diff --git a/drivers/devman/Makefile b/drivers/devman/Makefile index 2e4ad8a68d..ae03196373 100644 --- a/drivers/devman/Makefile +++ b/drivers/devman/Makefile @@ -1,56 +1,42 @@ +CC = kos32-gcc +LD = kos32-ld +KPACK = kpack +CFLAGS = -c -w -O2 -fomit-frame-pointer -fno-builtin-printf -CC = gcc -FASM = e:/fasm/fasm.exe +DRV_DIR = $(CURDIR)/.. +INCLUDES = -I$(DRV_DIR)/devman/acpica/include -I$(DRV_DIR)/devman -I$(DRV_DIR)/include/linux -I$(DRV_DIR)/include -I$(DRV_DIR)/include/uapi -CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf +DEFINES = -D__KERNEL__ -DCONFIG_X86_32 -DCONFIG_X86_L1_CACHE_SHIFT=6 -DCONFIG_ARCH_HAS_CACHE_LINE_SIZE -DHAVE_ACPICA -DCONFIG_ACPI -DLINUX_MOD_DEVICETABLE_H -DCONFIG_PCI +LDFLAGS = -nostdlib -shared -s -Map acpi.map --image-base 0 --file-alignment 512 --section-alignment 4096 -DRV_DIR = $(CURDIR)/.. +LIBPATH := -L$(DRV_DIR)/ddk -L../devman/acpica -L../../contrib/sdk/lib +LIBS := -lacpica -lgcc -lddk -lcore -DRV_INCLUDES = $(DRV_DIR)/include +NAME = acpi.sys -ACPI_INCLUDES = ./acpica/include +NAME_SRCS = acpi.c \ + scan.c \ + pci_root.c \ + pci_bind.c \ + pci_irq.c \ + pci/probe.c \ + pci/pci.c \ + pci/access.c -INCLUDES = -I$(DRV_INCLUDES) -I$(ACPI_INCLUDES) -I$(DRV_DIR)/include/linux +all: $(NAME) -DEFINES = -D__KERNEL__ -DCONFIG_X86_32 - -LDFLAGS = -nostdlib -shared -s -Map acpi.map --image-base 0\ - --file-alignment 512 --section-alignment 4096 - -LIBPATH:= -L$(DRV_DIR)/ddk -L./acpica - -LIBS:= -lacpica -lgcc -lddk -lcore - - -NAME= acpi - -NAME_SRCS= acpi.c \ - scan.c \ - pci_irq.c \ - pci_root.c \ - pci/access.c \ - pci/pci.c \ - pci/probe.c \ - pci_bind.c - - -all: $(NAME).dll - -NAME_OBJS = $(patsubst %.S, %.o, $(patsubst %.asm, %.o,\ +NAME_OBJS = $(patsubst %.S, %.o, $(patsubst %.asm, %.o, \ $(patsubst %.c, %.o, $(NAME_SRCS)))) -$(NAME).dll: $(NAME_OBJS) acpi.lds Makefile - ld $(LIBPATH) $(LDFLAGS) -T acpi.lds -o $@ $(NAME_OBJS) $(LIBS) - kpack $(NAME).dll +$(NAME): $(NAME_OBJS) ../devman/acpi.lds Makefile + $(LD) $(LIBPATH) $(LDFLAGS) -T ../devman/acpi.lds -o $@ $(NAME_OBJS) $(LIBS) + $(KPACK) $(NAME) %.o : %.c $(HFILES) Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< -%.o : %.S $(HFILES) Makefile - as -o $@ $< - - - +clean: + rm -rf *.o diff --git a/drivers/devman/Tupfile.lua b/drivers/devman/Tupfile.lua new file mode 100755 index 0000000000..abcafe8e86 --- /dev/null +++ b/drivers/devman/Tupfile.lua @@ -0,0 +1,21 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +if tup.getconfig("NO_GCC") ~= "" then return end +tup.include("../../programs/use_gcc.lua") + +DRV_DIR = ".." +INCLUDES = string.format(" -I./include -I./acpica/include -I. -I%s/include -I%s/include/linux -I%s/include/uapi ", DRV_DIR, DRV_DIR, DRV_DIR) + +DEFINES = " -D__KERNEL__ -DCONFIG_X86_32 -DCONFIG_X86_L1_CACHE_SHIFT=6 -DCONFIG_ARCH_HAS_CACHE_LINE_SIZE -DHAVE_ACPICA -DCONFIG_ACPI -DLINUX_MOD_DEVICETABLE_H -DCONFIG_PCI " + +CFLAGS = " -w -Os -march=i686 -fno-ident -msse2 -fomit-frame-pointer -fno-builtin-printf -mno-stack-arg-probe -mpreferred-stack-boundary=2 -mincoming-stack-boundary=2 -mno-ms-bitfields " .. DEFINES + +LDFLAGS = " -nostdlib -T acpi.lds -shared -s --image-base 0 --file-alignment 512 --section-alignment 4096 -L../../contrib/sdk/lib -L../ddk -Lacpica " + +NAME = "acpi.sys" + +compile_gcc{ "acpi.c", "scan.c", "pci_root.c", "pci_bind.c", "pci_irq.c", "pci/probe.c", "pci/pci.c", "pci/access.c" } +OBJS.extra_inputs = {"../ddk/libcore.a", "../ddk/libddk.a", "./acpica/libacpica.a"} + +LIBS = " -lacpica -lgcc -lddk -lcore " +tup.rule(OBJS, "kos32-ld" .. LDFLAGS .. "%f -o %o " .. LIBS .. tup.getconfig("KPACK_CMD"), NAME); +tup.rule("acpi.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "acpi") diff --git a/drivers/devman/acpi.asm b/drivers/devman/acpi.asm index 6cf10b55a6..b5b3de6d12 100644 --- a/drivers/devman/acpi.asm +++ b/drivers/devman/acpi.asm @@ -27,7 +27,7 @@ start: align 4 app_path rb 2048 -sz_dll db '.dll',0 +sz_dll db '.sys',0 i_end: rb 128 mem: diff --git a/drivers/devman/acpi.c b/drivers/devman/acpi.c index 908ca2a033..91620486f9 100644 --- a/drivers/devman/acpi.c +++ b/drivers/devman/acpi.c @@ -571,46 +571,37 @@ void acpi_init_pci(struct acpi_device *device) }; - -u32_t drvEntry(int action, char *cmdline) +uint32_t drvEntry(int action, char *cmdline) { - u32_t retval; - + uint32_t retval; ACPI_STATUS status; - int i; if(action != 1) return 0; - if( !dbg_open("/rd/1/drivers/acpi.log") ) - { - printf("Can't open /rd/1/drivers/acpi.log\nExit\n"); - return 0; - } - status = AcpiInitializeSubsystem(); if (status != AE_OK) { - dbgprintf("AcpiInitializeSubsystem failed (%s)\n", + printf("AcpiInitializeSubsystem failed (%s)\n", AcpiFormatException(status)); goto err; } status = AcpiInitializeTables (NULL, 16, FALSE); if (status != AE_OK) { - dbgprintf("AcpiInitializeTables failed (%s)\n", + printf("AcpiInitializeTables failed (%s)\n", AcpiFormatException(status)); goto err; } status = AcpiLoadTables(); if (status != AE_OK) { - dbgprintf("AcpiLoadTables failed (%s)\n", + printf("AcpiLoadTables failed (%s)\n", AcpiFormatException(status)); goto err; } -// u32_t mode = ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE; + // u32_t mode = ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE; status = AcpiEnableSubsystem(ACPI_NO_HANDLER_INIT | ACPI_NO_HARDWARE_INIT); if (status != AE_OK) { @@ -627,25 +618,17 @@ u32_t drvEntry(int action, char *cmdline) goto err; } - set_pic_mode(IO_APIC); - acpi_scan(); - acpi_init_pci(acpi_root); - print_pci_irqs(); - create_dm_list(); - print_dm_list(); write_device_dat("/RD/1/DRIVERS/DEVICES.DAT"); err: - return 0; - }; char* strdup(const char *str) @@ -699,7 +682,6 @@ count_dev_resources(ACPI_RESOURCE *acpi_res, void *data) return AE_OK; } - static void dm_add_acpi(struct acpi_device *device) { struct acpi_device *child; @@ -748,7 +730,6 @@ static void create_dm_list() { struct acpi_pci_root *root; - list_for_each_entry(root, &acpi_pci_roots, node) { struct pci_bus *pbus, *tbus; diff --git a/drivers/devman/pci/access.c b/drivers/devman/pci/access.c index 386370c2c8..9dd830f462 100644 --- a/drivers/devman/pci/access.c +++ b/drivers/devman/pci/access.c @@ -5,55 +5,6 @@ #include #include - -int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) -{ - *val = PciRead8(dev->busnr, dev->devfn, where); - return 0; -} - -int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) -{ - - if ( where & 1) - return PCIBIOS_BAD_REGISTER_NUMBER; - *val = PciRead16(dev->busnr, dev->devfn, where); - return 0; -} - -int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) -{ - - if ( where & 3) - return PCIBIOS_BAD_REGISTER_NUMBER; - *val = PciRead32(dev->busnr, dev->devfn, where); - return 0; -} - -int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) -{ - PciWrite8(dev->busnr, dev->devfn, where, val); - return 0; -}; - -int pci_write_config_word(struct pci_dev *dev, int where, u16 val) -{ - if ( where & 1) - return PCIBIOS_BAD_REGISTER_NUMBER; - PciWrite16(dev->busnr, dev->devfn, where, val); - return 0; -} - -int pci_write_config_dword(struct pci_dev *dev, int where, - u32 val) -{ - if ( where & 3) - return PCIBIOS_BAD_REGISTER_NUMBER; - PciWrite32(dev->busnr, dev->devfn, where, val); - return 0; -} - - int pci_bus_read_config_byte (struct pci_bus *bus, u32 devfn, int pos, u8 *value) { diff --git a/drivers/devman/pci/pci.c b/drivers/devman/pci/pci.c index ed843675ef..eafbedec79 100644 --- a/drivers/devman/pci/pci.c +++ b/drivers/devman/pci/pci.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include extern struct list_head pci_root_buses; diff --git a/drivers/devman/pci/probe.c b/drivers/devman/pci/probe.c index bd98c3e646..d49bdae109 100644 --- a/drivers/devman/pci/probe.c +++ b/drivers/devman/pci/probe.c @@ -18,22 +18,11 @@ LIST_HEAD(pci_root_buses); #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ #define CARDBUS_RESERVE_BUSNR 3 -static int pcibios_assign_all_busses(void) +int pcibios_assign_all_busses(void) { return 0; }; -/** - * pci_ari_enabled - query ARI forwarding status - * @bus: the PCI bus - * - * Returns 1 if ARI forwarding is enabled, or 0 if not enabled; - */ -static inline int pci_ari_enabled(struct pci_bus *bus) -{ - return bus->self && bus->self->ari_enabled; -} - /* * Translate the low bits of the PCI base * to the resource type @@ -632,7 +621,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); } - vsprintf(child->name, + sprintf(child->name, (is_cardbus ? "PCI CardBus %04x:%02x" : "PCI Bus %04x:%02x"), pci_domain_nr(bus), child->number); @@ -669,7 +658,7 @@ void set_pcie_port_type(struct pci_dev *pdev) pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); if (!pos) return; - pdev->is_pcie = 1; + //pdev->is_pcie = 1; pdev->pcie_cap = pos; pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16); pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4; @@ -1062,7 +1051,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) pci_scan_slot(bus, devfn); /* Reserve buses for SR-IOV capability. */ - max += pci_iov_bus_range(bus); + //max += pci_iov_bus_range(bus); /* * After performing arch-dependent fixup of the bus, look behind diff --git a/drivers/devman/scan.c b/drivers/devman/scan.c index dd1fd832f6..2f855379c9 100644 --- a/drivers/devman/scan.c +++ b/drivers/devman/scan.c @@ -784,4 +784,3 @@ int acpi_scan() return err; }; -