Cosmos: Implement PCI Scanning

Created on 15 Jun 2017  路  8Comments  路  Source: CosmosOS/Cosmos

Cosmos hardcodes a lot of things during the boot phase (the PCI address of VGA I/O ports, serial ports, assume that a master IDE driver exists and so on) this could give problems when Cosmos is booted on real hardware and block the possibility to create proper device drivers.

Kernel Medium

Most helpful comment

  • PCI
  • #666
    Wooohoo! :)

All 8 comments

  • PCI
  • #666
    Wooohoo! :)

I'd like to start working on this.

A couple thoughts and questions:

  1. There is already a function that enumerates pci devices that seems to work, so I'd be starting with it.

  2. I'm not 100% sure where in the boot process I should enumerate the devices. I know it needs to be before hard disk, video and serial are initialized. I'll look more at the code to find where to enumerate the bus.

  3. serial.cs assumes two serial ports. I think this should probably be changed to accept an arbitrary number of serial ports. May need to be a separate issue, but what should happen if more than two serial ports are found during enumeration?

  4. Serial port and vga code don't seem to use the pcidevice class. Are serial and vga considered pci devices? If so, they need refactored as pcidevice drivers, which can be part of this effort.

I'm new to os development, so forgive me if any if what I'm saying doesn't make sense. Any input is appreciated.

  1. Turned out I was looking at a file in the archive folder. Is there a serial driver in cosmos currently?

I don't think so.

There is a low level serial driver used by debugger I think but it is not exposed to user level.

VGA are PCI devices: the Bochs Video Driver (that is called VBE for a OSDEV error IMHO) has all hardcoded but is possible that using PCI we find the needed I/O ports in a better way, the VMWare driver need PCI scanning to work properly!

Some other devices are not found using PCI (for example legacy serial port, cooler, power devices) we will need ACPI for this probably.

@fanoI what's left on this?

This issue https://github.com/CosmosOS/Cosmos/issues/640 did the work only for PATA / IDE (partially as ATA was started in any case) but we have yet a lot of hard coded thing in Cosmos.

For example:

  1. If the Bochs VGA driver starts try to use the hardcoded I/O port without really checking that on the PCI a Bochs VGA does exists
  2. VmWare SVGA wanted to use PCI but to find the I/O port but it was not working
  3. The probably broken AMDNet driver had the same issue
  4. Serial Port have hardcode I/O ports (I don't know if the "legacy" serial ports can be found with PCI scanning)

I'd say a good starting point to say "well we have PCI scanning... now we need only to start the proper driver" will be to Enumerate the PCI bus and show on the Cosmos Console a "table" with for example these data:

Device Category | Vendor | Device ID
SATA Controller | Intel | 0x666
USB Controller | Intel | 0x444
VGA Card | Bochs | 0x689
Audio Card | Creative | 0x999
[...]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vardan2009 picture Vardan2009  路  11Comments

AAli107 picture AAli107  路  10Comments

manamster picture manamster  路  4Comments

jpmac26 picture jpmac26  路  8Comments

artizzq picture artizzq  路  9Comments