diff --git a/BaS_gcc/sys/exceptions.S b/BaS_gcc/sys/exceptions.S index ede0336..d0db477 100644 --- a/BaS_gcc/sys/exceptions.S +++ b/BaS_gcc/sys/exceptions.S @@ -94,90 +94,90 @@ .equ INT_SOURCE_USB_DSPI_TCF,29 // transfer complete interrupt .equ INT_SOURCE_USB_DSPI_TFFF,30 // transfer FIFO fill interrupt .equ INT_SOURCE_USB_DSPI_EOQF,31 // end of queue interrupt - .equ INT_SOURCE_PSC3,32 // PSC3 interrupt - .equ INT_SOURCE_PSC2,33 // PSC2 interrupt - .equ INT_SOURCE_PSC1,34 // PSC1 interrupt - .equ INT_SOURCE_PSC0,35 // PSC0 interrupt + .equ INT_SOURCE_PSC3,32 // PSC3 interrupt + .equ INT_SOURCE_PSC2,33 // PSC2 interrupt + .equ INT_SOURCE_PSC1,34 // PSC1 interrupt + .equ INT_SOURCE_PSC0,35 // PSC0 interrupt .equ INT_SOURCE_CTIMERS,36 // combined source for comm timers - .equ INT_SOURCE_SEC,37 // SEC interrupt - .equ INT_SOURCE_FEC1,38 // FEC1 interrupt - .equ INT_SOURCE_FEC0,39 // FEC0 interrupt - .equ INT_SOURCE_I2C,40 // I2C interrupt + .equ INT_SOURCE_SEC,37 // SEC interrupt + .equ INT_SOURCE_FEC1,38 // FEC1 interrupt + .equ INT_SOURCE_FEC0,39 // FEC0 interrupt + .equ INT_SOURCE_I2C,40 // I2C interrupt .equ INT_SOURCE_PCIARB,41 // PCI arbiter interrupt - .equ INT_SOURCE_CBPCI,42 // COMM bus PCI interrupt + .equ INT_SOURCE_CBPCI,42 // COMM bus PCI interrupt .equ INT_SOURCE_XLBPCI,43 // XLB PCI interrupt .equ INT_SOURCE_XLBARB,47 // XLBARB to PCI interrupt - .equ INT_SOURCE_DMA,48 // multichannel DMA interrupt + .equ INT_SOURCE_DMA,48 // multichannel DMA interrupt .equ INT_SOURCE_CAN0_ERROR,49 // FlexCAN error interrupt .equ INT_SOURCE_CAN0_BUSOFF,50 // FlexCAN bus off interrupt .equ INT_SOURCE_CAN0_MBOR,51 // message buffer ORed interrupt - .equ INT_SOURCE_SLT1,53 // slice timer 1 interrupt - .equ INT_SOURCE_SLT0,54 // slice timer 0 interrupt + .equ INT_SOURCE_SLT1,53 // slice timer 1 interrupt + .equ INT_SOURCE_SLT0,54 // slice timer 0 interrupt .equ INT_SOURCE_CAN1_ERROR,55 // FlexCAN error interrupt .equ INT_SOURCE_CAN1_BUSOFF,56 // FlexCAN bus off interrupt .equ INT_SOURCE_CAN1_MBOR,57 // message buffer ORed interrupt - .equ INT_SOURCE_GPT3,59 // GPT3 timer interrupt - .equ INT_SOURCE_GPT2,60 // GPT2 timer interrupt - .equ INT_SOURCE_GPT1,61 // GPT1 timer interrupt - .equ INT_SOURCE_GPT0,62 // GPT0 timer interrupt + .equ INT_SOURCE_GPT3,59 // GPT3 timer interrupt + .equ INT_SOURCE_GPT2,60 // GPT2 timer interrupt + .equ INT_SOURCE_GPT1,61 // GPT1 timer interrupt + .equ INT_SOURCE_GPT0,62 // GPT0 timer interrupt // Atari register equates (provided by FPGA) .equ vbasehi, 0xffff8201 //mmu --------------------------------------------------- /* Register read/write macros */ -#define MCF_MMU_MMUCR __MMUBAR -#define MCF_MMU_MMUOR __MMUBAR+0x04 -#define MCF_MMU_MMUSR __MMUBAR+0x08 -#define MCF_MMU_MMUAR __MMUBAR+0x10 -#define MCF_MMU_MMUTR __MMUBAR+0x14 -#define MCF_MMU_MMUDR __MMUBAR+0x18 +#define MCF_MMU_MMUCR __MMUBAR +#define MCF_MMU_MMUOR __MMUBAR+0x04 +#define MCF_MMU_MMUSR __MMUBAR+0x08 +#define MCF_MMU_MMUAR __MMUBAR+0x10 +#define MCF_MMU_MMUTR __MMUBAR+0x14 +#define MCF_MMU_MMUDR __MMUBAR+0x18 /* Bit definitions and macros for MCF_MMU_MMUCR */ -#define MCF_MMU_MMUCR_EN (0x1) -#define MCF_MMU_MMUCR_ASM (0x2) +#define MCF_MMU_MMUCR_EN (0x1) +#define MCF_MMU_MMUCR_ASM (0x2) /* Bit definitions and macros for MCF_MMU_MMUOR */ -#define MCF_MMU_MMUOR_UAA (0x1) -#define MCF_MMU_MMUOR_ACC (0x2) -#define MCF_MMU_MMUOR_RW (0x4) -#define MCF_MMU_MMUOR_ADR (0x8) -#define MCF_MMU_MMUOR_ITLB (0x10) -#define MCF_MMU_MMUOR_CAS (0x20) -#define MCF_MMU_MMUOR_CNL (0x40) -#define MCF_MMU_MMUOR_CA (0x80) -#define MCF_MMU_MMUOR_STLB (0x100) -#define MCF_MMU_MMUOR_AA(x) (((x)&0xFFFF)<<0x10) +#define MCF_MMU_MMUOR_UAA (0x1) +#define MCF_MMU_MMUOR_ACC (0x2) +#define MCF_MMU_MMUOR_RW (0x4) +#define MCF_MMU_MMUOR_ADR (0x8) +#define MCF_MMU_MMUOR_ITLB (0x10) +#define MCF_MMU_MMUOR_CAS (0x20) +#define MCF_MMU_MMUOR_CNL (0x40) +#define MCF_MMU_MMUOR_CA (0x80) +#define MCF_MMU_MMUOR_STLB (0x100) +#define MCF_MMU_MMUOR_AA(x) (((x)&0xFFFF)<<0x10) /* Bit definitions and macros for MCF_MMU_MMUSR */ -#define MCF_MMU_MMUSR_HIT (0x2) -#define MCF_MMU_MMUSR_WF (0x8) -#define MCF_MMU_MMUSR_RF (0x10) -#define MCF_MMU_MMUSR_SPF (0x20) +#define MCF_MMU_MMUSR_HIT (0x2) +#define MCF_MMU_MMUSR_WF (0x8) +#define MCF_MMU_MMUSR_RF (0x10) +#define MCF_MMU_MMUSR_SPF (0x20) /* Bit definitions and macros for MCF_MMU_MMUAR */ -#define MCF_MMU_MMUAR_FA(x) (((x)&0xFFFFFFFF)<<0) +#define MCF_MMU_MMUAR_FA(x) (((x)&0xFFFFFFFF)<<0) /* Bit definitions and macros for MCF_MMU_MMUTR */ -#define MCF_MMU_MMUTR_V (0x1) -#define MCF_MMU_MMUTR_SG (0x2) -#define MCF_MMU_MMUTR_ID(x) (((x)&0xFF)<<0x2) -#define MCF_MMU_MMUTR_VA(x) (((x)&0x3FFFFF)<<0xA) +#define MCF_MMU_MMUTR_V (0x1) +#define MCF_MMU_MMUTR_SG (0x2) +#define MCF_MMU_MMUTR_ID(x) (((x)&0xFF)<<0x2) +#define MCF_MMU_MMUTR_VA(x) (((x)&0x3FFFFF)<<0xA) /* Bit definitions and macros for MCF_MMU_MMUDR */ -#define MCF_MMU_MMUDR_LK (0x2) -#define MCF_MMU_MMUDR_X (0x4) -#define MCF_MMU_MMUDR_W (0x8) -#define MCF_MMU_MMUDR_R (0x10) -#define MCF_MMU_MMUDR_SP (0x20) -#define MCF_MMU_MMUDR_CM(x) (((x)&0x3)<<0x6) -#define MCF_MMU_MMUDR_SZ(x) (((x)&0x3)<<0x8) -#define MCF_MMU_MMUDR_PA(x) (((x)&0x3FFFFF)<<0xA) +#define MCF_MMU_MMUDR_LK (0x2) +#define MCF_MMU_MMUDR_X (0x4) +#define MCF_MMU_MMUDR_W (0x8) +#define MCF_MMU_MMUDR_R (0x10) +#define MCF_MMU_MMUDR_SP (0x20) +#define MCF_MMU_MMUDR_CM(x) (((x)&0x3)<<0x6) +#define MCF_MMU_MMUDR_SZ(x) (((x)&0x3)<<0x8) +#define MCF_MMU_MMUDR_PA(x) (((x)&0x3FFFFF)<<0xA) -#define std_mmutr (MCF_MMU_MMUTR_SG|MCF_MMU_MMUTR_V) -#define writethrough_mmudr (MCF_MMU_MMUDR_SZ(00)|MCF_MMU_MMUDR_CM(00)|MCF_MMU_MMUDR_R|MCF_MMU_MMUDR_W|MCF_MMU_MMUDR_X) -#define copyback_mmudr (MCF_MMU_MMUDR_SZ(00)|MCF_MMU_MMUDR_CM(01)|MCF_MMU_MMUDR_R|MCF_MMU_MMUDR_W|MCF_MMU_MMUDR_X) +#define std_mmutr (MCF_MMU_MMUTR_SG|MCF_MMU_MMUTR_V) +#define writethrough_mmudr (MCF_MMU_MMUDR_SZ(00)|MCF_MMU_MMUDR_CM(00)|MCF_MMU_MMUDR_R|MCF_MMU_MMUDR_W|MCF_MMU_MMUDR_X) +#define copyback_mmudr (MCF_MMU_MMUDR_SZ(00)|MCF_MMU_MMUDR_CM(01)|MCF_MMU_MMUDR_R|MCF_MMU_MMUDR_W|MCF_MMU_MMUDR_X) // equates for (experimental) video page copying via Coldfire DMA .equ MCD_SINGLE_DMA, 0x100 @@ -208,14 +208,14 @@ /**********************************************************/ .altmacro .macro irq vector,int_mask,clr_int - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt subq.l #8,a7 - movem.l d0/a5,(a7) // save registers + movem.l d0/a5,(a7) // save registers - lea MCF_EPORT_EPFR,a5 + lea MCF_EPORT_EPFR,a5 move.b #\clr_int,(a5) // clear int pending - movem.l (a7),d0/a5 // restore registers + movem.l (a7),d0/a5 // restore registers addq.l #8,a7 move.l \vector,-(a7) move #0x2\int_mask\()00,sr @@ -243,9 +243,9 @@ .text _vec_init: - move.l a2,-(sp) // Backup registers + move.l a2,-(sp) // Backup registers - mov3q.l #-1,_rt_mod // rt_mod auf super + mov3q.l #-1,_rt_mod // rt_mod auf super clr.l _rt_ssp clr.l _rt_usp clr.l _rt_vbr @@ -255,55 +255,55 @@ _vec_init: move.l a0,a2 init_vec: move.l #256,d0 - lea std_exc_vec(pc),a1 // standard vector + lea std_exc_vec(pc),a1 // standard vector init_vec_loop: - move.l a1,(a2)+ // set standard vector for all exceptions + move.l a1,(a2)+ // set standard vector for all exceptions subq.l #1,d0 - bne init_vec_loop + bne init_vec_loop move.l #__SUP_SP,(a0) // set initial stack pointer at start of exception vector table - lea reset_vector(pc),a1 // set reset vector + lea reset_vector(pc),a1 // set reset vector move.l a1,0x04(a0) - lea access(pc),a1 // set illegal access exception handler + lea access(pc),a1 // set illegal access exception handler move.l a1,0x08(a0) .extern _get_bas_drivers // trap #0 (without any parameters for now) is used to provide BaS' driver addresses to the OS - lea _get_bas_drivers(pc),a1 - move.l a1,0x80(a0) // trap #0 exception vector + lea _get_bas_drivers(pc),a1 + move.l a1,0x80(a0) // trap #0 exception vector #ifdef MACHINE_FIREBEE // ACP interrupts 1-7 (user-defined, generated by FPGA on the FireBee, M5484LITE has irq7 and irq5 for PCI) - lea irq1(pc),a1 + lea irq1(pc),a1 move.l a1,0x104(a0) - lea irq2(pc),a1 + lea irq2(pc),a1 move.l a1,0x108(a0) - lea irq3(pc),a1 + lea irq3(pc),a1 move.l a1,0x10c(a0) - lea irq4(pc),a1 + lea irq4(pc),a1 move.l a1,0x110(a0) - lea irq5(pc),a1 + lea irq5(pc),a1 move.l a1,0x114(a0) - lea irq6(pc),a1 + lea irq6(pc),a1 move.l a1,0x118(a0) - lea irq7(pc),a1 + lea irq7(pc),a1 move.l a1,0x11c(a0) // install PSC vectors (used for PIC communication on the FireBee) - lea handler_psc3(pc),a1 + lea handler_psc3(pc),a1 // PSC3 interrupt source = 32 move.l a1,(INT_SOURCE_PSC3 + 64) * 4(a0) // timer vectors (triggers when vbashi gets changed, used for video page copy) - lea handler_gpt0(pc),a1 + lea handler_gpt0(pc),a1 // GPT0 interrupt source = 62 move.l a1,(INT_SOURCE_GPT0 + 64) * 4(a0) #endif /* MACHINE_FIREBEE */ // install lowlevel_isr_handler for the three GPT timers - lea _lowlevel_isr_handler(pc),a1 + lea _lowlevel_isr_handler(pc),a1 move.l a1,(INT_SOURCE_GPT1 + 64) * 4(a0) move.l a1,(INT_SOURCE_GPT2 + 64) * 4(a0) move.l a1,(INT_SOURCE_GPT3 + 64) * 4(a0) @@ -319,57 +319,57 @@ init_vec_loop: // install lowlevel_isr_handler for DMA interrupts move.l a1,(INT_SOURCE_DMA + 64) * 4(a0) - move.l (sp)+,a2 // Restore registers + move.l (sp)+,a2 // Restore registers rts /* * exception vector routines */ vector_table_start: std_exc_vec: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt subq.l #8,a7 - movem.l d0/a5,(sp) // save registers - move.w 8(sp),d0 // fetch vector - and.l #0x3fc,d0 // mask out vector number + movem.l d0/a5,(sp) // save registers + move.w 8(sp),d0 // fetch vector + and.l #0x3fc,d0 // mask out vector number #ifdef DBG_EXC // printout vector number of exception - lea -4 * 4(sp),sp // reserve stack space + lea -4 * 4(sp),sp // reserve stack space movem.l d0-d1/a0-a1,(sp) // save gcc scratch registers - lsr.l #2,d0 // shift vector number in place + lsr.l #2,d0 // shift vector number in place cmp.l #33,d0 - beq noprint + beq noprint cmp.l #34,d0 - beq noprint + beq noprint cmp.l #45,d0 - beq noprint + beq noprint cmp.l #46,d0 - beq noprint + beq noprint move.l 4 * 4 + 8 + 4(sp),-(sp) // pc at exception - move.l d0,-(sp) // provide it to xprintf() - pea exception_text - jsr _xprintf // call xprintf() - add.l #3*4,sp // adjust stack + move.l d0,-(sp) // provide it to xprintf() + pea exception_text + jsr _xprintf // call xprintf() + add.l #3*4,sp // adjust stack noprint: movem.l (sp),d0-d1/a0-a1 // restore registers - lea 4 * 4(sp),sp + lea 4 * 4(sp),sp #endif /* DBG_EXC */ - add.l _rt_vbr,d0 // + VBR + add.l _rt_vbr,d0 // + VBR move.l d0,a5 - move.l (a5),d0 // fetch exception routine address + move.l (a5),d0 // fetch exception routine address - move.l 4(sp),a5 // restore a5 - move.l d0,4(a7) // store exception routine address + move.l 4(sp),a5 // restore a5 + move.l d0,4(a7) // store exception routine address - move.w 10(a7),d0 // restore original SR - bset #13,d0 // set supervisor bit - move.w d0,sr // - move.l (a7)+,d0 // restore d0 - rts // jump to exception routine + move.w 10(a7),d0 // restore original SR + bset #13,d0 // set supervisor bit + move.w d0,sr // + move.l (a7)+,d0 // restore d0 + rts // jump to exception routine exception_text: .ascii "DEBUG: EXCEPTION %d caught at %p" @@ -377,80 +377,80 @@ exception_text: .align 4 reset_vector: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt move.l #0x31415926,d0 - cmp.l 0x426,d0 // _resvalid: reset vector valid? - beq std_exc_vec // yes-> - jmp _rom_entry // no, cold start machine + cmp.l 0x426,d0 // _resvalid: reset vector valid? + beq std_exc_vec // yes-> + jmp _rom_entry // no, cold start machine access: - move.w #0x2700,sr // disable interrupt - move.l d0,-(sp) // ++ vr + move.w #0x2700,sr // disable interrupt + move.l d0,-(sp) // ++ vr - move.w 4(sp),d0 // get format_status word from stack - andi.l #0x0c03,d0 // mask out fault status bits - cmpi.l #0x0401,d0 // TLB miss on opword of instruction fetch? - beq access_mmu // yes - cmpi.l #0x0402,d0 // TLB miss on extension word of instruction fetch? - beq access_mmu // yes - cmpi.l #0x0802,d0 // TLB miss on data write? - beq access_mmu // yes - cmpi.l #0x0c02,d0 // TLB miss on data read, or read-modify-write? - beq access_mmu // yes + move.w 4(sp),d0 // get format_status word from stack + andi.l #0x0c03,d0 // mask out fault status bits + cmpi.l #0x0401,d0 // TLB miss on opword of instruction fetch? + beq access_mmu // yes + cmpi.l #0x0402,d0 // TLB miss on extension word of instruction fetch? + beq access_mmu // yes + cmpi.l #0x0802,d0 // TLB miss on data write? + beq access_mmu // yes + cmpi.l #0x0c02,d0 // TLB miss on data read, or read-modify-write? + beq access_mmu // yes - bra bus_error // everything else is a classic bus error + bra bus_error // everything else is a classic bus error access_mmu: move.l MCF_MMU_MMUSR,d0 // did the last fault hit in TLB? - btst #1,d0 // yes, it did. So we already mapped that page - bne bus_error // and this must be a real bus error + btst #1,d0 // yes, it did. So we already mapped that page + bne bus_error // and this must be a real bus error move.l MCF_MMU_MMUAR,d0 cmp.l #__FASTRAM_END,d0 // above max User RAM area? - bge bus_error // -> bus error + bge bus_error // -> bus error - lea -5*4(sp),sp // save gcc scratch registers + lea -5*4(sp),sp // save gcc scratch registers movem.l d0-d1/a0-a2,(sp) - move.l d0,-(sp) // fault address - jsr _mmutr_miss // else we have an MMU TLB miss + move.l d0,-(sp) // fault address + jsr _mmutr_miss // else we have an MMU TLB miss addq.l #4,sp movem.l (sp),d0-d1/a0-a2 // restore gcc scratch registers - lea 5*4(sp),sp + lea 5*4(sp),sp - move.l (sp)+,d0 // restore register + move.l (sp)+,d0 // restore register rte bus_error: - move.l (sp)+,d0 // restore register - bra std_exc_vec + move.l (sp)+,d0 // restore register + bra std_exc_vec zero_divide: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt move.l a0,-(a7) move.l d0,-(a7) - move.l 12(a7),a0 // pc - move.w (a0)+,d0 // command word - btst #7,d0 // long? - beq zd_word // nein-> + move.l 12(a7),a0 // pc + move.w (a0)+,d0 // command word + btst #7,d0 // long? + beq zd_word // nein-> addq.l #2,a0 zd_word: - and.l 0x3f,d0 // mask out ea field - cmp.w #0x08,d0 // -(ax) or less? - ble zd_end + and.l 0x3f,d0 // mask out ea field + cmp.w #0x08,d0 // -(ax) or less? + ble zd_end addq.l #2,a0 - cmp.w #0x39,d0 // xxx.L - bne zd_nal + cmp.w #0x39,d0 // xxx.L + bne zd_nal addq.l #2,a0 - bra zd_end + bra zd_end zd_nal: cmp.w #0x3c,d0 // immediate? - bne zd_end // no-> - btst #7,d0 // long? - beq zd_end // no + bne zd_end // no-> + btst #7,d0 // long? + beq zd_end // no addq.l #2,a0 zd_end: move.l a0,12(a7) @@ -460,110 +460,110 @@ zd_end: #ifdef _NOT_USED_ linea: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt halt nop nop linef: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt halt nop nop format: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt halt nop nop //floating point flpoow: - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt halt nop nop #endif /* _NOT_USED */ irq1: - irq 0x64,1,0x02 + irq 0x64,1,0x02 irq2: // hbl - // move.b #3,2(a7) - // rte - irq 0x68,2,0x04 + // move.b #3,2(a7) + // rte + irq 0x68,2,0x04 irq3: - irq 0x6c,3,0x08 + irq 0x6c,3,0x08 -irq4: // vbl - irq 0x70,4,0x10 +irq4: // vbl + irq 0x70,4,0x10 -#if MACHINE_M5484LITE_notyet // handlers for M5484LITE +#if MACHINE_M5484LITE_notyet // handlers for M5484LITE -irq5: // irq5 is tied to PCI INTC# and PCI INTD# on the M5484LITE - move.w #0x2700,sr // disable interrupts +irq5: // irq5 is tied to PCI INTC# and PCI INTD# on the M5484LITE + move.w #0x2700,sr // disable interrupts - lea -4*4(sp),sp // save gcc scratch registers + lea -4*4(sp),sp // save gcc scratch registers movem.l d0-d1/a0-a1,(sp) - jsr _irq5_handler // call C handler routine + jsr _irq5_handler // call C handler routine movem.l (sp),d0-d1/a0-a1 // restore registers - lea 4*4(sp),sp + lea 4*4(sp),sp - rte // return from exception + rte // return from exception irq5text: .ascii "IRQ5!" .dc.b 13,10,0 irq6: - irq 0x74,5,0x20 + irq 0x74,5,0x20 -irq7: // irq7 is tied to PCI INTA# and PCI INTB# on the M5484LITE +irq7: // irq7 is tied to PCI INTA# and PCI INTB# on the M5484LITE - move.w #0x2700,sr // disable interrupts + move.w #0x2700,sr // disable interrupts - lea -4*4(sp),sp // save gcc scratch registers + lea -4*4(sp),sp // save gcc scratch registers movem.l d0-d1/a0-a1,(sp) - jsr _irq7_handler // call C handler routine + jsr _irq7_handler // call C handler routine movem.l (sp),d0-d1/a0-a1 // restore registers - lea 4*4(sp),sp + lea 4*4(sp),sp - rte // return from exception + rte // return from exception irq7text: .ascii "IRQ7!" .dc.b 13,10,0 -#elif MACHINE_FIREBEE /* these handlers are only meaningful for the Firebee */ -irq5: // irq5 is tied to PCI INTC# and PCI INTD# on the M5484LITE - irq 0x74,5,0x20 +#elif MACHINE_FIREBEE /* these handlers are only meaningful for the Firebee */ +irq5: // irq5 is tied to PCI INTC# and PCI INTD# on the M5484LITE + irq 0x74,5,0x20 irq6: // MFP interrupt from FPGA - move.w #0x2700,sr // disable interrupt + move.w #0x2700,sr // disable interrupt subq.l #8,a7 - movem.l d0/a5,(a7) // save registers + movem.l d0/a5,(a7) // save registers - lea MCF_EPORT_EPFR,a5 // clear int6 from edge port + lea MCF_EPORT_EPFR,a5 // clear int6 from edge port bset #6,(a5) // there was a potential bug here before: would also clear all other edge port interrupts that might have happened... - // move.b #0x40,(a5) // clear int6 from edge port + // move.b #0x40,(a5) // clear int6 from edge port // screen adr change timed out? move.l _video_sbt,d0 - beq irq6_non_sca // nothing to do if 0 + beq irq6_non_sca // nothing to do if 0 sub.l #0x70000000,d0 // substract 14 seconds - lea MCF_SLT0_SCNT,a5 - cmp.l (a5),d0 // time reached? - ble irq6_non_sca // not yet + lea MCF_SLT0_SCNT,a5 + cmp.l (a5),d0 // time reached? + ble irq6_non_sca // not yet - lea -28(a7),a7 // save more registers + lea -28(a7),a7 // save more registers movem.l d0-d4/a0-a1,(a7) // - clr.l d3 // beginn mit 0 - jsr _flush_and_invalidate_caches + clr.l d3 // beginn mit 0 + jsr _flush_and_invalidate_caches // eintrag suchen irq6_next_sca: @@ -580,19 +580,19 @@ irq6: // MFP interrupt from FPGA move.l d4,MCF_MMU_MMUOR // einträge holen aus mmu nop move.l MCF_MMU_MMUTR,d4 // ID holen - lsr.l #2,d4 // bit 9 bis 2 + lsr.l #2,d4 // bit 9 bis 2 cmp.w #sca_page_ID,d4 // ist screen change ID? - bne irq6_sca_pn // nein -> page keine screen area next + bne irq6_sca_pn // nein -> page keine screen area next // eintrag �ndern add.l #std_mmutr,d0 - move.l d3,d1 // page 0? - beq irq6_sca_pn0 // ja -> + move.l d3,d1 // page 0? + beq irq6_sca_pn0 // ja -> add.l #copyback_mmudr,d1 // sonst page cb - bra irq6_sca_pn1c + bra irq6_sca_pn1c irq6_sca_pn0: add.l #writethrough_mmudr|MCF_MMU_MMUDR_LK,d1 // page wt and locked irq6_sca_pn1c: - mvz.w #0x10b,d2 // MMU update + mvz.w #0x10b,d2 // MMU update move.l d0,MCF_MMU_MMUTR move.l d1,MCF_MMU_MMUDR move.l d2,MCF_MMU_MMUOR // setze tlb data only @@ -601,7 +601,7 @@ irq6_sca_pn1c: move.l d3,a0 add.l #0x60000000,a0 move.l d3,a1 - move.l #0x10000,d4 // one whole page (1 MB) + move.l #0x10000,d4 // one whole page (1 MB) #define _DO_CPU_COPY #ifndef _DO_CPU_COPY @@ -610,117 +610,117 @@ irq6_sca_pn1c: lea -15 * 4(sp),sp movem.l d0-d1/a0-a1,(sp) // save gcc scratch registers - clr.l -(sp) // no special functions + clr.l -(sp) // no special functions move.l #MCD_SINGLE_DMA|MCD_TT_FLAGS_CW|MCD_TT_FLAGS_RL|MCD_TT_FLAGS_SP,-(sp) - mov3q #7,-(sp) // highest DMA priority + mov3q #7,-(sp) // highest DMA priority move.l #DMA_ALWAYS,-(sp) // do memory to memory DMA - move.l #1,-(sp) // copy 4 bytes at a time + move.l #1,-(sp) // copy 4 bytes at a time move.l #0x100000,-(sp) // copy 1 Megabyte - move.l #4,-(sp) // destination increment - move.l a1,-(sp) // destination adress - move.l #4,-(sp) // source increment - move.l a0,-(sp) // source adress - move.l #1,-(sp) // channel 1 - jsr _MCD_startDma + move.l #4,-(sp) // destination increment + move.l a1,-(sp) // destination adress + move.l #4,-(sp) // source increment + move.l a0,-(sp) // source adress + move.l #1,-(sp) // channel 1 + jsr _MCD_startDma movem.l (sp),d0-d1/a0-a1 // restore gcc scratch registers - lea 15 * 4(sp),sp // adjust stack + lea 15 * 4(sp),sp // adjust stack wait_dma_finished: clr.l -(sp) - jsr _MCD_dmaStatus + jsr _MCD_dmaStatus addq.l #4,sp tst.l d0 cmp.l #6,d0 - bne wait_dma_finished + bne wait_dma_finished #else irq6_vcd0_loop: - move.l (a0)+,(a1)+ // page copy + move.l (a0)+,(a1)+ // page copy move.l (a0)+,(a1)+ move.l (a0)+,(a1)+ move.l (a0)+,(a1)+ subq.l #1,d4 - bne irq6_vcd0_loop + bne irq6_vcd0_loop #endif /* _DO_CPU_COPY */ irq6_sca_pn: add.l #0x00100000,d3 // next cmp.l #0x00d00000,d3 // ende? - blt irq6_next_sca // nein-> + blt irq6_next_sca // nein-> move.l #0x2000,d0 move.l d0,_video_tlb // anfangszustand wieder herstellen - clr.l _video_sbt // zeit löschen + clr.l _video_sbt // zeit löschen movem.l (sp),d0-d4/a0-a1 // restore registers - lea 7 * 4(sp),sp + lea 7 * 4(sp),sp irq6_non_sca: // test auf acsi dma ----------------------------------------------------------------- - lea 0xfffffa0b,a5 - bset #7,-4(a5) // int ena - btst.b #7,(a5) // acsi dma int? - beq non_acsi_dma - bsr acsi_dma + lea 0xfffffa0b,a5 + bset #7,-4(a5) // int ena + btst.b #7,(a5) // acsi dma int? + beq non_acsi_dma + bsr acsi_dma non_acsi_dma: // ---------------------------------------------------------------------------------- tst.b (a5) - bne irq6_1 + bne irq6_1 tst.b 2(a5) - bne irq6_1 + bne irq6_1 movem.l (a7),d0/a5 addq.l #8,a7 rte irq6_1: - lea MCF_GPIO_PODR_FEC1L,a5 - bclr.b #4,(a5) // led on - lea blinker,a5 - addq.l #1,(a5) // +1 + lea MCF_GPIO_PODR_FEC1L,a5 + bclr.b #4,(a5) // led on + lea blinker,a5 + addq.l #1,(a5) // +1 move.l (a5),d0 and.l #0x80,d0 - bne irq6_2 - lea MCF_GPIO_PODR_FEC1L,a5 - bset.b #4,(a5) // led off + bne irq6_2 + lea MCF_GPIO_PODR_FEC1L,a5 + bset.b #4,(a5) // led off irq6_2: // test auf protect mode --------------------- move.b DIP_SWITCHa,d0 btst #7,d0 - bne irq6_3 // ja-> + bne irq6_3 // ja-> // ------------------------------------------- move.l 0xF0020000,a5 // vector holen - add.l _rt_vbr,a5 // basis - move.l (a5),d0 // vector holen - move.l 4(a7),a5 // a5 zurück - move.l d0,4(a7) // vector eintragen - move.l (a7)+,d0 // d0 zurück + add.l _rt_vbr,a5 // basis + move.l (a5),d0 // vector holen + move.l 4(a7),a5 // a5 zurück + move.l d0,4(a7) // vector eintragen + move.l (a7)+,d0 // d0 zurück move #0x2600,sr rts irq6_3: - move.l usp,a5 // usp holen - tst.b _rt_mod // supervisor? - bne sev_sup6 // ja -> - mov3q.l #-1,_rt_mod // auf supervisor setzen - move.l a5,_rt_usp // rt_usp speichern - move.l _rt_ssp,a5 // rt_ssp holen + move.l usp,a5 // usp holen + tst.b _rt_mod // supervisor? + bne sev_sup6 // ja -> + mov3q.l #-1,_rt_mod // auf supervisor setzen + move.l a5,_rt_usp // rt_usp speichern + move.l _rt_ssp,a5 // rt_ssp holen move.l 12(a7),-(a5) // pc transferieren - move.l 8(a7),-(a5) // sr transferieren - move.l a5,usp // usp setzen + move.l 8(a7),-(a5) // sr transferieren + move.l a5,usp // usp setzen move.l 0xF0020000,a5 // vector holen: intack routine - add.l _rt_vbr,a5 // virtuelle VBR des Systems - move.l (a5),12(a7) // hier gehts weiter - movem.l (a7),d0/a5 // register zurück + add.l _rt_vbr,a5 // virtuelle VBR des Systems + move.l (a5),12(a7) // hier gehts weiter + movem.l (a7),d0/a5 // register zurück addq.l #8,a7 - move.b #6,2(a7) // intmaske setzen - rte // und weg + move.b #6,2(a7) // intmaske setzen + rte // und weg sev_sup6: move.l 12(a7),-(a5) // pc transferieren - move.l 8(a7),-(a5) // sr,vec - bset #5,2(a5) // auf super setzen - move.l a5,usp // usp setzen + move.l 8(a7),-(a5) // sr,vec + bset #5,2(a5) // auf super setzen + move.l a5,usp // usp setzen move.l 0xF0020000,a5 // vector holen: intack routine - add.l _rt_vbr,a5 // virtuelle VBR des Systems - move.l (a5),12(a7) // hier gehts weiter - movem.l (a7),d0/a5 // register zurück + add.l _rt_vbr,a5 // virtuelle VBR des Systems + move.l (a5),12(a7) // hier gehts weiter + movem.l (a7),d0/a5 // register zurück rts .data @@ -732,7 +732,7 @@ blinker:.long 0 /* * pseudo dma */ -acsi_dma: // atari dma +acsi_dma: // atari dma move.l a1,-(a7) move.l d1,-(a7) @@ -744,47 +744,47 @@ acsi_dma: // atari dma lea 0xf0020110,a5 // fifo daten acsi_dma_start: - move.l -12(a5),a1 // dma adresse - move.l -8(a5),d0 // byt counter - ble acsi_dma_end - btst.b #0,-16(a5) // write? (dma modus reg) - bne acsi_dma_wl // ja-> + move.l -12(a5),a1 // dma adresse + move.l -8(a5),d0 // byt counter + ble acsi_dma_end + btst.b #0,-16(a5) // write? (dma modus reg) + bne acsi_dma_wl // ja-> acsi_dma_rl: - tst.b -4(a5) // dma req? - bpl acsi_dma_finished // nein-> - move.l (a5),(a1)+ // read 4 bytes - move.l (a5),(a1)+ // read 4 bytes - move.l (a5),(a1)+ // read 4 bytes - move.l (a5),(a1)+ // read 4 bytes + tst.b -4(a5) // dma req? + bpl acsi_dma_finished // nein-> + move.l (a5),(a1)+ // read 4 bytes + move.l (a5),(a1)+ // read 4 bytes + move.l (a5),(a1)+ // read 4 bytes + move.l (a5),(a1)+ // read 4 bytes moveq #'.',d1 move.b d1,MCF_PSC0_PSCTB_8BIT - sub.l #16,d0 // byt counter -16 - bpl acsi_dma_rl - bra acsi_dma_finished + sub.l #16,d0 // byt counter -16 + bpl acsi_dma_rl + bra acsi_dma_finished acsi_dma_wl: - tst.b -4(a5) // dma req? - bpl acsi_dma_finished // nein-> - move.l (a1)+,(a5) // write 4 byts - move.l (a1)+,(a5) // write 4 byts - move.l (a1)+,(a5) // write 4 byts - move.l (a1)+,(a5) // write 4 byts + tst.b -4(a5) // dma req? + bpl acsi_dma_finished // nein-> + move.l (a1)+,(a5) // write 4 byts + move.l (a1)+,(a5) // write 4 byts + move.l (a1)+,(a5) // write 4 byts + move.l (a1)+,(a5) // write 4 byts moveq #'.',d1 move.b d1,MCF_PSC0_PSCTB_8BIT - sub.l #16,d0 // byt counter -16 - bpl acsi_dma_wl + sub.l #16,d0 // byt counter -16 + bpl acsi_dma_wl acsi_dma_finished: - move.l a1,-12(a5) // adresse zur�ck - move.l d0,-8(a5) // byt counter zur�ck + move.l a1,-12(a5) // adresse zur�ck + move.l d0,-8(a5) // byt counter zur�ck acsi_dma_end: - tst.b -4(a5) // dma req? - bmi acsi_dma_start // ja-> - lea 0xfffffa0b,a5 - bclr.b #7,4(a5) // clear int in service mfp - bclr.b #7,(a5) // clear int pending mfp 0xfffffa0b + tst.b -4(a5) // dma req? + bmi acsi_dma_start // ja-> + lea 0xfffffa0b,a5 + bclr.b #7,4(a5) // clear int in service mfp + bclr.b #7,(a5) // clear int pending mfp 0xfffffa0b move.w #0x0d0a,d1 move.w d1,MCF_PSC0_PSCTB_8BIT @@ -796,38 +796,38 @@ acsi_dma_end: * irq 7 = pseudo bus error */ irq7: - lea -12(sp),sp - movem.l d0/a0,(sp) + lea -12(sp),sp + movem.l d0/a0,(sp) - move.l __RAMBAR0+0x008,a0 // real access error handler - move.l a0,8(sp) // this will be the return address for rts + move.l __RAMBAR0+0x008,a0 // real access error handler + move.l a0,8(sp) // this will be the return address for rts - move.w 12(sp),d0 // format/vector word - andi.l #0xf000,d0 // keep only the format - ori.l #2*4,d0 // simulate vector #2, no fault - move.w d0,12(sp) + move.w 12(sp),d0 // format/vector word + andi.l #0xf000,d0 // keep only the format + ori.l #2*4,d0 // simulate vector #2, no fault + move.w d0,12(sp) // TODO: Inside an interrupt handler, 16(sp) is the return address. // For an Access Error, it should be the address of the fault instruction instead - lea MCF_EPORT_EPFR,a0 - bset #7,(a0) // clear int 7 + lea MCF_EPORT_EPFR,a0 + bset #7,(a0) // clear int 7 - move.l (sp)+,d0 // restore registers - move.l (sp)+,a0 - rts // Forward to the Access Error handler + move.l (sp)+,d0 // restore registers + move.l (sp)+,a0 + rts // Forward to the Access Error handler /* * psc3 com PIC MCF */ handler_psc3: - move.w #0x2700,sr // disable interrupt - lea -20(a7),a7 + move.w #0x2700,sr // disable interrupt + lea -20(a7),a7 movem.l d0-d2/a0/a3,(a7) - lea MCF_PSC3_PSCRB_8BIT,a3 + lea MCF_PSC3_PSCRB_8BIT,a3 move.b (a3),d1 - cmp.b #2,d1 // anforderung rtc daten? - bne psc3_fertig + cmp.b #2,d1 // anforderung rtc daten? + bne psc3_fertig lea MCF_PSC0_PSCTB_8BIT,a0 // ++ vr mchar move.l,'\P,'\I,'C,' ,(a0) @@ -835,11 +835,11 @@ handler_psc3: mchar move.l,'R,'T,'C,'!,(a0) mchar move.l,0x0d,0x0a,0,0,(a0) - lea 0xffff8961,a0 - lea MCF_PSC3_PSCTB_8BIT,a3 + lea 0xffff8961,a0 + lea MCF_PSC3_PSCTB_8BIT,a3 clr.l d1 moveq #64,d2 - move.b #0x82,(a3) // header: rtcd mcf->pic + move.b #0x82,(a3) // header: rtcd mcf->pic loop_sr2: move.b d1,(a0) move.b 2(a0),d0 @@ -849,7 +849,7 @@ loop_sr2: bne loop_sr2 psc3_fertig: movem.l (a7),d0-d2/a0/a3 // restore saved registers - lea 20(a7),a7 + lea 20(a7),a7 RTE /* @@ -858,25 +858,25 @@ psc3_fertig: * vbasehi is written to, i.e. when the video base address gets changed */ handler_gpt0: - move #0x2700,sr // disable interrupts + move #0x2700,sr // disable interrupts - lea -28(a7),a7 // save registers + lea -28(a7),a7 // save registers movem.l d0-d4/a0-a1,(a7) - mvz.b vbasehi,d0 // screen base address high - cmp.w #2,d0 // screen base lower than 0x20000? - blt video_chg_end // yes, do nothing - cmp.w #0xd0,d0 // lower than 0xd00000? - normal Falcon video area, mapped - // to 60d00000 (FPGA video memory) - blt sca_other // + mvz.b vbasehi,d0 // screen base address high + cmp.w #2,d0 // screen base lower than 0x20000? + blt video_chg_end // yes, do nothing + cmp.w #0xd0,d0 // lower than 0xd00000? - normal Falcon video area, mapped + // to 60d00000 (FPGA video memory) + blt sca_other // - lea MCF_SLT0_SCNT,a0 + lea MCF_SLT0_SCNT,a0 move.l (a0),_video_sbt // save time // FIXME: don't we need to get out here? sca_other: - lsl.l #8,d0 // build new screen start address from Atari register contents + lsl.l #8,d0 // build new screen start address from Atari register contents move.b 0xffff8203,d0 // mid byte lsl.l #8,d0 move.b 0xffff820d,d0 // low byte @@ -886,12 +886,12 @@ video_chg_1page: // check if page is already marked as video page moveq #20,d4 move.l d0,d2 - lsr.l d4,d2 // new page + lsr.l d4,d2 // new page move.l _video_tlb,d4 - bset.l d2,d4 // set as changed - bne video_chg_2page // was it set already? + bset.l d2,d4 // set as changed + bne video_chg_2page // was it set already? move.l d4,_video_tlb - jsr _flush_and_invalidate_caches + jsr _flush_and_invalidate_caches video_copy_data: move.l d4,_video_tlb @@ -899,7 +899,7 @@ video_copy_data: move.l d0,a0 move.l a0,a1 add.l #0x60000000,a1 - move.l #0x10000,d4 // whole page + move.l #0x10000,d4 // whole page #ifndef _DO_CPU_COPY @@ -908,38 +908,38 @@ video_copy_data: lea -15 * 4(sp),sp movem.l d0-d1/a0-a1,(sp) // save gcc scratch registers - clr.l -(sp) // no special functions + clr.l -(sp) // no special functions move.l #MCD_SINGLE_DMA|MCD_TT_FLAGS_CW|MCD_TT_FLAGS_RL|MCD_TT_FLAGS_SP,-(sp) - mov3q #7,-(sp) // highest DMA priority + mov3q #7,-(sp) // highest DMA priority move.l #DMA_ALWAYS,-(sp) // do memory to memory DMA - move.l #1,-(sp) // copy 4 bytes at a time + move.l #1,-(sp) // copy 4 bytes at a time move.l #0x100000,-(sp) // copy 1 Megabyte - move.l #4,-(sp) // destination increment - move.l a1,-(sp) // destination adress - move.l #4,-(sp) // source increment - move.l a0,-(sp) // source adress - move.l #1,-(sp) // channel 1 - jsr _MCD_startDma + move.l #4,-(sp) // destination increment + move.l a1,-(sp) // destination adress + move.l #4,-(sp) // source increment + move.l a0,-(sp) // source adress + move.l #1,-(sp) // channel 1 + jsr _MCD_startDma .wait_dma_finished: clr.l -(sp) - jsr _MCD_dmaStatus + jsr _MCD_dmaStatus addq.l #4,sp tst.l d0 cmp.l #6,d0 - bne .wait_dma_finished + bne .wait_dma_finished movem.l (sp),d0-d1/a0-a1 // restore gcc scratch registers - lea 15 * 4(sp),sp // adjust stack + lea 15 * 4(sp),sp // adjust stack #else video_copy_data_loop: - move.l (a0)+,(a1)+ // copy video page contents to real screen + move.l (a0)+,(a1)+ // copy video page contents to real screen move.l (a0)+,(a1)+ move.l (a0)+,(a1)+ move.l (a0)+,(a1)+ subq.l #1,d4 - bne video_copy_data_loop + bne video_copy_data_loop #endif // eintrag suchen @@ -954,10 +954,10 @@ video_copy_data_loop: move.l d0,d1 add.l #MCF_MMU_MMUTR_ID(sca_page_ID)|std_mmutr,d0 add.l #0x60000000|writethrough_mmudr|MCF_MMU_MMUDR_LK,d1 - mvz.w #0x10b,d2 // MMU update + mvz.w #0x10b,d2 // MMU update move.l d0,MCF_MMU_MMUTR move.l d1,MCF_MMU_MMUDR - move.l d2,MCF_MMU_MMUOR // setzen vidoe maped to 60xxx only data + move.l d2,MCF_MMU_MMUOR // setzen vidoe maped to 60xxx only data nop video_chg_2page: // test of adjacent page is needed also @@ -965,25 +965,25 @@ video_chg_2page: mvz.w 0xffff8210,d4 // byts pro zeile mvz.w 0xffff82aa,d2 // zeilen ende mvz.w 0xffff82a8,d1 // zeilenstart - sub.l d1,d2 // differenz = anzahl zeilen - mulu d2,d4 // maximal 480 zeilen - add.l d4,d0 // video gr�sse + sub.l d1,d2 // differenz = anzahl zeilen + mulu d2,d4 // maximal 480 zeilen + add.l d4,d0 // video gr�sse cmp.l #__STRAM_END,d0 // maximale addresse - bge video_chg_end // wenn gleich oder gr�sser -> fertig + bge video_chg_end // wenn gleich oder gr�sser -> fertig moveq #20,d4 move.l d0,d2 - lsr.l d4,d2 // neue page + lsr.l d4,d2 // neue page move.l _video_tlb,d4 - bset.l d2,d4 // setzen als ge�ndert - beq video_copy_data // nein nochmal + bset.l d2,d4 // setzen als ge�ndert + beq video_copy_data // nein nochmal video_chg_end: - lea MCF_GPT0_GMS,a0 // clear interrupt + lea MCF_GPT0_GMS,a0 // clear interrupt bclr.b #0,3(a0) nop bset.b #0,3(a0) movem.l (a7),d0-d4/a0-a1 // restore saved registers - lea 7 * 4(sp),a7 + lea 7 * 4(sp),a7 rte #endif /* MACHINE_FIREBEE */ @@ -995,16 +995,16 @@ video_chg_end: .extern _isr_execute_handler _lowlevel_isr_handler: - move.w #0x2700,sr // disable interrupts - link a6,#-4*4 // make room for + move.w #0x2700,sr // disable interrupts + link a6,#-4*4 // make room for movem.l d0-d1/a0-a1,(sp) // gcc scratch registers and save them - move.w 4(a6),d0 // fetch vector number from stack - lsr.l #2,d0 // move it in place + move.w 4(a6),d0 // fetch vector number from stack + lsr.l #2,d0 // move it in place andi.l #0x000000ff,d0 // mask it out - move.l d0,-(sp) // push it - jsr _isr_execute_handler // call the C handler - lea 4(sp),sp // adjust stack + move.l d0,-(sp) // push it + jsr _isr_execute_handler // call the C handler + lea 4(sp),sp // adjust stack movem.l (sp),d0-d1/a0-a1 // restore registers - unlk a6 // cleanup stack + unlk a6 // cleanup stack rte diff --git a/BaS_gcc/usb/usb.c b/BaS_gcc/usb/usb.c index 9c9a9de..59432a8 100644 --- a/BaS_gcc/usb/usb.c +++ b/BaS_gcc/usb/usb.c @@ -56,13 +56,13 @@ extern int usb_stor_curr_dev; extern uint32_t usb_1st_disk_drive; -//#define USB_DEBUG - -#ifdef USB_DEBUG -#define debug_printf(fmt, args...) xprintf(fmt , ##args) +#define DEBUG_USB +#ifdef DEBUG_USB +#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0) #else -#define debug_printf(fmt, args...) -#endif +#define dbg(format, arg...) do { ; } while (0) +#endif /* DEBUG_USB */ + #define USB_BUFSIZ 512 @@ -157,20 +157,20 @@ int usb_init(int32_t handle, const struct pci_device_id *ent) usb_hub_reset(bus_index); /* init low_level USB */ - debug_printf("USB: "); + dbg("USB: "); switch(ent->class) { case PCI_CLASS_SERIAL_USB_UHCI: //res = uhci_usb_lowlevel_init(handle, ent, &priv); - debug_printf("sorry, no uhci driver available\r\n"); + dbg("sorry, no uhci driver available\r\n"); break; case PCI_CLASS_SERIAL_USB_OHCI: - debug_printf("initialize ohci interface\r\n"); + dbg("initialize ohci interface\r\n"); res = ohci_usb_lowlevel_init(handle, ent, &priv); break; case PCI_CLASS_SERIAL_USB_EHCI: - debug_printf("initialize ehci interface\r\n"); + dbg("initialize ehci interface\r\n"); res = ehci_usb_lowlevel_init(handle, ent, &priv); break; default: res = -1; break; @@ -315,7 +315,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, setup_packet->value = swpw(value); setup_packet->index = swpw(index); setup_packet->length = swpw(size); - debug_printf("usb_control_msg: request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\r\n", request, requesttype, value, index, size); + dbg("usb_control_msg: request: 0x%X, requesttype: 0x%X, value 0x%X index 0x%X length 0x%X\r\n", request, requesttype, value, index, size); switch(priv->ent->class) { case PCI_CLASS_SERIAL_USB_OHCI: @@ -414,7 +414,7 @@ static void __attribute__((noinline))usb_set_maxpacket_ep(struct usb_device *dev /* Control => bidirectional */ dev->epmaxpacketout[b] = ep->wMaxPacketSize; dev->epmaxpacketin[b] = ep->wMaxPacketSize; - debug_printf("##Control EP epmaxpacketout/in[%d] = %d\r\n", b, dev->epmaxpacketin[b]); + dbg("##Control EP epmaxpacketout/in[%d] = %d\r\n", b, dev->epmaxpacketin[b]); } else { @@ -424,7 +424,7 @@ static void __attribute__((noinline))usb_set_maxpacket_ep(struct usb_device *dev if (ep->wMaxPacketSize > dev->epmaxpacketout[b]) { dev->epmaxpacketout[b] = ep->wMaxPacketSize; - debug_printf("##EP epmaxpacketout[%d] = %d\r\n", b, dev->epmaxpacketout[b]); + dbg("##EP epmaxpacketout[%d] = %d\r\n", b, dev->epmaxpacketout[b]); } } else @@ -433,7 +433,7 @@ static void __attribute__((noinline))usb_set_maxpacket_ep(struct usb_device *dev if (ep->wMaxPacketSize > dev->epmaxpacketin[b]) { dev->epmaxpacketin[b] = ep->wMaxPacketSize; - debug_printf("##EP epmaxpacketin[%d] = %d\r\n", b, dev->epmaxpacketin[b]); + dbg("##EP epmaxpacketin[%d] = %d\r\n", b, dev->epmaxpacketin[b]); } } /* if out */ } /* if control */ @@ -467,7 +467,7 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno) head = (struct usb_descriptor_header *)&buffer[0]; if (head->bDescriptorType != USB_DT_CONFIG) { - debug_printf(" ERROR: NOT USB_CONFIG_DESC %x\r\n", head->bDescriptorType); + dbg(" ERROR: NOT USB_CONFIG_DESC %x\r\n", head->bDescriptorType); return -1; } memcpy(&dev->config, buffer, buffer[0]); @@ -504,12 +504,12 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno) dev->config.if_desc[ifno].no_of_ep++; memcpy(&dev->config.if_desc[ifno].ep_desc[epno], &buffer[index], buffer[index]); dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize = swpw(dev->config.if_desc[ifno].ep_desc[epno].wMaxPacketSize); - debug_printf("if %d, ep %d\r\n", ifno, epno); + dbg("if %d, ep %d\r\n", ifno, epno); break; default: if (head->bLength == 0) return 1; - debug_printf("unknown Description Type : %x\r\n", head->bDescriptorType); + dbg("unknown Description Type : %x\r\n", head->bDescriptorType); #ifdef USB_DEBUG { unsigned char *ch; @@ -517,8 +517,8 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno) ch = (unsigned char *)head; for (i = 0; i < head->bLength; i++) - debug_printf(" %02X", *ch++); - debug_printf("\r\n"); + dbg(" %02X", *ch++); + dbg("\r\n"); } #endif /* USB_DEBUG */ break; @@ -577,19 +577,19 @@ int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int if (result < 9) { if (result < 0) - debug_printf("unable to get descriptor, error %lX\r\n", dev->status); + dbg("unable to get descriptor, error %lX\r\n", dev->status); else - debug_printf("config descriptor too short (expected %i, got %i)\n", 9, result); + dbg("config descriptor too short (expected %i, got %i)\n", 9, result); return -1; } tmp = swpw(config->wTotalLength); if (tmp > USB_BUFSIZ) { - debug_printf("usb_get_configuration_no: failed to get descriptor - too long: %d\r\n", tmp); + dbg("usb_get_configuration_no: failed to get descriptor - too long: %d\r\n", tmp); return -1; } result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, tmp); - debug_printf("get_conf_no %d Result %d, wLength %d\r\n", cfgno, result, tmp); + dbg("get_conf_no %d Result %d, wLength %d\r\n", cfgno, result, tmp); return result; } @@ -600,7 +600,7 @@ int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int int usb_set_address(struct usb_device *dev) { int res; - debug_printf("set address %d\r\n", dev->devnum); + dbg("set address %d\r\n", dev->devnum); res = usb_control_msg(dev, usb_snddefctrl(dev), USB_REQ_SET_ADDRESS, 0, (dev->devnum), 0, NULL, 0, USB_CNTL_TIMEOUT); return res; } @@ -622,7 +622,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) } if (!if_face) { - debug_printf("selecting invalid interface %d", interface); + dbg("selecting invalid interface %d", interface); return -1; } /* @@ -647,7 +647,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) int usb_set_configuration(struct usb_device *dev, int configuration) { int res; - debug_printf("set configuration %d\r\n", configuration); + dbg("set configuration %d\r\n", configuration); /* set setup command */ res = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION, 0, configuration, 0, NULL, 0, USB_CNTL_TIMEOUT); @@ -781,7 +781,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) tbuf = (unsigned char *)driver_mem_alloc(USB_BUFSIZ); if (tbuf == NULL) { - debug_printf("usb_string: malloc failure\r\n"); + dbg("usb_string: malloc failure\r\n"); return -1; } /* get langid for strings if it's not yet known */ @@ -790,13 +790,13 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) err = usb_string_sub(dev, 0, 0, tbuf); if (err < 0) { - debug_printf("error getting string descriptor 0 (error=%lx)\r\n", dev->status); + dbg("error getting string descriptor 0 (error=%lx)\r\n", dev->status); driver_mem_free(tbuf); return -1; } else if (tbuf[0] < 4) { - debug_printf("string descriptor 0 too short\r\n"); + dbg("string descriptor 0 too short\r\n"); driver_mem_free(tbuf); return -1; } @@ -805,7 +805,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) dev->have_langid = -1; dev->string_langid = tbuf[2] | (tbuf[3] << 8); /* always use the first langid listed */ - debug_printf("USB device number %d default language ID 0x%x\r\n", dev->devnum, dev->string_langid); + dbg("USB device number %d default language ID 0x%x\r\n", dev->devnum, dev->string_langid); } } err = usb_string_sub(dev, dev->string_langid, index, tbuf); @@ -844,8 +844,8 @@ void usb_disconnect(struct usb_device **pdev) if (dev != NULL) { int i; - debug_printf("USB %d disconnect on device %d\r\n", dev->parent->usbnum, dev->parent->devnum); - debug_printf("USB %d disconnected, device number %d\r\n", dev->usbnum, dev->devnum); + dbg("USB %d disconnect on device %d\r\n", dev->parent->usbnum, dev->parent->devnum); + dbg("USB %d disconnected, device number %d\r\n", dev->usbnum, dev->devnum); if (dev->deregister != NULL) dev->deregister(dev); /* Free up all the children.. */ @@ -853,7 +853,7 @@ void usb_disconnect(struct usb_device **pdev) { if (dev->children[i] != NULL) { - debug_printf("USB %d, disconnect children %d\r\n", dev->usbnum, dev->children[i]->devnum); + dbg("USB %d, disconnect children %d\r\n", dev->usbnum, dev->children[i]->devnum); usb_disconnect(&dev->children[i]); dev->children[i] = NULL; } @@ -889,24 +889,28 @@ struct usb_device *usb_get_dev_index(int index, int index_bus) */ struct usb_device *usb_alloc_new_device(int bus_index, void *priv) { - int i, index = dev_index[bus_index]; + int i; + int index = dev_index[bus_index]; struct usb_device *dev; - debug_printf("USB %d new device %d\r\n", bus_index, index); + dbg("USB %d new device %d\r\n", bus_index, index); if (index >= USB_MAX_DEVICE) { - debug_printf("ERROR, too many USB Devices, max=%d\r\n", USB_MAX_DEVICE); + dbg("ERROR, too many USB Devices, max=%d\r\n", USB_MAX_DEVICE); return NULL; } /* default Address is 0, real addresses start with 1 */ dev = &usb_dev[(bus_index * USB_MAX_DEVICE) + index]; dev->devnum = index + 1; dev->maxchild = 0; - for (i = 0; i < USB_MAXCHILDREN; dev->children[i++] = NULL); + for (i = 0; i < USB_MAXCHILDREN; dev->children[i++] = NULL) + ; + dev->parent = NULL; dev->priv_hcd = priv; dev->usbnum = bus_index; dev_index[bus_index]++; + return dev; } @@ -940,7 +944,7 @@ int usb_new_device(struct usb_device *dev) tmpbuf = (unsigned char *) driver_mem_alloc(USB_BUFSIZ); if (tmpbuf == NULL) { - debug_printf("usb_new_device: malloc failure\r\n"); + dbg("usb_new_device: malloc failure\r\n"); return 1; } @@ -957,7 +961,7 @@ int usb_new_device(struct usb_device *dev) err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8); if (err < 8) { - debug_printf("\r\nUSB device not responding, giving up (status=%lX)\r\n", dev->status); + dbg("\r\nUSB device not responding, giving up (status=%lX)\r\n", dev->status); driver_mem_free(tmpbuf); return 1; } @@ -982,7 +986,7 @@ int usb_new_device(struct usb_device *dev) err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); if (err < 0) { - debug_printf("usb_new_device: usb_get_descriptor() failed\r\n"); + dbg("usb_new_device: usb_get_descriptor() failed\r\n"); driver_mem_free(tmpbuf); return 1; } @@ -1002,7 +1006,7 @@ int usb_new_device(struct usb_device *dev) } if (port < 0) { - debug_printf("usb_new_device: cannot locate device's port.\r\n"); + dbg("usb_new_device: cannot locate device's port.\r\n"); driver_mem_free(tmpbuf); return 1; } @@ -1010,7 +1014,7 @@ int usb_new_device(struct usb_device *dev) err = hub_port_reset(dev->parent, port, &portstatus); if (err < 0) { - debug_printf("\r\nCouldn't reset port %d\r\n", port); + dbg("\r\nCouldn't reset port %d\r\n", port); driver_mem_free(tmpbuf); return 1; } @@ -1029,7 +1033,7 @@ int usb_new_device(struct usb_device *dev) err = usb_set_address(dev); /* set address */ if (err < 0) { - debug_printf("\r\nUSB device not accepting new address (error=%lX)\r\n", dev->status); + dbg("\r\nUSB device not accepting new address (error=%lX)\r\n", dev->status); driver_mem_free(tmpbuf); return 1; } @@ -1039,9 +1043,9 @@ int usb_new_device(struct usb_device *dev) if (err < tmp) { if (err < 0) - debug_printf("unable to get device descriptor (error=%d)\r\n", err); + dbg("unable to get device descriptor (error=%d)\r\n", err); else - debug_printf("USB device descriptor short read (expected %i, got %i)\r\n", tmp, err); + dbg("USB device descriptor short read (expected %i, got %i)\r\n", tmp, err); driver_mem_free(tmpbuf); return 1; } @@ -1057,11 +1061,11 @@ int usb_new_device(struct usb_device *dev) /* we set the default configuration here */ if (usb_set_configuration(dev, dev->config.bConfigurationValue)) { - debug_printf("failed to set default configuration len %d, status %lX\r\n", dev->act_len, dev->status); + dbg("failed to set default configuration len %d, status %lX\r\n", dev->act_len, dev->status); driver_mem_free(tmpbuf); return -1; } - debug_printf("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\r\n", + dbg("new device strings: Mfr=%d, Product=%d, SerialNumber=%d\r\n", dev->descriptor.iManufacturer, dev->descriptor.iProduct, dev->descriptor.iSerialNumber); memset(dev->mf, 0, sizeof(dev->mf)); @@ -1073,9 +1077,9 @@ int usb_new_device(struct usb_device *dev) usb_string(dev, dev->descriptor.iProduct, dev->prod, sizeof(dev->prod)); if (dev->descriptor.iSerialNumber) usb_string(dev, dev->descriptor.iSerialNumber, dev->serial, sizeof(dev->serial)); - debug_printf("Manufacturer %s\r\n", dev->mf); - debug_printf("Product %s\r\n", dev->prod); - debug_printf("SerialNumber %s\r\n", dev->serial); + dbg("Manufacturer %s\r\n", dev->mf); + dbg("Product %s\r\n", dev->prod); + dbg("SerialNumber %s\r\n", dev->serial); /* now prode if the device is a hub */ usb_hub_probe(dev, 0); driver_mem_free(tmpbuf); @@ -1604,11 +1608,17 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) struct usb_interface_descriptor *iface; struct usb_endpoint_descriptor *ep; int ret; + iface = &dev->config.if_desc[ifnum]; - /* Is it a hub? */ + + /* Is it a hub? */ if (iface->bInterfaceClass != USB_CLASS_HUB) + { + dbg("iface->bInterfaceClass != USB_CLASS_HUB (%d), %d instead\r\n", USB_CLASS_HUB, iface->bInterfaceClass); return 0; - /* Some hubs have a subclass of 1, which AFAICT according to the */ + } + + /* Some hubs have a subclass of 1, which AFAICT according to the */ /* specs is not defined, but it works */ if ((iface->bInterfaceSubClass != 0) && (iface->bInterfaceSubClass != 1)) return 0; diff --git a/BaS_gcc/usb/usb_mouse.c b/BaS_gcc/usb/usb_mouse.c index 844dd0b..500c8bd 100644 --- a/BaS_gcc/usb/usb_mouse.c +++ b/BaS_gcc/usb/usb_mouse.c @@ -222,24 +222,24 @@ static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum) iface = &dev->config.if_desc[ifnum]; - if (iface->bInterfaceClass != 3) + if (iface->bInterfaceClass != USB_CLASS_HID) { - dbg("iface->bInterfaceClass != 3 (%d instead)\r\n", iface->bInterfaceClass); + dbg("iface->bInterfaceClass != USB_CLASS_HID (%d instead)\r\n", iface->bInterfaceClass); return 0; } - if (iface->bInterfaceSubClass != 1) + if (iface->bInterfaceSubClass != USB_SUB_HID_BOOT) { - dbg("iface->bInterfaceSubClass != 1 (%d instead)\r\n", iface->bInterfaceSubClass); + dbg("iface->bInterfaceSubClass != USB_SUB_HID_BOOT (%d instead)\r\n", iface->bInterfaceSubClass); return 0; } - if (iface->bInterfaceProtocol != 2) + if (iface->bInterfaceProtocol != USB_PROT_HID_MOUSE) { - dbg("iface->bInterfaceProtocol != 2 (%d)\r\n", iface->bInterfaceProtocol); + dbg("iface->bInterfaceProtocol != USB_PROT_HID_MOUSE (%d)\r\n", iface->bInterfaceProtocol); return 0; }