More PCI stuff. Lua API, beginning.
parent
bf27bbb79a
commit
46a5fb8642
|
@ -41,6 +41,10 @@ obj/src/%.nao : src/%.asm
|
|||
@echo "[i] Assembling $*.asm..."
|
||||
@$(AS) -f elf64 -o obj/src/$*.nao src/$*.asm
|
||||
|
||||
obj/src/%.lo : src/%.lua
|
||||
@echo "[i] Packing $*.lua..."
|
||||
@contrib/luapack.py src/$*.lua obj/src/$*.lo
|
||||
|
||||
obj/src/%.o : src/%.c
|
||||
@echo "[i] Compiling $*.c ..."
|
||||
@if [ -e obj/src/$*.o ] ; then rm obj/src/$*.o ; fi
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/python2
|
||||
|
||||
import sys
|
||||
import struct
|
||||
|
||||
path = sys.argv[1]
|
||||
target = sys.argv[2]
|
||||
f = open(path, "r")
|
||||
source = f.read()
|
||||
f.close()
|
||||
|
||||
fs_path = path.replace("src/", "")
|
||||
data = struct.pack(">H", len(fs_path))
|
||||
data += fs_path
|
||||
data += struct.pack(">L", len(source))
|
||||
data += source
|
||||
|
||||
f = open(target, "wb")
|
||||
f.write(data)
|
||||
f.close()
|
|
@ -0,0 +1,34 @@
|
|||
alentours.pci.Device = {}
|
||||
|
||||
alentours.pci.buses = {}
|
||||
alentours.pci.devices = {}
|
||||
|
||||
function alentours.pci.Initialize()
|
||||
local Devices = alentours.pci.__GetAllDevices()
|
||||
for Location, DeviceRaw in pairs(Devices) do
|
||||
local BusID = Location.Bus
|
||||
local DeviceID = Location.Device
|
||||
|
||||
if alentours.pci.buses[BusID] == nil then
|
||||
alentours.pci.buses[BusID] = {}
|
||||
end
|
||||
|
||||
local Device = {}
|
||||
Device.__raw = DeviceRaw
|
||||
setmetatable(Device, alentours.pci.Device)
|
||||
|
||||
alentours.pci.buses[BusID][DeviceID] = Device
|
||||
end
|
||||
end
|
||||
|
||||
function alentours.pci.Device:GetVendor()
|
||||
return self.__raw.VID, self.__raw.VendorString
|
||||
end
|
||||
|
||||
function alentours.pci.Device:GetProduct()
|
||||
return self.__raw.PID, self.__raw.ProductName, self.__raw.ProductDescrption
|
||||
end
|
||||
|
||||
function alentours.pci.Device:WriteControl32(Offset, Data)
|
||||
|
||||
end
|
Loading…
Reference in New Issue