git-svn-id: svn://kolibrios.org@2187 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-09-14 21:43:11 +00:00
parent 59fc4ab346
commit baa5810af4
5 changed files with 245 additions and 44 deletions

View File

@ -1,9 +1,11 @@
CC = gcc CC = gcc
FASM = e:/fasm/fasm.exe FASM = e:/fasm/fasm.exe
CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf
DRV_DIR = $(CURDIR)/.. DRV_DIR = $(CURDIR)/..
DRV_INCLUDES = $(DRV_DIR)/include DRV_INCLUDES = $(DRV_DIR)/include

View File

@ -90,6 +90,8 @@ static void create_dm_list();
static void print_dm_list(); static void print_dm_list();
int write_device_dat(char *path);
static void set_pic_mode(enum pic_mode mode) static void set_pic_mode(enum pic_mode mode)
{ {
@ -113,10 +115,6 @@ static void set_pic_mode(enum pic_mode mode)
static bool pci_use_crs = false; static bool pci_use_crs = false;
#define IORESOURCE_BUS 0x00001000 #define IORESOURCE_BUS 0x00001000
@ -263,7 +261,6 @@ static ACPI_STATUS setup_resource(ACPI_RESOURCE *acpi_res, void *data)
struct acpi_resource_address64 addr; struct acpi_resource_address64 addr;
ACPI_STATUS status; ACPI_STATUS status;
unsigned long flags; unsigned long flags;
struct resource *root, *conflict;
u64 start, end; u64 start, end;
status = resource_to_addr(acpi_res, &addr); status = resource_to_addr(acpi_res, &addr);
@ -272,14 +269,12 @@ static ACPI_STATUS setup_resource(ACPI_RESOURCE *acpi_res, void *data)
if (addr.ResourceType == ACPI_MEMORY_RANGE) if (addr.ResourceType == ACPI_MEMORY_RANGE)
{ {
root = &iomem_resource;
flags = IORESOURCE_MEM; flags = IORESOURCE_MEM;
if (addr.Info.Mem.Caching == ACPI_PREFETCHABLE_MEMORY) if (addr.Info.Mem.Caching == ACPI_PREFETCHABLE_MEMORY)
flags |= IORESOURCE_PREFETCH; flags |= IORESOURCE_PREFETCH;
} }
else if (addr.ResourceType == ACPI_IO_RANGE) else if (addr.ResourceType == ACPI_IO_RANGE)
{ {
root = &ioport_resource;
flags = IORESOURCE_IO; flags = IORESOURCE_IO;
} else } else
return AE_OK; return AE_OK;
@ -299,27 +294,17 @@ static ACPI_STATUS setup_resource(ACPI_RESOURCE *acpi_res, void *data)
return AE_OK; return AE_OK;
} }
#if 0 info->res_num++;
conflict = insert_resource_conflict(root, res); if (addr.TranslationOffset)
if (conflict) { dev_info(NULL, "host bridge window %pR "
dev_err(&info->bridge->dev, "(PCI address [%#llx-%#llx])\n",
"address space collision: host bridge window %pR " res, res->start - addr.TranslationOffset,
"conflicts with %s %pR\n", res->end - addr.TranslationOffset);
res, conflict->name, conflict); else
} else { dev_info(NULL,
pci_bus_add_resource(info->bus, res, 0); "host bridge window %pR\n", res);
info->res_num++;
if (addr.translation_offset)
dev_info(&info->bridge->dev, "host bridge window %pR "
"(PCI address [%#llx-%#llx])\n",
res, res->start - addr.translation_offset,
res->end - addr.translation_offset);
else
dev_info(&info->bridge->dev,
"host bridge window %pR\n", res);
}
return AE_OK; return AE_OK;
#endif
} }
@ -368,8 +353,6 @@ res_alloc_fail:
} }
struct pci_ops pci_root_ops = { struct pci_ops pci_root_ops = {
.read = NULL, .read = NULL,
.write = NULL, .write = NULL,
@ -383,7 +366,7 @@ struct pci_bus* pci_acpi_scan_root(struct acpi_pci_root *root)
int busnum = root->secondary.start; int busnum = root->secondary.start;
struct pci_bus *bus; struct pci_bus *bus;
struct pci_sysdata *sd; struct pci_sysdata *sd;
int node = 0; int node = 0;
if (domain ) { if (domain ) {
printk(KERN_WARNING "pci_bus %04x:%02x: " printk(KERN_WARNING "pci_bus %04x:%02x: "
@ -392,6 +375,7 @@ struct pci_bus* pci_acpi_scan_root(struct acpi_pci_root *root)
return NULL; return NULL;
} }
node = -1;
/* Allocate per-root-bus (not per bus) arch-specific data. /* Allocate per-root-bus (not per bus) arch-specific data.
* TODO: leak; this memory is never freed. * TODO: leak; this memory is never freed.
* It's arguable whether it's worth the trouble to care. * It's arguable whether it's worth the trouble to care.
@ -632,14 +616,14 @@ u32_t drvEntry(int action, char *cmdline)
// u32_t mode = ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE; // u32_t mode = ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE;
status = AcpiEnableSubsystem(0); status = AcpiEnableSubsystem(ACPI_NO_HANDLER_INIT | ACPI_NO_HARDWARE_INIT);
if (status != AE_OK) { if (status != AE_OK) {
dbgprintf("AcpiEnableSubsystem failed (%s)\n", dbgprintf("AcpiEnableSubsystem failed (%s)\n",
AcpiFormatException(status)); AcpiFormatException(status));
goto err; goto err;
} }
status = AcpiInitializeObjects (0); status = AcpiInitializeObjects (ACPI_FULL_INITIALIZATION);
if (ACPI_FAILURE (status)) if (ACPI_FAILURE (status))
{ {
dbgprintf("AcpiInitializeObjects failed (%s)\n", dbgprintf("AcpiInitializeObjects failed (%s)\n",
@ -660,6 +644,8 @@ u32_t drvEntry(int action, char *cmdline)
print_dm_list(); print_dm_list();
write_device_dat("/RD/1/DRIVERS/DEVICES.DAT");
err: err:
return 0; return 0;
@ -921,3 +907,137 @@ static void print_dm_list()
}; };
typedef struct
{
uint32_t busaddr;
uint32_t devid;
uint32_t irq;
uint32_t unused;
}devinfo_t;
#pragma pack(push, 1)
typedef struct
{
char sec;
char min;
char hour;
char rsv;
}detime_t;
typedef struct
{
char day;
char month;
short year;
}dedate_t;
typedef struct
{
unsigned attr;
unsigned flags;
union
{
detime_t ctime;
unsigned cr_time;
};
union
{
dedate_t cdate;
unsigned cr_date;
};
union
{
detime_t atime;
unsigned acc_time;
};
union
{
dedate_t adate;
unsigned acc_date;
};
union
{
detime_t mtime;
unsigned mod_time;
};
union
{
dedate_t mdate;
unsigned mod_date;
};
unsigned size;
unsigned size_high;
} FILEINFO;
#pragma pack(pop)
int write_device_dat(char *path)
{
struct pci_dev *pcidev;
dmdev_t *dmdev;
devinfo_t *data;
int writes;
int len;
int i = 0;
list_for_each_entry(dmdev, &dmdev_tree, list)
{
if(dmdev->type ==1)
{
if(dmdev->pci_dev != NULL)
{
pcidev = dmdev->pci_dev;
if(pcidev->pin)
i++;
};
};
};
len = sizeof(devinfo_t)*i + 4;
data = (devinfo_t*)malloc(len);
i = 0;
list_for_each_entry(dmdev, &dmdev_tree, list)
{
if(dmdev->type == 1)
{
if(dmdev->pci_dev != NULL)
{
pcidev = dmdev->pci_dev;
if(pcidev->pin && (acpi_get_irq(pcidev) != -1) )
{
data[i].busaddr = (pcidev->busnr<<8)|pcidev->devfn;
data[i].devid = ((uint32_t)pcidev->device<<16) |
pcidev->vendor;
data[i].irq = acpi_get_irq(pcidev);
data[i].unused = 0;
i++;
}
};
};
};
data[i].busaddr = -1;
FILEINFO info;
int offset = 0;
if(get_fileinfo(path,&info))
{
if( create_file(path))
{
free(data);
return false;
}
}
else
set_file_size(path, 0);
write_file(path, data, 0, len, &writes);
return true;
};

View File

@ -702,7 +702,7 @@ AcpiOsInstallInterruptHandler (
ACPI_OSD_HANDLER ServiceRoutine, ACPI_OSD_HANDLER ServiceRoutine,
void *Context) void *Context)
{ {
dbgprintf("%s irq %d\n", InterruptNumber );
return (AE_OK); return (AE_OK);
} }
@ -995,6 +995,8 @@ AcpiOsReadPort (
return (AE_BAD_PARAMETER); return (AE_BAD_PARAMETER);
} }
dbgprintf("%s %x, %x\n",__FUNCTION__, Address, *Value);
return (AE_OK); return (AE_OK);
} }
@ -1037,6 +1039,8 @@ AcpiOsWritePort (
return (AE_ERROR); return (AE_ERROR);
} }
dbgprintf("%s %x, %x\n",__FUNCTION__, Address, Value);
return (AE_OK); return (AE_OK);
}; };
@ -1060,23 +1064,59 @@ AcpiOsReadMemory (
UINT32 *Value, UINT32 *Value,
UINT32 Width) UINT32 Width)
{ {
void *memptr;
ACPI_STATUS status = AE_ERROR;
if( Address > 0x400000) dbgprintf("%s %x\n",__FUNCTION__, Address);
return (AE_BAD_PARAMETER);
if( Address >= 0x400000)
{
memptr = AcpiOsMapMemory(Address, Width);
if(memptr)
{
status = AE_OK;
switch (Width)
{
case 8:
*Value = *(UINT8*)Address;
break;
case 16:
*Value = *(UINT16*)Address;
break;
case 32:
*Value = *(UINT32*)Address;
break;
default:
status = (AE_BAD_PARAMETER);
}
FreeKernelSpace(memptr);
}
return status;
}
else else
Address+= 0x80000000; Address+= 0x80000000;
switch (Width) switch (Width)
{ {
case 8: case 8:
case 16: *Value = *(UINT8*)Address;
case 32: break;
*Value = *(UINT32*)Address;
break;
default: case 16:
return (AE_BAD_PARAMETER); *Value = *(UINT16*)Address;
break;
case 32:
*Value = *(UINT32*)Address;
break;
default:
return (AE_BAD_PARAMETER);
} }
return (AE_OK); return (AE_OK);
} }
@ -1103,16 +1143,53 @@ AcpiOsWriteMemory (
UINT32 Width) UINT32 Width)
{ {
if( Address > 0x400000) void *memptr;
return (AE_BAD_PARAMETER); ACPI_STATUS status = AE_ERROR;
dbgprintf("%s %x, %x\n",__FUNCTION__, Address, Value);
if( Address >= 0x400000)
{
memptr = AcpiOsMapMemory(Address, Width);
if(memptr)
{
status = AE_OK;
switch (Width)
{
case 8:
*(UINT8*)Address = (UINT8)Value;
break;
case 16:
*(UINT16*)Address = (UINT16)Value;
break;
case 32:
*(UINT32*)Address = Value;
break;
default:
status = (AE_BAD_PARAMETER);
}
FreeKernelSpace(memptr);
}
return status;
}
else else
Address+= 0x80000000; Address+= 0x80000000;
switch (Width) switch (Width)
{ {
case 8: case 8:
*(UINT8*)Address = (UINT8)Value;
break;
case 16: case 16:
*(UINT16*)Address = (UINT16)Value;
break;
case 32: case 32:
*(UINT32*)Address = Value; *(UINT32*)Address = Value;
break; break;

View File

@ -5,6 +5,7 @@
#include <pci.h> #include <pci.h>
#include <syscall.h> #include <syscall.h>
extern struct list_head pci_root_buses;
#define IO_SPACE_LIMIT 0xffff #define IO_SPACE_LIMIT 0xffff
#define PCIBIOS_SUCCESSFUL 0x00 #define PCIBIOS_SUCCESSFUL 0x00

View File

@ -3,6 +3,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <mutex.h> #include <mutex.h>
#include <pci.h> #include <pci.h>
#include <list.h>
#include <syscall.h> #include <syscall.h>
LIST_HEAD(pci_root_buses); LIST_HEAD(pci_root_buses);