X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FUSB%2FEHCI%2Fehci.c;h=c970eb49208b56ffc0dadd0a62a6aa19dc383cfc;hb=bc164a02c6f5f9fdcc66bd66d2d6a02dcfff8bec;hp=2dd86108f9e5b354e4d0f7e9bda6c98c66264d50;hpb=590ae24e57553f79a92d6ef52c0468c07aa5de22;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/USB/EHCI/ehci.c b/KernelLand/Modules/USB/EHCI/ehci.c index 2dd86108..c970eb49 100644 --- a/KernelLand/Modules/USB/EHCI/ehci.c +++ b/KernelLand/Modules/USB/EHCI/ehci.c @@ -79,11 +79,16 @@ int EHCI_Initialise(char **Arguments) { Uint32 addr = PCI_GetBAR(id, 0); if( addr == 0 ) { - // Oops, PCI BIOS emulation time + // TODO: PCI BIOS emulation time } + if( addr & 1 ) { + // TODO: Error + continue ; + } + addr &= ~0xF; Uint8 irq = PCI_GetIRQ(id); if( irq == 0 ) { - // TODO: The same + // TODO: Error? } Log_Log("ECHI", "Controller at PCI %i 0x%x IRQ 0x%x", @@ -94,9 +99,32 @@ int EHCI_Initialise(char **Arguments) // TODO: Detect other forms of failure than "out of slots" break ; } + } - // TODO: Register with the USB stack + for( int i = 0; Arguments && Arguments[i]; i ++ ) + { + char *pos = Arguments[i], *next; + LOG("pos = '%s'", pos); + tPAddr base = strtoull(pos, &next, 16); + if( base == 0 ) + continue; + pos = next; + LOG("pos = '%s'", pos); + if( *pos++ != '-' ) + continue; + LOG("pos = '%s'", pos); + int irq = strtol(pos, &next, 16); + if( irq == 0 ) + continue ; + if( *next != 0 ) + continue; + LOG("base=%x, irq=%i", base, irq); + if( EHCI_InitController(base, irq) ) + { + continue ; + } } + return 0; } @@ -130,14 +158,21 @@ int EHCI_InitController(tPAddr BaseAddress, Uint8 InterruptNum) cont->TDPool = NULL; // -- Build up structure -- - cont->CapRegs = (void*)MM_MapHWPages(BaseAddress, 1); + cont->CapRegs = (void*)( MM_MapHWPages(BaseAddress, 1) + (BaseAddress % PAGE_SIZE) ); if( !cont->CapRegs ) { Log_Warning("EHCI", "Can't map 1 page at %P into kernel space", BaseAddress); goto _error; } // TODO: Error check if( (cont->CapRegs->CapLength & 3) ) { - Log_Warning("EHCI", "Controller at %P non-aligned op regs", BaseAddress); + Log_Warning("EHCI", "Controller at %P non-aligned op regs (%x)", + BaseAddress, cont->CapRegs->CapLength); + goto _error; + } + if( BaseAddress % PAGE_SIZE + cont->CapRegs->CapLength + sizeof(tEHCI_CapRegs) > PAGE_SIZE ) { + Log_Warning("EHCI", "%P: Cap regs over page boundary (+0x%x bytes)", + BaseAddress % PAGE_SIZE + cont->CapRegs->CapLength + sizeof(tEHCI_CapRegs) + ); goto _error; } cont->OpRegs = (void*)( (Uint32*)cont->CapRegs + cont->CapRegs->CapLength / 4 );