Devman (acpi.sys):

- Fixed errors breaking build; 
- Added to auto build;

git-svn-id: svn://kolibrios.org@9499 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-12-27 18:22:14 +00:00
parent c1d40e004d
commit 8848af8de1
8 changed files with 59 additions and 132 deletions

View File

@ -1,56 +1,42 @@
CC = kos32-gcc
LD = kos32-ld
KPACK = kpack
CC = gcc
FASM = e:/fasm/fasm.exe
CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf
CFLAGS = -c -w -O2 -fomit-frame-pointer -fno-builtin-printf
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
DRV_INCLUDES = $(DRV_DIR)/include
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
ACPI_INCLUDES = ./acpica/include
INCLUDES = -I$(DRV_INCLUDES) -I$(ACPI_INCLUDES) -I$(DRV_DIR)/include/linux
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
LDFLAGS = -nostdlib -shared -s -Map acpi.map --image-base 0 --file-alignment 512 --section-alignment 4096
LIBPATH := -L$(DRV_DIR)/ddk -L../devman/acpica -L../../contrib/sdk/lib
LIBS := -lacpica -lgcc -lddk -lcore
NAME= acpi
NAME = acpi.sys
NAME_SRCS = acpi.c \
scan.c \
pci_irq.c \
pci_root.c \
pci/access.c \
pci/pci.c \
pci_bind.c \
pci_irq.c \
pci/probe.c \
pci_bind.c
pci/pci.c \
pci/access.c
all: $(NAME).dll
all: $(NAME)
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

21
drivers/devman/Tupfile.lua Executable file
View File

@ -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")

View File

@ -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:

View File

@ -571,41 +571,32 @@ 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;
}
@ -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;

View File

@ -5,55 +5,6 @@
#include <pci.h>
#include <syscall.h>
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)
{

View File

@ -2,7 +2,7 @@
#include <ddk.h>
#include <linux/errno.h>
#include <mutex.h>
#include <pci.h>
#include <linux/pci.h>
#include <syscall.h>
extern struct list_head pci_root_buses;

View File

@ -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, &reg16);
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

View File

@ -784,4 +784,3 @@ int acpi_scan()
return err;
};