mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
Make OHCI+Core drivers really working, they are basically working now. Next thing to do is to make them working better (e.g. having a thread infinitely looping to serve irqs/other stuff isn't a good solution for multitasking OS) - add interrupt handler, spinlocks wrappers, waits etc.
svn path=/trunk/; revision=13660
This commit is contained in:
parent
bc1516fae9
commit
1053eac705
16 changed files with 499 additions and 72 deletions
|
@ -62,13 +62,16 @@
|
||||||
int STDCALL usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
|
int STDCALL usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
struct hc_driver *driver;
|
struct hc_driver *driver;
|
||||||
unsigned long resource, len;
|
PHYSICAL_ADDRESS resource;
|
||||||
|
unsigned long len;
|
||||||
void *base;
|
void *base;
|
||||||
struct usb_hcd *hcd;
|
struct usb_hcd *hcd;
|
||||||
int retval, region;
|
int retval, region;
|
||||||
char buf [8];
|
char buf [8];
|
||||||
//char *bufp = buf;
|
//char *bufp = buf;
|
||||||
|
|
||||||
|
printk("usbcore: usb_hcd_pci_probe() called\n");
|
||||||
|
|
||||||
if (usb_disabled())
|
if (usb_disabled())
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@ -103,7 +106,8 @@ clean_1:
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // UHCI
|
} else { // UHCI
|
||||||
resource = len = 0;
|
//resource = 0;
|
||||||
|
len = 0;
|
||||||
for (region = 0; region < PCI_ROM_RESOURCE; region++) {
|
for (region = 0; region < PCI_ROM_RESOURCE; region++) {
|
||||||
if (!(pci_resource_flags (dev, region) & IORESOURCE_IO))
|
if (!(pci_resource_flags (dev, region) & IORESOURCE_IO))
|
||||||
continue;
|
continue;
|
||||||
|
@ -118,7 +122,7 @@ clean_1:
|
||||||
dbg ("no i/o regions available");
|
dbg ("no i/o regions available");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
base = (void *) resource;
|
base = NULL; //(void *) resource; // this isn't possible
|
||||||
}
|
}
|
||||||
|
|
||||||
// driver->start(), later on, will transfer device from
|
// driver->start(), later on, will transfer device from
|
||||||
|
@ -165,7 +169,7 @@ clean_3:
|
||||||
if (request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, hcd->description, hcd)
|
if (request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, hcd->description, hcd)
|
||||||
!= 0) {
|
!= 0) {
|
||||||
dev_err (hcd->controller,
|
dev_err (hcd->controller,
|
||||||
"request interrupt %s failed\n", bufp);
|
"request interrupt %s failed\n", buf);
|
||||||
retval = -EBUSY;
|
retval = -EBUSY;
|
||||||
goto clean_3;
|
goto clean_3;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +177,7 @@ clean_3:
|
||||||
|
|
||||||
hcd->regs = base;
|
hcd->regs = base;
|
||||||
hcd->region = region;
|
hcd->region = region;
|
||||||
dev_info (hcd->controller, "irq %s, %s %p\n", bufp,
|
dev_info (hcd->controller, "irq %s, %s %p\n", buf,
|
||||||
(driver->flags & HCD_MEMORY) ? "pci mem" : "io base",
|
(driver->flags & HCD_MEMORY) ? "pci mem" : "io base",
|
||||||
base);
|
base);
|
||||||
|
|
||||||
|
|
|
@ -1148,7 +1148,12 @@ static int hub_thread(void *__hub)
|
||||||
do {
|
do {
|
||||||
|
|
||||||
hub_events();
|
hub_events();
|
||||||
wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
|
|
||||||
|
//FIXME: Correct this
|
||||||
|
//wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); // interruptable_sleep_on analog - below
|
||||||
|
/*while (!list_empty(&hub_event_list)) {
|
||||||
|
interruptible_sleep_on(&khubd_wait);
|
||||||
|
}*/
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE)
|
if (current->flags & PF_FREEZE)
|
||||||
refrigerator(PF_IOTHREAD);
|
refrigerator(PF_IOTHREAD);
|
||||||
|
|
|
@ -6,7 +6,7 @@ TARGET_NAME = usbcore
|
||||||
|
|
||||||
TARGET_DDKLIBS = ntoskrnl.a
|
TARGET_DDKLIBS = ntoskrnl.a
|
||||||
|
|
||||||
TARGET_CFLAGS = -Wall -I$(PATH_TO_TOP)/ntoskrnl/include
|
TARGET_CFLAGS = -Wall -I$(PATH_TO_TOP)/ntoskrnl/include -DDEBUG_MODE
|
||||||
|
|
||||||
TARGET_OBJECTS = \
|
TARGET_OBJECTS = \
|
||||||
message.o hcd.o hcd-pci.o hub.o usb.o config.o urb.o \
|
message.o hcd.o hcd-pci.o hub.o usb.o config.o urb.o \
|
||||||
|
|
|
@ -1042,7 +1042,7 @@ static void set_device_description (struct usb_device *dev)
|
||||||
"USB device %04x:%04x (%s)",
|
"USB device %04x:%04x (%s)",
|
||||||
vendor_id, product_id, mfgr_str);
|
vendor_id, product_id, mfgr_str);
|
||||||
}
|
}
|
||||||
//usbprintk("USB connected: %s\n",dev->dev.name);
|
usbprintk("USB connected: %s\n",dev->dev.name);
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,6 +1227,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
|
||||||
"usb-%s-%s interface %d",
|
"usb-%s-%s interface %d",
|
||||||
dev->bus->bus_name, dev->devpath,
|
dev->bus->bus_name, dev->devpath,
|
||||||
desc->bInterfaceNumber);
|
desc->bInterfaceNumber);
|
||||||
|
DPRINT1("usb_new_device: %s\n", interface->dev.name);
|
||||||
}
|
}
|
||||||
dev_dbg (&dev->dev, "%s - registering interface %s\n", __FUNCTION__, interface->dev.bus_id);
|
dev_dbg (&dev->dev, "%s - registering interface %s\n", __FUNCTION__, interface->dev.bus_id);
|
||||||
device_add (&interface->dev);
|
device_add (&interface->dev);
|
||||||
|
@ -1510,7 +1511,7 @@ int STDCALL usb_disabled(void)
|
||||||
/*
|
/*
|
||||||
* Init
|
* Init
|
||||||
*/
|
*/
|
||||||
static int __init usb_init(void)
|
int STDCALL __init usb_init(void)
|
||||||
{
|
{
|
||||||
if (nousb) {
|
if (nousb) {
|
||||||
info("USB support disabled\n");
|
info("USB support disabled\n");
|
||||||
|
@ -1530,7 +1531,7 @@ static int __init usb_init(void)
|
||||||
/*
|
/*
|
||||||
* Cleanup
|
* Cleanup
|
||||||
*/
|
*/
|
||||||
static void __exit usb_exit(void)
|
void STDCALL __exit usb_exit(void)
|
||||||
{
|
{
|
||||||
/* This will matter if shutdown/reboot does exitcalls. */
|
/* This will matter if shutdown/reboot does exitcalls. */
|
||||||
if (nousb)
|
if (nousb)
|
||||||
|
|
|
@ -4,13 +4,60 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
NTSTATUS AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
|
||||||
|
{
|
||||||
|
DbgPrint("usbcore: AddDevice called\n");
|
||||||
|
|
||||||
|
/* we need to do kind of this stuff here (as usual)
|
||||||
|
PDEVICE_OBJECT fdo;
|
||||||
|
IoCreateDevice(..., &fdo);
|
||||||
|
pdx->LowerDeviceObject =
|
||||||
|
IoAttachDeviceToDeviceStack(fdo, pdo);*/
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID DriverUnload(PDRIVER_OBJECT DriverObject)
|
||||||
|
{
|
||||||
|
// nothing to do here yet
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispatch PNP
|
||||||
|
NTSTATUS DispatchPnp(PDEVICE_OBJECT fdo, PIRP Irp)
|
||||||
|
{
|
||||||
|
ULONG fcn;
|
||||||
|
PIO_STACK_LOCATION stack;
|
||||||
|
|
||||||
|
stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
fcn = stack->MinorFunction;
|
||||||
|
DbgPrint("IRP_MJ_PNP, fcn=%d\n", fcn);
|
||||||
|
|
||||||
|
if (fcn == IRP_MN_REMOVE_DEVICE)
|
||||||
|
{
|
||||||
|
IoDeleteDevice(fdo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
|
||||||
|
{
|
||||||
|
DbgPrint("IRP_MJ_POWER dispatch\n");
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Standard DriverEntry method.
|
* Standard DriverEntry method.
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
DriverEntry(IN PVOID Context1, IN PVOID Context2)
|
DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegPath)
|
||||||
{
|
{
|
||||||
|
DriverObject->DriverUnload = DriverUnload;
|
||||||
|
DriverObject->DriverExtension->AddDevice = AddDevice;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_POWER] = DispatchPower;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
; Exports definition file for usbcore.sys
|
; Exports definition file for usbcore.sys
|
||||||
;
|
;
|
||||||
EXPORTS
|
EXPORTS
|
||||||
|
usb_init@0
|
||||||
|
usb_exit@0
|
||||||
usb_init_urb@4
|
usb_init_urb@4
|
||||||
usb_alloc_urb@8
|
usb_alloc_urb@8
|
||||||
usb_free_urb@4
|
usb_free_urb@4
|
||||||
|
|
|
@ -6,7 +6,7 @@ TARGET_NAME = ohci
|
||||||
|
|
||||||
TARGET_DDKLIBS = ntoskrnl.a usbcore.a
|
TARGET_DDKLIBS = ntoskrnl.a usbcore.a
|
||||||
|
|
||||||
TARGET_CFLAGS = -Wall -I$(PATH_TO_TOP)/ntoskrnl/include
|
TARGET_CFLAGS = -Wall -I$(PATH_TO_TOP)/ntoskrnl/include -DDEBUG_MODE
|
||||||
|
|
||||||
TARGET_OBJECTS = \
|
TARGET_OBJECTS = \
|
||||||
ohci-hcd.o ohci_main.o ../sys/ros_wrapper.o ../sys/linuxwrapper.o
|
ohci-hcd.o ohci_main.o ../sys/ros_wrapper.o ../sys/linuxwrapper.o
|
||||||
|
|
|
@ -471,7 +471,7 @@ static int hc_start (struct ohci_hcd *ohci)
|
||||||
|
|
||||||
/* a reset clears this */
|
/* a reset clears this */
|
||||||
writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
|
writel ((u32) ohci->hcca_dma, &ohci->regs->hcca);
|
||||||
// usbprintk("HCCA: %p \n",ohci->regs->hcca);
|
usbprintk("HCCA: %p \n",ohci->regs->hcca);
|
||||||
|
|
||||||
/* force default fmInterval (we won't adjust it); init thresholds
|
/* force default fmInterval (we won't adjust it); init thresholds
|
||||||
* for last FS and LS packets, reserve 90% for periodic.
|
* for last FS and LS packets, reserve 90% for periodic.
|
||||||
|
|
|
@ -38,6 +38,8 @@ ohci_pci_start (struct usb_hcd *hcd)
|
||||||
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
|
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
DPRINT("ohci_pci_start()\n");
|
||||||
|
|
||||||
if (hcd->pdev) {
|
if (hcd->pdev) {
|
||||||
ohci->hcca = pci_alloc_consistent (hcd->pdev,
|
ohci->hcca = pci_alloc_consistent (hcd->pdev,
|
||||||
sizeof *ohci->hcca, &ohci->hcca_dma);
|
sizeof *ohci->hcca, &ohci->hcca_dma);
|
||||||
|
@ -86,23 +88,27 @@ ohci_pci_start (struct usb_hcd *hcd)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
|
memset (ohci->hcca, 0, sizeof (struct ohci_hcca));
|
||||||
if ((ret = ohci_mem_init (ohci)) < 0) {
|
if ((ret = ohci_mem_init (ohci)) < 0) {
|
||||||
ohci_stop (hcd);
|
ohci_stop (hcd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ohci->regs = hcd->regs;
|
ohci->regs = hcd->regs;
|
||||||
|
|
||||||
|
DPRINT("Controller memory init done\n");
|
||||||
|
|
||||||
if (hc_reset (ohci) < 0) {
|
if (hc_reset (ohci) < 0) {
|
||||||
ohci_stop (hcd);
|
ohci_stop (hcd);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
DPRINT("Controller reset done\n");
|
||||||
|
|
||||||
if (hc_start (ohci) < 0) {
|
if (hc_start (ohci) < 0) {
|
||||||
ohci_err (ohci, "can't start\n");
|
ohci_err (ohci, "can't start\n");
|
||||||
ohci_stop (hcd);
|
ohci_stop (hcd);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
DPRINT("Controller start done\n");
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ohci_dump (ohci, 1);
|
ohci_dump (ohci, 1);
|
||||||
|
@ -352,7 +358,7 @@ static const struct hc_driver ohci_pci_hc_driver = {
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static const struct pci_device_id __devinitdata pci_ids [] = { {
|
const struct pci_device_id __devinitdata pci_ids [] = { {
|
||||||
|
|
||||||
/* handle any USB OHCI controller */
|
/* handle any USB OHCI controller */
|
||||||
.class = (PCI_CLASS_SERIAL_USB << 8) | 0x10,
|
.class = (PCI_CLASS_SERIAL_USB << 8) | 0x10,
|
||||||
|
@ -370,7 +376,7 @@ static const struct pci_device_id __devinitdata pci_ids [] = { {
|
||||||
MODULE_DEVICE_TABLE (pci, pci_ids);
|
MODULE_DEVICE_TABLE (pci, pci_ids);
|
||||||
|
|
||||||
/* pci driver glue; this is a "new style" PCI driver module */
|
/* pci driver glue; this is a "new style" PCI driver module */
|
||||||
static struct pci_driver ohci_pci_driver = {
|
struct pci_driver ohci_pci_driver = {
|
||||||
.name = (char *) hcd_name,
|
.name = (char *) hcd_name,
|
||||||
.id_table = pci_ids,
|
.id_table = pci_ids,
|
||||||
|
|
||||||
|
@ -384,22 +390,23 @@ static struct pci_driver ohci_pci_driver = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int __init ohci_hcd_pci_init (void)
|
int ohci_hcd_pci_init (void)
|
||||||
{
|
{
|
||||||
printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
|
printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
|
||||||
if (usb_disabled())
|
if (usb_disabled())
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
printk (KERN_DEBUG "%s: block sizes: ed %Zd td %Zd\n", hcd_name,
|
// causes page fault in reactos
|
||||||
sizeof (struct ed), sizeof (struct td));
|
//printk (KERN_DEBUG "%s: block sizes: ed %Zd td %Zd\n", hcd_name,
|
||||||
|
// sizeof (struct ed), sizeof (struct td));
|
||||||
return pci_module_init (&ohci_pci_driver);
|
return pci_module_init (&ohci_pci_driver);
|
||||||
}
|
}
|
||||||
module_init (ohci_hcd_pci_init);
|
/*module_init (ohci_hcd_pci_init);*/
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void __exit ohci_hcd_pci_cleanup (void)
|
void ohci_hcd_pci_cleanup (void)
|
||||||
{
|
{
|
||||||
pci_unregister_driver (&ohci_pci_driver);
|
pci_unregister_driver (&ohci_pci_driver);
|
||||||
}
|
}
|
||||||
module_exit (ohci_hcd_pci_cleanup);
|
/*module_exit (ohci_hcd_pci_cleanup);*/
|
||||||
|
|
|
@ -240,10 +240,22 @@ struct ohci_regs {
|
||||||
#define OHCI_CTRL_RWE (1 << 10) /* remote wakeup enable */
|
#define OHCI_CTRL_RWE (1 << 10) /* remote wakeup enable */
|
||||||
|
|
||||||
/* pre-shifted values for HCFS */
|
/* pre-shifted values for HCFS */
|
||||||
# define OHCI_USB_RESET (0 << 6)
|
#define OHCI_USB_RESET (0 << 6)
|
||||||
# define OHCI_USB_RESUME (1 << 6)
|
#define OHCI_USB_RESUME (1 << 6)
|
||||||
# define OHCI_USB_OPER (2 << 6)
|
#define OHCI_USB_OPER (2 << 6)
|
||||||
# define OHCI_USB_SUSPEND (3 << 6)
|
#define OHCI_USB_SUSPEND (3 << 6)
|
||||||
|
|
||||||
|
// HCFS itself
|
||||||
|
static char *hcfs2string (int state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case OHCI_USB_RESET: return "reset";
|
||||||
|
case OHCI_USB_RESUME: return "resume";
|
||||||
|
case OHCI_USB_OPER: return "operational";
|
||||||
|
case OHCI_USB_SUSPEND: return "suspend";
|
||||||
|
}
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HcCommandStatus (cmdstatus) register masks
|
* HcCommandStatus (cmdstatus) register masks
|
||||||
|
|
|
@ -1,26 +1,73 @@
|
||||||
/*
|
/*
|
||||||
ReactOS specific functions for ohci module
|
ReactOS specific functions for OHCI module
|
||||||
by Aleksey Bragin (aleksey@reactos.com)
|
by Aleksey Bragin (aleksey@reactos.com)
|
||||||
|
Some parts of code are inspired (or even just copied) from ReactOS Videoport driver
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
#include "../linux/linux_wrapper.h"
|
||||||
|
#include "ohci_main.h"
|
||||||
|
|
||||||
NTSTATUS AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
|
// declare basic init funcs
|
||||||
|
void init_wrapper(struct pci_dev *probe_dev);
|
||||||
|
int ohci_hcd_pci_init (void);
|
||||||
|
void ohci_hcd_pci_cleanup (void);
|
||||||
|
int STDCALL usb_init(void);
|
||||||
|
void STDCALL usb_exit(void);
|
||||||
|
extern struct pci_driver ohci_pci_driver;
|
||||||
|
extern const struct pci_device_id pci_ids[];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// This should be removed, but for testing purposes it's here
|
||||||
|
struct pci_dev *dev;
|
||||||
|
//struct pci_device_id *dev_id;
|
||||||
|
|
||||||
|
|
||||||
|
#define USB_OHCI_TAG TAG('u','s','b','o')
|
||||||
|
|
||||||
|
NTSTATUS STDCALL AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT fdo;
|
PDEVICE_OBJECT fdo;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
WCHAR DeviceBuffer[20];
|
WCHAR DeviceBuffer[20];
|
||||||
UNICODE_STRING DeviceName;
|
UNICODE_STRING DeviceName;
|
||||||
|
POHCI_DRIVER_EXTENSION DriverExtension;
|
||||||
|
POHCI_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
ULONG Size, DeviceNumber;
|
||||||
|
|
||||||
DbgPrint("ohci: AddDevice called\n");
|
DPRINT1("ohci: AddDevice called\n");
|
||||||
|
|
||||||
/* Create a unicode device name. */
|
// Allocate driver extension now
|
||||||
swprintf(DeviceBuffer, L"\\Device\\usbohci");
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
if (DriverExtension == NULL)
|
||||||
|
{
|
||||||
|
Status = IoAllocateDriverObjectExtension(
|
||||||
|
DriverObject,
|
||||||
|
DriverObject,
|
||||||
|
sizeof(OHCI_DRIVER_EXTENSION),
|
||||||
|
(PVOID *)&DriverExtension);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Allocating DriverObjectExtension failed.\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a unicode device name
|
||||||
|
DeviceNumber = 0; //TODO: Allocate new device number every time
|
||||||
|
swprintf(DeviceBuffer, L"\\Device\\USBFDO-%lu", DeviceNumber);
|
||||||
RtlInitUnicodeString(&DeviceName, DeviceBuffer);
|
RtlInitUnicodeString(&DeviceName, DeviceBuffer);
|
||||||
|
|
||||||
|
Status = IoCreateDevice(DriverObject,
|
||||||
Status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_VIDEO, 0, FALSE,&fdo);
|
sizeof(OHCI_DEVICE_EXTENSION)/* + DriverExtension->InitializationData.HwDeviceExtensionSize*/,
|
||||||
|
&DeviceName,
|
||||||
|
FILE_DEVICE_CONTROLLER,
|
||||||
|
0,
|
||||||
|
FALSE,
|
||||||
|
&fdo);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -28,33 +75,220 @@ NTSTATUS AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT pdo)
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// zerofill device extension
|
||||||
|
DeviceExtension = (POHCI_DEVICE_EXTENSION)pdo->DeviceExtension;
|
||||||
|
RtlZeroMemory(DeviceExtension, sizeof(OHCI_DEVICE_EXTENSION));
|
||||||
|
DeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack(fdo, pdo);
|
||||||
|
|
||||||
|
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
|
|
||||||
|
// Initialize device extension
|
||||||
|
DeviceExtension->DeviceNumber = DeviceNumber;
|
||||||
|
DeviceExtension->PhysicalDeviceObject = pdo;
|
||||||
|
DeviceExtension->FunctionalDeviceObject = fdo;
|
||||||
|
DeviceExtension->DriverExtension = DriverExtension;
|
||||||
|
|
||||||
|
/* Get bus number from the upper level bus driver. */
|
||||||
|
Size = sizeof(ULONG);
|
||||||
|
Status = IoGetDeviceProperty(
|
||||||
|
pdo,
|
||||||
|
DevicePropertyBusNumber,
|
||||||
|
Size,
|
||||||
|
&DeviceExtension->SystemIoBusNumber,
|
||||||
|
&Size);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("Couldn't get an information from bus driver. Panic!!!\n");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Done AddDevice\n");
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID DriverUnload(PDRIVER_OBJECT DriverObject)
|
VOID STDCALL DriverUnload(PDRIVER_OBJECT DriverObject)
|
||||||
{
|
{
|
||||||
// nothing to do here yet
|
DPRINT1("DriverUnload()\n");
|
||||||
|
|
||||||
|
// Exit usb device
|
||||||
|
usb_exit();
|
||||||
|
|
||||||
|
// Remove device (ohci_pci_driver.remove)
|
||||||
|
ohci_pci_driver.remove(dev);
|
||||||
|
|
||||||
|
ExFreePool(dev->slot_name);
|
||||||
|
ExFreePool(dev);
|
||||||
|
|
||||||
|
// Perform some cleanup
|
||||||
|
ohci_hcd_pci_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS InitLinuxWrapper(PDEVICE_OBJECT DeviceObject)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
POHCI_DEVICE_EXTENSION DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
// Fill generic linux structs
|
||||||
|
dev = ExAllocatePoolWithTag(PagedPool, sizeof(struct pci_dev), USB_OHCI_TAG);
|
||||||
|
|
||||||
|
init_wrapper(dev);
|
||||||
|
dev->irq = DeviceExtension->InterruptLevel;
|
||||||
|
dev->dev_ext = (PVOID)DeviceExtension;
|
||||||
|
dev->slot_name = ExAllocatePoolWithTag(NonPagedPool, 128, USB_OHCI_TAG); // 128 max len for slot name
|
||||||
|
|
||||||
|
strcpy(dev->dev.name, "OpenHCI PCI-USB Controller");
|
||||||
|
strcpy(dev->slot_name, "OHCD PCI Slot");
|
||||||
|
|
||||||
|
// Init the OHCI HCD. Probe will be called automatically, but will fail because id=NULL
|
||||||
|
Status = ohci_hcd_pci_init();
|
||||||
|
//FIXME: Check status returned value
|
||||||
|
|
||||||
|
// Init core usb
|
||||||
|
usb_init();
|
||||||
|
|
||||||
|
// Probe device with real id now
|
||||||
|
ohci_pci_driver.probe(dev, pci_ids);
|
||||||
|
|
||||||
|
DPRINT("InitLinuxWrapper() done\n");
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
OHCD_PnPStartDevice(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp)
|
||||||
|
{
|
||||||
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
POHCI_DRIVER_EXTENSION DriverExtension;
|
||||||
|
POHCI_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
PCM_RESOURCE_LIST AllocatedResources;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the initialization data we saved in VideoPortInitialize.
|
||||||
|
*/
|
||||||
|
DriverObject = DeviceObject->DriverObject;
|
||||||
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
DeviceExtension = (POHCI_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store some resources in the DeviceExtension.
|
||||||
|
*/
|
||||||
|
AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
|
||||||
|
if (AllocatedResources != NULL)
|
||||||
|
{
|
||||||
|
CM_FULL_RESOURCE_DESCRIPTOR *FullList;
|
||||||
|
CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor;
|
||||||
|
ULONG ResourceCount;
|
||||||
|
ULONG ResourceListSize;
|
||||||
|
|
||||||
|
/* Save the resource list */
|
||||||
|
ResourceCount = AllocatedResources->List[0].PartialResourceList.Count;
|
||||||
|
ResourceListSize =
|
||||||
|
FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.
|
||||||
|
PartialDescriptors[ResourceCount]);
|
||||||
|
DeviceExtension->AllocatedResources = ExAllocatePool(PagedPool, ResourceListSize);
|
||||||
|
if (DeviceExtension->AllocatedResources == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlCopyMemory(DeviceExtension->AllocatedResources,
|
||||||
|
AllocatedResources,
|
||||||
|
ResourceListSize);
|
||||||
|
|
||||||
|
/* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
|
||||||
|
for (FullList = AllocatedResources->List;
|
||||||
|
FullList < AllocatedResources->List + AllocatedResources->Count;
|
||||||
|
FullList++)
|
||||||
|
{
|
||||||
|
/* FIXME: Is this ASSERT ok for resources from the PNP manager? */
|
||||||
|
/*ASSERT(FullList->InterfaceType == PCIBus &&
|
||||||
|
FullList->BusNumber == DeviceExtension->SystemIoBusNumber &&
|
||||||
|
1 == FullList->PartialResourceList.Version &&
|
||||||
|
1 == FullList->PartialResourceList.Revision);*/
|
||||||
|
for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
|
||||||
|
Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
|
||||||
|
Descriptor++)
|
||||||
|
{
|
||||||
|
if (Descriptor->Type == CmResourceTypeInterrupt)
|
||||||
|
{
|
||||||
|
DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
|
||||||
|
DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
|
||||||
|
}
|
||||||
|
else if (Descriptor->Type == CmResourceTypeMemory)
|
||||||
|
{
|
||||||
|
DeviceExtension->BaseAddress = Descriptor->u.Memory.Start;
|
||||||
|
DeviceExtension->BaseAddrLength = Descriptor->u.Memory.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DPRINT1("Interrupt level: 0x%x Interrupt Vector: 0x%x\n",
|
||||||
|
DeviceExtension->InterruptLevel,
|
||||||
|
DeviceExtension->InterruptVector);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init wrapper with this object
|
||||||
|
*/
|
||||||
|
return InitLinuxWrapper(DeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch PNP
|
// Dispatch PNP
|
||||||
NTSTATUS DispatchPnp(PDEVICE_OBJECT fdo, PIRP Irp)
|
NTSTATUS STDCALL DispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
{
|
{
|
||||||
ULONG fcn;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
PIO_STACK_LOCATION stack;
|
NTSTATUS Status;
|
||||||
|
|
||||||
stack = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
fcn = stack->MinorFunction;
|
|
||||||
DbgPrint("IRP_MJ_PNP, fcn=%d\n", fcn);
|
|
||||||
|
|
||||||
if (fcn == IRP_MN_REMOVE_DEVICE)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
IoDeleteDevice(fdo);
|
case IRP_MN_START_DEVICE:
|
||||||
}
|
//Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
||||||
|
//if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
Status = OHCD_PnPStartDevice(DeviceObject, Irp);
|
||||||
|
Irp->IoStatus.Status = Status;
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case IRP_MN_REMOVE_DEVICE:
|
||||||
|
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||||
|
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||||
|
case IRP_MN_SURPRISE_REMOVAL:
|
||||||
|
|
||||||
|
case IRP_MN_STOP_DEVICE:
|
||||||
|
//Status = IntVideoPortForwardIrpAndWait(DeviceObject, Irp);
|
||||||
|
//if (NT_SUCCESS(Status) && NT_SUCCESS(Irp->IoStatus.Status))
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
Irp->IoStatus.Status = Status;
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
|
IoDeleteDevice(DeviceObject); // just delete device for now
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IRP_MN_QUERY_STOP_DEVICE:
|
||||||
|
case IRP_MN_CANCEL_STOP_DEVICE:
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
|
NTSTATUS STDCALL DispatchPower(PDEVICE_OBJECT fido, PIRP Irp)
|
||||||
{
|
{
|
||||||
DbgPrint("IRP_MJ_POWER dispatch\n");
|
DbgPrint("IRP_MJ_POWER dispatch\n");
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
46
reactos/drivers/usb/cromwell/host/ohci_main.h
Normal file
46
reactos/drivers/usb/cromwell/host/ohci_main.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* OHCI WDM/PNP driver
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 ReactOS Team
|
||||||
|
*
|
||||||
|
* Author: Aleksey Bragin (aleksey@reactos.com)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OHCI_MAIN_H
|
||||||
|
#define OHCI_MAIN_H
|
||||||
|
|
||||||
|
typedef struct _OHCI_DRIVER_EXTENSION
|
||||||
|
{
|
||||||
|
//OHCI_HW_INITIALIZATION_DATA InitializationData;
|
||||||
|
PVOID HwContext;
|
||||||
|
//UNICODE_STRING RegistryPath;
|
||||||
|
} OHCI_DRIVER_EXTENSION, *POHCI_DRIVER_EXTENSION;
|
||||||
|
|
||||||
|
typedef struct _OHCI_DEVICE_EXTENSTION
|
||||||
|
{
|
||||||
|
ULONG DeviceNumber;
|
||||||
|
PDEVICE_OBJECT PhysicalDeviceObject;
|
||||||
|
PDEVICE_OBJECT FunctionalDeviceObject;
|
||||||
|
PDEVICE_OBJECT NextDeviceObject;
|
||||||
|
//UNICODE_STRING RegistryPath;
|
||||||
|
PKINTERRUPT InterruptObject;
|
||||||
|
KSPIN_LOCK InterruptSpinLock;
|
||||||
|
PCM_RESOURCE_LIST AllocatedResources;
|
||||||
|
ULONG InterruptVector;
|
||||||
|
ULONG InterruptLevel;
|
||||||
|
PHYSICAL_ADDRESS BaseAddress;
|
||||||
|
ULONG BaseAddrLength;
|
||||||
|
ULONG AdapterInterfaceType;
|
||||||
|
ULONG SystemIoBusNumber;
|
||||||
|
ULONG SystemIoSlotNumber;
|
||||||
|
LIST_ENTRY AddressMappingListHead;
|
||||||
|
//KDPC DpcObject;
|
||||||
|
OHCI_DRIVER_EXTENSION *DriverExtension;
|
||||||
|
ULONG DeviceOpened;
|
||||||
|
//KMUTEX DeviceLock;
|
||||||
|
//CHAR MiniPortDeviceExtension[1];
|
||||||
|
} OHCI_DEVICE_EXTENSION, *POHCI_DEVICE_EXTENSION;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -205,6 +205,7 @@ struct pci_dev {
|
||||||
int base[4];
|
int base[4];
|
||||||
int flags[4];
|
int flags[4];
|
||||||
void * data;
|
void * data;
|
||||||
|
void * dev_ext; // link to Windows DeviceExtension
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pci_bus {
|
struct pci_bus {
|
||||||
|
@ -475,12 +476,19 @@ void my_wait_for_completion(struct completion*);
|
||||||
#define daemonize(a) do {} while(0)
|
#define daemonize(a) do {} while(0)
|
||||||
#define allow_signal(a) do {} while(0)
|
#define allow_signal(a) do {} while(0)
|
||||||
#define wait_event_interruptible(x,y) do {} while(0)
|
#define wait_event_interruptible(x,y) do {} while(0)
|
||||||
|
|
||||||
|
#define interruptible_sleep_on(a) my_interruptible_sleep_on(a)
|
||||||
|
void my_interruptible_sleep_on(int a);
|
||||||
|
|
||||||
#define flush_scheduled_work() do {} while(0)
|
#define flush_scheduled_work() do {} while(0)
|
||||||
#define refrigerator(x) do {} while(0)
|
#define refrigerator(x) do {} while(0)
|
||||||
#define signal_pending(x) 1 // fall through threads
|
#define signal_pending(x) 1 // fall through threads
|
||||||
#define complete_and_exit(a,b) return 0
|
#define complete_and_exit(a,b) return 0
|
||||||
|
|
||||||
#define kill_proc(a,b,c) 0
|
//#define kill_proc(a,b,c) 0
|
||||||
|
#define kill_proc(a,b,c) my_kill_proc(a, b, c);
|
||||||
|
int my_kill_proc(int pid, int signal, int unk);
|
||||||
|
|
||||||
#define yield() do {} while(0)
|
#define yield() do {} while(0)
|
||||||
#define cpu_relax() do {} while(0)
|
#define cpu_relax() do {} while(0)
|
||||||
|
|
||||||
|
@ -528,7 +536,7 @@ void my_wait_for_completion(struct completion*);
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
#define dev_printk(lvl,x,f,arg...) printk(f, ## arg)
|
#define dev_printk(lvl,x,f,arg...) printk(f, ## arg)
|
||||||
#define dev_dbg(x,f,arg...) do {} while (0) //printk(f, ## arg)
|
#define dev_dbg(x,f,arg...) printk(f, ## arg)
|
||||||
#define dev_info(x,f,arg...) printk(f,## arg)
|
#define dev_info(x,f,arg...) printk(f,## arg)
|
||||||
#define dev_warn(x,f,arg...) printk(f,## arg)
|
#define dev_warn(x,f,arg...) printk(f,## arg)
|
||||||
#define dev_err(x,f,arg...) printk(f,## arg)
|
#define dev_err(x,f,arg...) printk(f,## arg)
|
||||||
|
@ -681,7 +689,7 @@ static void __inline__ complete(struct completion *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define kernel_thread(a,b,c) my_kernel_thread(a,b,c)
|
#define kernel_thread(a,b,c) my_kernel_thread(a,b,c)
|
||||||
int my_kernel_thread(int (*handler)(void*), void* parm, int flags);
|
int my_kernel_thread(int STDCALL (*handler)(void*), void* parm, int flags);
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* PCI, simple and inlined... */
|
/* PCI, simple and inlined... */
|
||||||
|
@ -714,7 +722,7 @@ struct my_irqs {
|
||||||
|
|
||||||
void handle_irqs(int irq);
|
void handle_irqs(int irq);
|
||||||
void inc_jiffies(int);
|
void inc_jiffies(int);
|
||||||
void init_wrapper(void);
|
void init_wrapper(struct pci_dev *pci_dev);
|
||||||
void do_all_timers(void);
|
void do_all_timers(void);
|
||||||
|
|
||||||
#define __KERNEL_DS 0x18
|
#define __KERNEL_DS 0x18
|
||||||
|
|
|
@ -1,29 +1,45 @@
|
||||||
// PCI -> HAL interface
|
// PCI -> HAL interface
|
||||||
// this file is part of linux_wrapper.h
|
// this file is part of linux_wrapper.h
|
||||||
|
|
||||||
|
//FIXME: Move this file, make its definitions more general
|
||||||
|
#include "../host/ohci_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initialize device before it's used by a driver. Ask low-level code to enable I/O and memory.
|
Initialize device before it's used by a driver. Ask low-level code to enable I/O and memory.
|
||||||
Wake up the device if it was suspended. Beware, this function can fail.
|
Wake up the device if it was suspended. Beware, this function can fail.
|
||||||
*/
|
*/
|
||||||
static int __inline__ pci_enable_device(struct pci_dev *dev)
|
static int __inline__ pci_enable_device(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
|
DPRINT1("pci_enable_device() called...\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get physical address where resource x resides
|
// Get physical address where resource x resides
|
||||||
static unsigned long __inline__ pci_resource_start (struct pci_dev *dev, int x)
|
static PHYSICAL_ADDRESS __inline__ pci_resource_start (struct pci_dev *dev, int x)
|
||||||
{
|
{
|
||||||
// HalGetBusData...
|
POHCI_DEVICE_EXTENSION dev_ext = (POHCI_DEVICE_EXTENSION)dev->dev_ext;
|
||||||
// HalAssignSlotResources ?
|
DPRINT1("pci_resource_start() called, x=0x%x\n", x);
|
||||||
return dev->base[x];
|
|
||||||
|
//FIXME: Take x into account
|
||||||
|
return dev_ext->BaseAddress;
|
||||||
|
//return dev->base[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ???
|
// ???
|
||||||
static unsigned long __inline__ pci_resource_len (struct pci_dev *dev, int x){return 0;}
|
static unsigned long __inline__ pci_resource_len (struct pci_dev *dev, int x)
|
||||||
|
{
|
||||||
|
POHCI_DEVICE_EXTENSION ext = (POHCI_DEVICE_EXTENSION)dev->dev_ext;
|
||||||
|
|
||||||
|
DPRINT1("pci_resource_len() called, x=0x%x\n", x);
|
||||||
|
|
||||||
|
//FIXME: Take x into account
|
||||||
|
return ext->BaseAddrLength;
|
||||||
|
}
|
||||||
|
|
||||||
// ???
|
// ???
|
||||||
static int __inline__ pci_resource_flags(struct pci_dev *dev, int x)
|
static int __inline__ pci_resource_flags(struct pci_dev *dev, int x)
|
||||||
{
|
{
|
||||||
|
DPRINT1("pci_resource_flags() called, x=0x%x\n");
|
||||||
return dev->flags[x];
|
return dev->flags[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +51,7 @@ static int __inline__ pci_set_master(struct pci_dev *dev) {return 0;}
|
||||||
// Store pointer to data for this device
|
// Store pointer to data for this device
|
||||||
static int __inline__ pci_set_drvdata(struct pci_dev *dev, void* d)
|
static int __inline__ pci_set_drvdata(struct pci_dev *dev, void* d)
|
||||||
{
|
{
|
||||||
|
DPRINT1("pci_set_drvdata() called...\n");
|
||||||
dev->data=(void*)d;
|
dev->data=(void*)d;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +59,7 @@ static int __inline__ pci_set_drvdata(struct pci_dev *dev, void* d)
|
||||||
// Get pointer to previously saved data
|
// Get pointer to previously saved data
|
||||||
static void __inline__ *pci_get_drvdata(struct pci_dev *dev)
|
static void __inline__ *pci_get_drvdata(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
|
DPRINT1("pci_get_drvdata() called...\n");
|
||||||
return dev->data;
|
return dev->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,16 +77,25 @@ start begin of region
|
||||||
n length of region
|
n length of region
|
||||||
name name of requester
|
name name of requester
|
||||||
*/
|
*/
|
||||||
static int __inline__ request_region(unsigned long addr, unsigned long len, const char * d){return 0;}
|
static int __inline__ request_region(PHYSICAL_ADDRESS addr, unsigned long len, const char * d)
|
||||||
|
{
|
||||||
|
DPRINT1("request_region(): addr=0x%x, len=0x%x\n", addr, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Unmap I/O memory from kernel address space.
|
Unmap I/O memory from kernel address space.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
addr virtual start address
|
addr virtual start address
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static int __inline__ iounmap(void* p)
|
static int __inline__ iounmap(void* p)
|
||||||
{
|
{
|
||||||
|
DPRINT1("iounmap(): p=0x%x. FIXME - how to obtain len of mapped region?\n", p);
|
||||||
|
|
||||||
|
//MmUnnapIoSpace(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +106,11 @@ Parameters:
|
||||||
start begin of region
|
start begin of region
|
||||||
n length of region
|
n length of region
|
||||||
*/
|
*/
|
||||||
static int __inline__ release_region(unsigned long addr, unsigned long len){return 0;}
|
static int __inline__ release_region(PHYSICAL_ADDRESS addr, unsigned long len)
|
||||||
|
{
|
||||||
|
DPRINT1("release_region(): addr=0x%x, len=0x%x\n", addr, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allocate I/O memory region.
|
Allocate I/O memory region.
|
||||||
|
@ -89,8 +120,9 @@ start begin of region
|
||||||
n length of region
|
n length of region
|
||||||
name name of requester
|
name name of requester
|
||||||
*/
|
*/
|
||||||
static int __inline__ request_mem_region(unsigned long addr, unsigned long len, const char * d)
|
static int __inline__ request_mem_region(PHYSICAL_ADDRESS addr, unsigned long len, const char * d)
|
||||||
{
|
{
|
||||||
|
DPRINT1("request_mem_region(): addr=0x%x, len=0x%x\n", addr, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,10 +136,12 @@ size size of physical address range
|
||||||
Returns:
|
Returns:
|
||||||
virtual start address of mapped range
|
virtual start address of mapped range
|
||||||
*/
|
*/
|
||||||
static void __inline__ *ioremap_nocache(unsigned long addr, unsigned long len)
|
static void __inline__ *ioremap_nocache(PHYSICAL_ADDRESS addr, unsigned long len)
|
||||||
{
|
{
|
||||||
// MmMapIoSpace ?
|
// MmMapIoSpace with NoCache param
|
||||||
return (void*)addr;
|
DPRINT1("ioremap_nocache(): addr=0x%x, len=0x%x\n", addr, len);
|
||||||
|
|
||||||
|
return MmMapIoSpace(addr, len, MmNonCached);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -117,7 +151,8 @@ Parameters:
|
||||||
start begin of region
|
start begin of region
|
||||||
n length of region
|
n length of region
|
||||||
*/
|
*/
|
||||||
static int __inline__ release_mem_region(unsigned long addr, unsigned long len)
|
static int __inline__ release_mem_region(PHYSICAL_ADDRESS addr, unsigned long len)
|
||||||
{
|
{
|
||||||
|
DPRINT1("release_mem_region(): addr=0x%x, len=0x%x\n", addr, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ static int drvs_num;
|
||||||
* Helper functions for top-level system
|
* Helper functions for top-level system
|
||||||
*/
|
*/
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
void init_wrapper(void)
|
void init_wrapper(struct pci_dev *probe_dev)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
for(n=0;n<MAX_TIMERS;n++)
|
for(n=0;n<MAX_TIMERS;n++)
|
||||||
|
@ -58,7 +58,7 @@ void init_wrapper(void)
|
||||||
my_jiffies=0;
|
my_jiffies=0;
|
||||||
num_irqs=0;
|
num_irqs=0;
|
||||||
my_current=&act_cur;
|
my_current=&act_cur;
|
||||||
pci_probe_dev=NULL;
|
pci_probe_dev=probe_dev;
|
||||||
|
|
||||||
for(n=0;n<MAX_IRQS;n++)
|
for(n=0;n<MAX_IRQS;n++)
|
||||||
{
|
{
|
||||||
|
@ -108,12 +108,38 @@ void do_all_timers(void)
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
// Purpose: Remember thread procedure and data in global var
|
// Purpose: Remember thread procedure and data in global var
|
||||||
int my_kernel_thread(int (*handler)(void*), void* parm, int flags)
|
// ReactOS Purpose: Create real kernel thread
|
||||||
|
int my_kernel_thread(int STDCALL (*handler)(void*), void* parm, int flags)
|
||||||
{
|
{
|
||||||
thread_handler=handler;
|
HANDLE hThread;
|
||||||
thread_parm=parm;
|
//thread_handler=handler;
|
||||||
return 42; // PID :-)
|
//thread_parm=parm;
|
||||||
|
//return 42; // PID :-)
|
||||||
|
|
||||||
|
ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
|
||||||
|
|
||||||
|
PsCreateSystemThread(&hThread,
|
||||||
|
THREAD_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(PKSTART_ROUTINE)handler,
|
||||||
|
parm);
|
||||||
|
|
||||||
|
return (int)hThread; // FIXME: Correct?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kill the process
|
||||||
|
int my_kill_proc(int pid, int signal, int unk)
|
||||||
|
{
|
||||||
|
HANDLE hThread;
|
||||||
|
|
||||||
|
hThread = (HANDLE)pid;
|
||||||
|
ZwClose(hThread);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Device management
|
/* Device management
|
||||||
* As simple as possible, but as complete as necessary ...
|
* As simple as possible, but as complete as necessary ...
|
||||||
|
|
Loading…
Reference in a new issue