PCI+SVGA skeleton

This commit is contained in:
Able 2024-09-14 03:51:57 -05:00
parent 028949559b
commit cc9337348e
8 changed files with 117 additions and 7 deletions

View file

@ -0,0 +1 @@
# pci

View file

@ -0,0 +1,25 @@
PCIAddress := struct {
bus: u8,
device: u8,
function: u8,
}
find_device := fn(vendor_id: int, device_id: int, pci_address: PCIAddress): int {
return 1
}
scan_bus := fn(): void {
}
config_read32 := fn(bus: u32, device: u32, func: u32, offset: u32): u32 {
// construct address param
address := bus << 16 | device << 11 | func << 8 | offset & 0xFC | 0x80000000
// write address
//Port::new(0xCF8).write(address);
// read data
//Port::new(0xCFC).read()
return
}

View file

@ -25,7 +25,6 @@ main := fn(): int {
instance := ignim.instance.void_instance()
// TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
ret := ignim.instance.create_instance(&create_info, 0, &instance)
if ret == errors.IncompatibleDriver {

View file

@ -0,0 +1 @@
# svga_driver

View file

@ -0,0 +1,11 @@
[package]
name = "svga_driver"
authors = ["able"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang src/main.hb"

View file

@ -0,0 +1,41 @@
pci := @use("../../../libraries/pci/src/lib.hb");
.{PCIAddress} := pci
SVGADevice := struct {
pciAddr: PCIAddress,
ioBase: u32,
fifoMem: ^u32,
fbMem: ^u8,
fifoSize: int,
fbSize: int,
vramSize: int,
deviceVersionId: int,
capabilities: int,
width: int,
height: int,
bpp: int,
pitch: int,
}
svga_device := fn(): SVGADevice {
pci_addr := PCIAddress.(0, 0, 0)
return SVGADevice.(pci_addr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}
/*
struct {
uint32 reservedSize;
Bool usingBounceBuffer;
uint8 bounceBuffer[1024 * 1024];
uint32 nextFence;
} fifo;
volatile struct {
uint32 pending;
uint32 switchContext;
IntrContext oldContext;
IntrContext newContext;
uint32 count;
} irq;
*/

View file

@ -0,0 +1,28 @@
device := @use("rel:device.hb")
pci := @use("../../../libraries/pci/src/lib.hb")
stn := @use("../../../libraries/stn/src/lib.hb");
.{string, memory, buffer, log} := stn
PCI_VENDOR_ID_VMWARE := 0x15AD
PCI_DEVICE_ID_VMWARE_SVGA2 := 0x405
init := fn(): void {
svga_struct := device.svga_device()
if pci.find_device(PCI_VENDOR_ID_VMWARE, PCI_DEVICE_ID_VMWARE_SVGA2, svga_struct.pciAddr) {
log.error("No VMware SVGA device found.\0")
}
return
}
SVGA_Disable := fn(): void {
//SVGA_WriteReg(SVGA_REG_ENABLE, 0);
return
}
main := fn(): int {
init()
return 0
}

View file

@ -26,20 +26,24 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.diskio_driver]
# path = "boot:///diskio_driver.hbf"
[boot.limine.ableos.modules.fb_driver]
path = "boot:///fb_driver.hbf"
# [boot.limine.ableos.modules.fb_driver]
# path = "boot:///fb_driver.hbf"
# [boot.limine.ableos.modules.serial_driver_test]
# path = "boot:///serial_driver_test.hbf"
[boot.limine.ableos.modules.horizon]
path = "boot:///horizon.hbf"
# [boot.limine.ableos.modules.horizon]
# path = "boot:///horizon.hbf"
[boot.limine.ableos.modules.horizon_testing_program]
path = "boot:///horizon_testing_program.hbf"
# [boot.limine.ableos.modules.horizon_testing_program]
# path = "boot:///horizon_testing_program.hbf"
# [boot.limine.ableos.modules.dt_buffer_test]
# path = "boot:///dt_buffer_test.hbf"
[boot.limine.ableos.modules.svga_driver]
path = "boot:///svga_driver.hbf"