/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "IntelGPIOController"; return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "AMDPCNet_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); ioProm1 = hardwareResources.GetIOPort(0, 0x0); ioProm4 = hardwareResources.GetIOPort(0, 0x4); rdp = hardwareResources.GetIOPort(0, 0x10); rap = hardwareResources.GetIOPort(0, 0x14); bdp = hardwareResources.GetIOPort(0, 0x1C); initBlock = hardwareResources.GetMemory(0); txDescriptor = hardwareResources.GetMemory(1); rxDescriptor = hardwareResources.GetMemory(2); buffers = hardwareResources.GetMemory(3); bufferSize = 2048; uint len = (ushort)(~bufferSize); len = (len + 1) & 0x0FFF | 0x8000F000; physicalBufferAddress = HAL.GetPhysicalAddress(buffers); for (uint index = 0; index < 16; index++) { uint offset = index * 4; rxDescriptor.Write32((offset + 1) * 4, len); rxDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * index)); txDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * (index + 16))); } nextTXDesc = 0; return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "COM_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); rbrBase = base.HardwareResources.GetIOPort(0, 0); // Receive Buffer Register (read only) thrBase = base.HardwareResources.GetIOPort(0, 0); // Transmitter Holding Register (write only) ierBase = base.HardwareResources.GetIOPort(0, 1); // Interrupt Enable Register dllBase = base.HardwareResources.GetIOPort(0, 0); // Divisor Latch (LSB and MSB) dlmBase = base.HardwareResources.GetIOPort(0, 1); iirBase = base.HardwareResources.GetIOPort(0, 2); // Interrupt Identification Register (read only) fcrBase = base.HardwareResources.GetIOPort(0, 2); // FIFO Control Register (write only, 16550+ only) lcrBase = base.HardwareResources.GetIOPort(0, 3); // Line Control Register mcrBase = base.HardwareResources.GetIOPort(0, 4); // Modem Control Register lsrBase = base.HardwareResources.GetIOPort(0, 5); // Line Status Register msrBase = base.HardwareResources.GetIOPort(0, 6); // Modem Status Register scrBase = base.HardwareResources.GetIOPort(0, 7); // Scratch Register (16450+ and some 8250s, special use with some boards) fifoBuffer = new byte[fifoSize]; fifoStart = 0; fifoEnd = 0; base.DeviceStatus = DeviceStatus.Online; return(true); }
protected void StartISADevice(ISADeviceDriverRegistryEntry driverEntry) { var ioPortRegions = new List <IOPortRegion>(); var memoryRegions = new List <MemoryRegion>(); ioPortRegions.Add(new IOPortRegion(driverEntry.BasePort, driverEntry.PortRange)); if (driverEntry.AltBasePort != 0x00) { ioPortRegions.Add(new IOPortRegion(driverEntry.AltBasePort, driverEntry.AltPortRange)); } if (driverEntry.BaseAddress != 0x00) { memoryRegions.Add(new MemoryRegion(driverEntry.BaseAddress, driverEntry.AddressRange)); } //if (driverEntry.PhysicalMemory != null) //{ // foreach (var physicalMemory in driver.PhysicalMemory) // { // if (physicalMemory.MemorySize > 0) // { // var memory = HAL.AllocateMemory(physicalMemory.MemorySize, physicalMemory.MemoryAlignment); // memoryRegions.Add(new MemoryRegion(memory.Address, memory.Size)); // } // } //} var hardwareResources = new HardwareResources(ioPortRegions, memoryRegions, driverEntry.IRQ); DeviceService.Initialize(driverEntry, Device, null, hardwareResources); }
/// <summary> /// Claims the resources. /// </summary> /// <param name="hardwareResources">The hardware resources.</param> /// <returns></returns> public bool ClaimResources(HardwareResources hardwareResources) { spinLock.Enter(); for (byte r = 0; r < hardwareResources.IOPointRegionCount - 1; r++) { var region = hardwareResources.GetIOPortRegion(r); for (int p = 0; p < region.Size; p++) { if (portUsed[region.BaseIOPort + p]) { return(false); } } } for (byte r = 0; r < hardwareResources.IOPointRegionCount; r++) { var region = hardwareResources.GetIOPortRegion(r); for (int p = 0; p < region.Size; p++) { portUsed[region.BaseIOPort + p] = true; } } spinLock.Exit(); return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "IntelPCI_ISA_IDE_Xcelerator_PIIX4"; return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "Intel82540EM"; return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <param name="hardwareResources"></param> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "IDE_0x" + base.HardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); DataPort = base.HardwareResources.GetIOPortReadWrite(0, 0); ErrorPort = base.HardwareResources.GetIOPortReadWrite(0, 1); FeaturePort = base.HardwareResources.GetIOPortReadWrite(0, 1); SectorCountPort = base.HardwareResources.GetIOPortReadWrite(0, 2); LBALowPort = base.HardwareResources.GetIOPortReadWrite(0, 3); LBAMidPort = base.HardwareResources.GetIOPortReadWrite(0, 4); LBAHighPort = base.HardwareResources.GetIOPortReadWrite(0, 5); DeviceHeadPort = base.HardwareResources.GetIOPortReadWrite(0, 6); CommandPort = base.HardwareResources.GetIOPortWrite(0, 7); StatusPort = base.HardwareResources.GetIOPortReadWrite(0, 7); ControlPort = base.HardwareResources.GetIOPortWrite(1, 0); AltStatusPort = base.HardwareResources.GetIOPortReadWrite(1, 6); for (var drive = 0; drive < DrivesPerConroller; drive++) { driveInfo[drive].Present = false; driveInfo[drive].MaxLBA = 0; } base.DeviceStatus = DeviceStatus.Online; return(true); }
/// <summary> /// Claims the resources. /// </summary> /// <param name="hardwareResources">The hardware resources.</param> /// <returns></returns> public bool ClaimResources(HardwareResources hardwareResources) { spinLock.Enter(); for (byte r = 0; r < hardwareResources.IOPointRegionCount - 1; r++) { var region = hardwareResources.GetIOPortRegion(r); for (int p = 0; p < region.Size; p++) { if (portUsed[region.BaseIOPort + p]) return false; } } for (byte r = 0; r < hardwareResources.IOPointRegionCount; r++) { var region = hardwareResources.GetIOPortRegion(r); for (int p = 0; p < region.Size; p++) { portUsed[region.BaseIOPort + p] = true; } } spinLock.Exit(); return true; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "GenericVGA"; byte portBar = (byte)(base.HardwareResources.IOPointRegionCount - 1); miscellaneousOutputRead = base.HardwareResources.GetIOPort(portBar, 0x1C); crtControllerIndex = base.HardwareResources.GetIOPort(portBar, 0x04); crtControllerData = base.HardwareResources.GetIOPort(portBar, 0x05); crtControllerIndexColor = base.HardwareResources.GetIOPort(portBar, 0x24); crtControllerDataColor = base.HardwareResources.GetIOPort(portBar, 0x25); dacPaletteMask = base.HardwareResources.GetIOPort(portBar, 0x16); dacIndexRead = base.HardwareResources.GetIOPort(portBar, 0x17); dacIndexWrite = base.HardwareResources.GetIOPort(portBar, 0x18); dacData = base.HardwareResources.GetIOPort(portBar, 0x19); inputStatus1 = base.HardwareResources.GetIOPort(portBar, 0x12); miscellaneousOutputWrite = base.HardwareResources.GetIOPort(portBar, 0x12); sequencerAddress = base.HardwareResources.GetIOPort(portBar, 0x14); sequencerData = base.HardwareResources.GetIOPort(portBar, 0x15); graphicsControllerAddress = base.HardwareResources.GetIOPort(portBar, 0x1E); graphicsControllerData = base.HardwareResources.GetIOPort(portBar, 0x1F); inputStatus1ReadB = base.HardwareResources.GetIOPort(portBar, 0x2A); attributeAddress = base.HardwareResources.GetIOPort(portBar, 0x10); attributeData = base.HardwareResources.GetIOPort(portBar, 0x11); memory = base.HardwareResources.GetMemory((byte)(base.HardwareResources.MemoryRegionCount - 1)); return(true); }
/// <summary> /// Starts the device. /// </summary> /// <param name="deviceDriver">The device driver.</param> static public void StartDevice(Mosa.HardwareSystem.DeviceDriver deviceDriver) { var driverAtttribute = deviceDriver.Attribute as ISADeviceDriverAttribute; // TEMP: Don't load the VGAText and PIC drivers if (driverAtttribute.BasePort == 0x03B0 || driverAtttribute.BasePort == 0x20) { return; } if (!driverAtttribute.AutoLoad) { return; } var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; var ioPortRegions = new LinkedList <IOPortRegion>(); var memoryRegions = new LinkedList <MemoryRegion>(); ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.BasePort, driverAtttribute.PortRange)); if (driverAtttribute.AltBasePort != 0x00) { ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.AltBasePort, driverAtttribute.AltPortRange)); } if (driverAtttribute.BaseAddress != 0x00) { memoryRegions.AddLast(new MemoryRegion(driverAtttribute.BaseAddress, driverAtttribute.AddressRange)); } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { var memory = Mosa.HardwareSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } var hardwareResources = new HardwareResources( ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(InterruptManager, driverAtttribute.IRQ, hardwareDevice) ); hardwareDevice.Setup(hardwareResources); Boot.Console.Write("Adding device "); Boot.InBrackets(hardwareDevice.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.WriteLine(); deviceManager.Add(hardwareDevice); hardwareResources.EnableIRQ(); hardwareDevice.Start(); }
/// <summary> /// Starts the device. /// </summary> /// <param name="deviceDriver">The device driver.</param> static public void StartDevice(Mosa.DeviceSystem.DeviceDriver deviceDriver) { var driverAtttribute = deviceDriver.Attribute as ISADeviceDriverAttribute; // Don't load the VGAText and PIC drivers if (/*driverAtttribute.BasePort == 0x03B0 || */ driverAtttribute.BasePort == 0x20) { return; } if (driverAtttribute.AutoLoad) { var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; var ioPortRegions = new LinkedList <IIOPortRegion>(); var memoryRegions = new LinkedList <IMemoryRegion>(); ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.BasePort, driverAtttribute.PortRange)); if (driverAtttribute.AltBasePort != 0x00) { ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.AltBasePort, driverAtttribute.AltPortRange)); } if (driverAtttribute.BaseAddress != 0x00) { memoryRegions.AddLast(new MemoryRegion(driverAtttribute.BaseAddress, driverAtttribute.AddressRange)); } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { IMemory memory = Mosa.DeviceSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } var hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, driverAtttribute.IRQ, hardwareDevice)); if (resourceManager.ClaimResources(hardwareResources)) { hardwareResources.EnableIRQ(); hardwareDevice.Setup(hardwareResources); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { deviceManager.Add(hardwareDevice); } else { hardwareResources.DisableIRQ(); resourceManager.ReleaseResources(hardwareResources); } } } }
private static void StartDevice(IPCIDevice pciDevice, Mosa.HardwareSystem.DeviceDriver deviceDriver, IHardwareDevice hardwareDevice) { var ioPortRegions = new LinkedList <IOPortRegion>(); var memoryRegions = new LinkedList <MemoryRegion>(); foreach (var pciBaseAddress in pciDevice.BaseAddresses) { switch (pciBaseAddress.Region) { case AddressType.IO: ioPortRegions.AddLast(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break; case AddressType.Memory: memoryRegions.AddLast(new MemoryRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break; default: break; } } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { var memory = Mosa.HardwareSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } foreach (var ioportregion in ioPortRegions) { Boot.Console.WriteLine(" I/O: 0x" + ioportregion.BaseIOPort.ToString("X") + " [" + ioportregion.Size.ToString("X") + "]"); } foreach (var memoryregion in memoryRegions) { Boot.Console.WriteLine(" Memory: 0x" + memoryregion.BaseAddress.ToString("X") + " [" + memoryregion.Size.ToString("X") + "]"); } //Boot.Console.WriteLine(" Command: 0x" + hardwareDevice...ToString("X")); var hardwareResources = new HardwareResources( ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(InterruptManager, pciDevice.IRQ, hardwareDevice), pciDevice as IPCIDeviceResource ); hardwareDevice.Setup(hardwareResources); deviceManager.Add(hardwareDevice); hardwareResources.EnableIRQ(); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { pciDevice.SetDeviceOnline(); } }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "CMOS"; commandPort = base.HardwareResources.GetIOPort(0, 0); dataPort = base.HardwareResources.GetIOPort(0, 4); return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "PCI_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); configAddress = base.HardwareResources.GetIOPort(0, 0); configData = base.HardwareResources.GetIOPort(0, 4); return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "PIT_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); modeControlPort = base.HardwareResources.GetIOPort(0, 3); counter0Divisor = base.HardwareResources.GetIOPort(0, 0); return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <param name="hardwareResources"></param> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "PIC_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); masterCommandPort = base.HardwareResources.GetIOPort(0, 0); masterDataPort = base.HardwareResources.GetIOPort(0, 1); slaveCommandPort = base.HardwareResources.GetIOPort(1, 0); slaveDataPort = base.HardwareResources.GetIOPort(1, 1); return(true); }
/// <summary> /// Setups the standard keyboard driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "StandardKeyboard"; commandPort = base.HardwareResources.GetIOPortReadWrite(0, 0); dataPort = base.HardwareResources.GetIOPortReadWrite(1, 0); fifoBuffer = new byte[fifoSize]; fifoStart = 0; fifoEnd = 0; return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "VMWARE_SVGA_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); indexPort = hardwareResources.GetIOPort(0, 0); valuePort = hardwareResources.GetIOPort(0, 1); HAL.DebugWrite("**G**"); memory = base.HardwareResources.GetMemory(0); HAL.DebugWrite("**I**"); fifo = base.HardwareResources.GetMemory(1); HAL.DebugWrite("**J**"); return(true); }
/// <summary> /// Releases the resources. /// </summary> /// <param name="hardwareResources">The hardware resources.</param> public void ReleaseResources(HardwareResources hardwareResources) { lock (_lock) { for (byte r = 0; r < hardwareResources.IOPointRegionCount; r++) { var region = hardwareResources.GetIOPortRegion(r); for (int p = 0; p < region.Size; p++) { portUsed[region.BaseIOPort + p] = false; } } } }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "FDC_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); base.Parent = null; // no parent commandPort = base.HardwareResources.GetIOPort(0, 2); statusPort = base.HardwareResources.GetIOPort(0, 4); dataPort = base.HardwareResources.GetIOPort(0, 5); configPort = base.HardwareResources.GetIOPort(0, 7); // floppyDMA = base.CreateDMAChannel(2); // floppyIRQ = base.CreateIRQHandler(6); return(true); }
private static void StartDevice(IPCIDevice pciDevice, Mosa.DeviceSystem.DeviceDriver deviceDriver, IHardwareDevice hardwareDevice) { var ioPortRegions = new LinkedList <IIOPortRegion>(); var memoryRegions = new LinkedList <IMemoryRegion>(); foreach (var pciBaseAddress in pciDevice.BaseAddresses) { switch (pciBaseAddress.Region) { case AddressType.IO: ioPortRegions.AddLast(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break; case AddressType.Memory: memoryRegions.AddLast(new MemoryRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break; default: break; } } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { var memory = Mosa.DeviceSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } var hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, pciDevice.IRQ, hardwareDevice), pciDevice as IDeviceResource); if (resourceManager.ClaimResources(hardwareResources)) { hardwareResources.EnableIRQ(); hardwareDevice.Setup(hardwareResources); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { pciDevice.SetDeviceOnline(); } else { hardwareResources.DisableIRQ(); resourceManager.ReleaseResources(hardwareResources); } } }
/// <summary> /// Setups this hardware device driver /// </summary> /// <param name="hardwareResources"></param> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { // Store reference to hardware resources this.HardwareResources = hardwareResources; // Set the driver's name base.Name = "S3Trio64V2"; // Store portmanager byte portBar = (byte)(base.HardwareResources.IOPointRegionCount - 1); vgaEnableController = base.HardwareResources.GetIOPortReadWrite(portBar, Register.VgaEnable); miscOutputReader = base.HardwareResources.GetIOPortReadWrite(portBar, Register.MiscOutRead); miscOutputWriter = base.HardwareResources.GetIOPortReadWrite(portBar, Register.MiscOutWrite); crtcControllerIndex = base.HardwareResources.GetIOPortReadWrite(portBar, Register.CrtcIndex); crtcControllerData = base.HardwareResources.GetIOPortReadWrite(portBar, Register.CrtcData); seqControllerIndex = base.HardwareResources.GetIOPortReadWrite(portBar, Register.SequenceIndex); seqControllerData = base.HardwareResources.GetIOPortReadWrite(portBar, Register.SequenceData); // Everything went fine return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "DMA_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); statusRegister = base.HardwareResources.GetIOPort(0, 0x08); commandRegister = base.HardwareResources.GetIOPort(0, 0x08); requestRegister = base.HardwareResources.GetIOPort(0, 0x09); channelMaskRegister = base.HardwareResources.GetIOPort(0, 0x0A); modeRegister = base.HardwareResources.GetIOPort(0, 0x0B); byteWordRegister = base.HardwareResources.GetIOPort(0, 0x0C); intermediateRegister = base.HardwareResources.GetIOPort(0, 0x0D); maskRegister = base.HardwareResources.GetIOPort(0, 0x0F); channel0Address = base.HardwareResources.GetIOPort(0, 0x00); channel0Count = base.HardwareResources.GetIOPort(0, 0x01); channel0Page = base.HardwareResources.GetIOPort(0, 0x87); channel1Address = base.HardwareResources.GetIOPort(0, 0x02); channel1Count = base.HardwareResources.GetIOPort(0, 0x03); channel1Page = base.HardwareResources.GetIOPort(0, 0x83); channel2Address = base.HardwareResources.GetIOPort(0, 0x04); channel2Count = base.HardwareResources.GetIOPort(0, 0x05); channel2Page = base.HardwareResources.GetIOPort(0, 0x81); channel3Address = base.HardwareResources.GetIOPort(0, 0x06); channel3Count = base.HardwareResources.GetIOPort(0, 0x07); channel3Page = base.HardwareResources.GetIOPort(0, 0x82); memory0 = base.HardwareResources.GetMemory(0); memory1 = base.HardwareResources.GetMemory(1); memory2 = base.HardwareResources.GetMemory(2); memory3 = base.HardwareResources.GetMemory(3); return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "VGAText"; miscellaneousOutput = base.HardwareResources.GetIOPort(0, 0x1C); crtControllerIndex = base.HardwareResources.GetIOPort(0, 0x04); crtControllerData = base.HardwareResources.GetIOPort(0, 0x05); crtControllerIndexColor = base.HardwareResources.GetIOPort(0, 0x24); crtControllerDataColor = base.HardwareResources.GetIOPort(0, 0x25); miscellaneousOutputWrite = base.HardwareResources.GetIOPort(0, 0x12); sequencerAddress = base.HardwareResources.GetIOPort(0, 0x14); sequencerData = base.HardwareResources.GetIOPort(0, 0x15); graphicsControllerAddress = base.HardwareResources.GetIOPort(0, 0x1E); graphicsControllerData = base.HardwareResources.GetIOPort(0, 0x1F); inputStatus1ReadB = base.HardwareResources.GetIOPort(0, 0x2A); attributeAddress = base.HardwareResources.GetIOPort(0, 0x10); attributeData = base.HardwareResources.GetIOPort(0, 0x11); memory = base.HardwareResources.GetMemory(0); return(true); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "FDC_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); base.Parent = null; // no parent commandPort = base.HardwareResources.GetIOPort(0, 2); statusPort = base.HardwareResources.GetIOPort(0, 4); dataPort = base.HardwareResources.GetIOPort(0, 5); configPort = base.HardwareResources.GetIOPort(0, 7); // floppyDMA = base.CreateDMAChannel(2); // floppyIRQ = base.CreateIRQHandler(6); return true; }
/// <summary> /// Releases the resources. /// </summary> /// <param name="hardwareResources">The hardware resources.</param> public void ReleaseResources(HardwareResources hardwareResources) { spinLock.Enter(); for (byte r = 0; r < hardwareResources.IOPointRegionCount; r++) { var region = hardwareResources.GetIOPortRegion(r); for (int p = 0; p < region.Size; p++) { portUsed[region.BaseIOPort + p] = false; } } spinLock.Exit(); }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "AMDPCNet_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); ioProm1 = hardwareResources.GetIOPort(0, 0x0); ioProm4 = hardwareResources.GetIOPort(0, 0x4); rdp = hardwareResources.GetIOPort(0, 0x10); rap = hardwareResources.GetIOPort(0, 0x14); bdp = hardwareResources.GetIOPort(0, 0x1C); initBlock = hardwareResources.GetMemory(0); txDescriptor = hardwareResources.GetMemory(1); rxDescriptor = hardwareResources.GetMemory(2); buffers = hardwareResources.GetMemory(3); bufferSize = 2048; uint len = (ushort)(~bufferSize); len = (len + 1) & 0x0FFF | 0x8000F000; physicalBufferAddress = HAL.GetPhysicalAddress(buffers); for (uint index = 0; index < 16; index++) { uint offset = index * 4; rxDescriptor.Write32((offset + 1) * 4, len); rxDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * index)); txDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * (index + 16))); } nextTXDesc = 0; return true; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "VGAText"; miscellaneousOutput = base.HardwareResources.GetIOPort(0, 0x1C); crtControllerIndex = base.HardwareResources.GetIOPort(0, 0x04); crtControllerData = base.HardwareResources.GetIOPort(0, 0x05); crtControllerIndexColor = base.HardwareResources.GetIOPort(0, 0x24); crtControllerDataColor = base.HardwareResources.GetIOPort(0, 0x25); miscellaneousOutputWrite = base.HardwareResources.GetIOPort(0, 0x12); sequencerAddress = base.HardwareResources.GetIOPort(0, 0x14); sequencerData = base.HardwareResources.GetIOPort(0, 0x15); graphicsControllerAddress = base.HardwareResources.GetIOPort(0, 0x1E); graphicsControllerData = base.HardwareResources.GetIOPort(0, 0x1F); inputStatus1ReadB = base.HardwareResources.GetIOPort(0, 0x2A); attributeAddress = base.HardwareResources.GetIOPort(0, 0x10); attributeData = base.HardwareResources.GetIOPort(0, 0x11); memory = base.HardwareResources.GetMemory(0); return true; }
/// <summary> /// Starts the device. /// </summary> /// <param name="deviceDriver">The device driver.</param> public static void StartDevice(Mosa.HardwareSystem.DeviceDriver deviceDriver) { var driverAtttribute = deviceDriver.Attribute as ISADeviceDriverAttribute; // TEMP: Don't load the VGAText and PIC drivers if (driverAtttribute.BasePort == 0x03B0 || driverAtttribute.BasePort == 0x20) return; if (!driverAtttribute.AutoLoad) return; var hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; var ioPortRegions = new LinkedList<IOPortRegion>(); var memoryRegions = new LinkedList<MemoryRegion>(); ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.BasePort, driverAtttribute.PortRange)); if (driverAtttribute.AltBasePort != 0x00) { ioPortRegions.AddLast(new IOPortRegion(driverAtttribute.AltBasePort, driverAtttribute.AltPortRange)); } if (driverAtttribute.BaseAddress != 0x00) { memoryRegions.AddLast(new MemoryRegion(driverAtttribute.BaseAddress, driverAtttribute.AddressRange)); } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { var memory = Mosa.HardwareSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } var hardwareResources = new HardwareResources( ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(InterruptManager, driverAtttribute.IRQ, hardwareDevice) ); hardwareDevice.Setup(hardwareResources); Boot.Console.Write("Adding device "); Boot.InBrackets(hardwareDevice.Name, Mosa.Kernel.x86.Colors.White, Mosa.Kernel.x86.Colors.LightGreen); Boot.Console.WriteLine(); deviceManager.Add(hardwareDevice); hardwareResources.EnableIRQ(); hardwareDevice.Start(); }
/// <summary> /// Setups the standard keyboard driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "StandardKeyboard"; commandPort = base.HardwareResources.GetIOPort(0, 0); dataPort = base.HardwareResources.GetIOPort(1, 0); fifoBuffer = new byte[fifoSize]; fifoStart = 0; fifoEnd = 0; return true; }
private static void StartDevice(IPCIDevice pciDevice, Mosa.HardwareSystem.DeviceDriver deviceDriver, IHardwareDevice hardwareDevice) { var ioPortRegions = new LinkedList<IOPortRegion>(); var memoryRegions = new LinkedList<MemoryRegion>(); foreach (var pciBaseAddress in pciDevice.BaseAddresses) { switch (pciBaseAddress.Region) { case AddressType.IO: ioPortRegions.AddLast(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break; case AddressType.Memory: memoryRegions.AddLast(new MemoryRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break; default: break; } } foreach (var memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { var memory = Mosa.HardwareSystem.HAL.AllocateMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.AddLast(new MemoryRegion(memory.Address, memory.Size)); } } foreach (var ioportregion in ioPortRegions) { Boot.Console.WriteLine(" I/O: 0x" + ioportregion.BaseIOPort.ToString("X") + " [" + ioportregion.Size.ToString("X") + "]"); } foreach (var memoryregion in memoryRegions) { Boot.Console.WriteLine(" Memory: 0x" + memoryregion.BaseAddress.ToString("X") + " [" + memoryregion.Size.ToString("X") + "]"); } //Boot.Console.WriteLine(" Command: 0x" + hardwareDevice...ToString("X")); var hardwareResources = new HardwareResources( ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(InterruptManager, pciDevice.IRQ, hardwareDevice), pciDevice as IPCIDeviceResource ); hardwareDevice.Setup(hardwareResources); deviceManager.Add(hardwareDevice); hardwareResources.EnableIRQ(); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { pciDevice.SetDeviceOnline(); } }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { // Store reference to hardware resources this.HardwareResources = hardwareResources; // Set the driver's name base.Name = "S3Trio64V2"; // Store portmanager byte portBar = (byte)(base.HardwareResources.IOPointRegionCount - 1); vgaEnableController = base.HardwareResources.GetIOPort(portBar, Register.VgaEnable); miscOutputReader = base.HardwareResources.GetIOPort(portBar, Register.MiscOutRead); miscOutputWriter = base.HardwareResources.GetIOPort(portBar, Register.MiscOutWrite); crtcControllerIndex = base.HardwareResources.GetIOPort(portBar, Register.CrtcIndex); crtcControllerData = base.HardwareResources.GetIOPort(portBar, Register.CrtcData); seqControllerIndex = base.HardwareResources.GetIOPort(portBar, Register.SequenceIndex); seqControllerData = base.HardwareResources.GetIOPort(portBar, Register.SequenceData); // Everything went fine return true; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "GenericVGA"; byte portBar = (byte)(base.HardwareResources.IOPointRegionCount - 1); miscellaneousOutputRead = base.HardwareResources.GetIOPort(portBar, 0x1C); crtControllerIndex = base.HardwareResources.GetIOPort(portBar, 0x04); crtControllerData = base.HardwareResources.GetIOPort(portBar, 0x05); crtControllerIndexColor = base.HardwareResources.GetIOPort(portBar, 0x24); crtControllerDataColor = base.HardwareResources.GetIOPort(portBar, 0x25); dacPaletteMask = base.HardwareResources.GetIOPort(portBar, 0x16); dacIndexRead = base.HardwareResources.GetIOPort(portBar, 0x17); dacIndexWrite = base.HardwareResources.GetIOPort(portBar, 0x18); dacData = base.HardwareResources.GetIOPort(portBar, 0x19); inputStatus1 = base.HardwareResources.GetIOPort(portBar, 0x12); miscellaneousOutputWrite = base.HardwareResources.GetIOPort(portBar, 0x12); sequencerAddress = base.HardwareResources.GetIOPort(portBar, 0x14); sequencerData = base.HardwareResources.GetIOPort(portBar, 0x15); graphicsControllerAddress = base.HardwareResources.GetIOPort(portBar, 0x1E); graphicsControllerData = base.HardwareResources.GetIOPort(portBar, 0x1F); inputStatus1ReadB = base.HardwareResources.GetIOPort(portBar, 0x2A); attributeAddress = base.HardwareResources.GetIOPort(portBar, 0x10); attributeData = base.HardwareResources.GetIOPort(portBar, 0x11); memory = base.HardwareResources.GetMemory((byte)(base.HardwareResources.MemoryRegionCount - 1)); return true; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "VMWARE_SVGA_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X"); indexPort = hardwareResources.GetIOPort(0, 0); valuePort = hardwareResources.GetIOPort(0, 1); HAL.DebugWrite("**G**"); memory = base.HardwareResources.GetMemory(0); HAL.DebugWrite("**I**"); fifo = base.HardwareResources.GetMemory(1); HAL.DebugWrite("**J**"); return true; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <param name="hardwareResources"></param> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "IDE_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); DataPort = base.HardwareResources.GetIOPort(0, 0); ErrorPort = base.HardwareResources.GetIOPort(0, 1); FeaturePort = base.HardwareResources.GetIOPort(0, 1); SectorCountPort = base.HardwareResources.GetIOPort(0, 2); LBALowPort = base.HardwareResources.GetIOPort(0, 3); LBAMidPort = base.HardwareResources.GetIOPort(0, 4); LBAHighPort = base.HardwareResources.GetIOPort(0, 5); DeviceHeadPort = base.HardwareResources.GetIOPort(0, 6); CommandPort = base.HardwareResources.GetIOPort(0, 7); StatusPort = base.HardwareResources.GetIOPort(0, 7); for (int drive = 0; drive < DrivesPerConroller; drive++) { driveInfo[drive].Present = false; driveInfo[drive].MaxLBA = 0; } base.DeviceStatus = DeviceStatus.Online; return true; }
/// <summary> /// Setups this hardware device driver /// </summary> /// <returns></returns> public override bool Setup(HardwareResources hardwareResources) { this.HardwareResources = hardwareResources; base.Name = "COM_0x" + base.HardwareResources.GetIOPort(0, 0).Address.ToString("X"); rbrBase = base.HardwareResources.GetIOPort(0, 0); // Receive Buffer Register (read only) thrBase = base.HardwareResources.GetIOPort(0, 0); // Transmitter Holding Register (write only) ierBase = base.HardwareResources.GetIOPort(0, 1); // Interrupt Enable Register dllBase = base.HardwareResources.GetIOPort(0, 0); // Divisor Latch (LSB and MSB) dlmBase = base.HardwareResources.GetIOPort(0, 1); iirBase = base.HardwareResources.GetIOPort(0, 2); // Interrupt Identification Register (read only) fcrBase = base.HardwareResources.GetIOPort(0, 2); // FIFO Control Register (write only, 16550+ only) lcrBase = base.HardwareResources.GetIOPort(0, 3); // Line Control Register mcrBase = base.HardwareResources.GetIOPort(0, 4); // Modem Control Register lsrBase = base.HardwareResources.GetIOPort(0, 5); // Line Status Register msrBase = base.HardwareResources.GetIOPort(0, 6); // Modem Status Register scrBase = base.HardwareResources.GetIOPort(0, 7); // Scratch Register (16450+ and some 8250s, special use with some boards) fifoBuffer = new byte[fifoSize]; fifoStart = 0; fifoEnd = 0; base.DeviceStatus = DeviceStatus.Online; return true; }