Compare commits
3 Commits
1c6c922b45
...
d86bf47211
Author | SHA1 | Date | |
---|---|---|---|
d86bf47211 | |||
757f8f8c65 | |||
8303451929 |
@ -7,6 +7,7 @@ import hulk.hurl;
|
||||
import hulk.hippo;
|
||||
import hulk.util;
|
||||
import hulk.pagetable;
|
||||
import hulk.memory;
|
||||
|
||||
/**
|
||||
* The A1 memory allocator is a one-shot memory allocator for kernel memory
|
||||
@ -48,6 +49,8 @@ struct A1
|
||||
current_limit += PAGE_SIZE;
|
||||
}
|
||||
|
||||
memset64(cast(void *)address, 0, size / 8);
|
||||
|
||||
return cast(void *)address;
|
||||
}
|
||||
|
||||
|
64
src/hulk/list.d
Normal file
64
src/hulk/list.d
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Linked list functionality.
|
||||
*/
|
||||
module hulk.list;
|
||||
|
||||
import hulk.hurl.a1;
|
||||
|
||||
/**
|
||||
* Linked list structure.
|
||||
*/
|
||||
struct List(T)
|
||||
{
|
||||
/**
|
||||
* Linked list item.
|
||||
*/
|
||||
T * item;
|
||||
|
||||
/**
|
||||
* Next list entry.
|
||||
*/
|
||||
List!T * next;
|
||||
|
||||
/**
|
||||
* Add an item to this linked list.
|
||||
*/
|
||||
public void add(T * item)
|
||||
{
|
||||
List!T * last_entry = last_entry();
|
||||
List!T * new_entry = A1.allocate!(List!T)();
|
||||
last_entry.item = item;
|
||||
last_entry.next = new_entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow foreach iteration across a List.
|
||||
*/
|
||||
public int opApply(scope int delegate(ref T) dg)
|
||||
{
|
||||
List!T * entry = &this;
|
||||
while (entry.next != null)
|
||||
{
|
||||
int result = dg(*entry.item);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
entry = entry.next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last linked list entry.
|
||||
*/
|
||||
private @property List!T * last_entry()
|
||||
{
|
||||
List!T * result = &this;
|
||||
while (result.next != null)
|
||||
{
|
||||
result = result.next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import hulk.hurl.a1;
|
||||
import hulk.range;
|
||||
import hulk.usb.xhci;
|
||||
import hulk.acpi;
|
||||
import hulk.list;
|
||||
|
||||
struct Pci
|
||||
{
|
||||
@ -196,6 +197,11 @@ struct Pci
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a list of discovered PCI devices.
|
||||
*/
|
||||
public static __gshared List!Device devices;
|
||||
|
||||
private static uint read_config_register(Address address, uint register_id)
|
||||
{
|
||||
uint cfg_addr = 0x8000_0000u |
|
||||
@ -361,6 +367,7 @@ struct Pci
|
||||
if (config.vendor_id != 0xFFFFu)
|
||||
{
|
||||
Device * device = A1.allocate!Device();
|
||||
devices.add(device);
|
||||
device.initialize(Address(bus_nr, device_nr, function_nr), config);
|
||||
if (device.multifunction)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user