Changeset 32

Show
Ignore:
Timestamp:
08/02/09 04:39:28 (3 years ago)
Author:
brandonlw
Message:

Committing the start of some direct USB code

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/page00/boot.asm

    r31 r32  
    474474       cp skGraphvar 
    475475       jr z,StartBootLoader 
    476 $$:    ld hl,0 
    477        ld (appBackUpScreen+50),hl 
    478        ld (appBackUpScreen+52),hl 
    479        set indicRun,(iy+indicFlags) 
     476$$:    set indicRun,(iy+indicFlags) 
    480477       ld hl,1 
    481478       ld (curRow),hl 
     
    502499       ld (curRow),hl 
    503500       call DispHexA 
    504        cp 36h 
    505        jr z,waitOnByte 
    506501       cp 37h 
    507502       jr nz,notKey 
     
    513508       call z,PowerOff 
    514509       jr $B 
    515 waitOnByte: 
    516        di 
    517        res curAble,(iy+curFlags) 
    518        ld hl,(curRow) 
    519        push hl 
    520        ld hl,handler 
    521        call APP_PUSH_ERRORH 
    522        ld hl,2 
    523        ld (curRow),hl 
    524        ld a,6 
    525        call PutC 
    526        B_CALL Rec1stByteNC 
    527        call DispHexA 
    528        B_CALL RecAByteIO 
    529        call DispHexA 
    530        B_CALL RecAByteIO 
    531        call DispHexA 
    532        B_CALL RecAByteIO 
    533        call DispHexA 
    534        call APP_POP_ERRORH 
    535 handler: 
    536        pop hl 
    537        ld (curRow),hl 
    538        res indicOnly,(iy+indicFlags) 
    539        set curAble,(iy+curFlags) 
    540        jr $B 
    541510sTest: 
    542511       DB "This is a test!",0 
    543512 
    544513StartBootLoader: 
     514;TODO: this whole thing eventually needs to run from sector 70h or wherever I back myself up to 
    545515       res indicOnly,(iy+indicFlags) 
    546516       res curAble,(iy+curFlags) 
  • trunk/page00/jumptable.asm

    r17 r32  
    6161       DB 7Ch 
    6262_HandleUSBACablePluggedIn: 
     63       call Page0Call 
    6364       DW HandleUSBACablePluggedIn 
    6465       DB 02h 
    6566_HandleUSBACableUnplugged: 
     67       call Page0Call 
    6668       DW HandleUSBACableUnplugged 
    6769       DB 02h 
    6870_HandleUSBBCablePluggedIn: 
     71       call Page0Call 
    6972       DW HandleUSBBCablePluggedIn 
    7073       DB 02h 
    7174_HandleUSBBCableUnplugged: 
     75       call Page0Call 
    7276       DW HandleUSBBCableUnplugged 
    7377       DB 02h 
    7478_HandleUSBInterruptInitialize: 
     79       call Page0Call 
    7580       DW HandleUSBInterruptInitialize 
    7681       DB 02h 
    7782_HandleDefaultUSBInterrupt: 
     83       call Page0Call 
    7884       DW HandleDefaultUSBInterrupt 
    7985       DB 02h 
    8086_ReadUSBInterruptData: 
     87       call Page0Call 
    8188       DW ReadUSBInterruptData 
    8289       DB 02h 
  • trunk/page02/02base.asm

    r9 r32  
    22 SEGMENT PAGE02 
    33 
     4 include "includes\os2.inc" 
     5 
    46 PUBLIC HandleUSBInterruptInitialize,HandleDefaultUSBInterrupt,ReadUSBInterruptData 
    57 PUBLIC HandleUSBACablePluggedIn,HandleUSBACableUnplugged,HandleUSBBCablePluggedIn,HandleUSBBCableUnplugged 
     8 EXTERN PutC 
    69 
    710;TODO: deal with all these USB events, somehow 
    811HandleUSBACablePluggedIn: 
    912HandleUSBACableUnplugged: 
     13       ret 
     14 
    1015HandleUSBBCablePluggedIn: 
     16       set useUSB,(iy+linkFlags) 
     17       ld a,2 
     18       ld (9C28h),a 
     19       ld a,80h 
     20       out (57h),a 
     21       xor a 
     22       out (4Ch),a 
     23       ld a,1 
     24       out (5Bh),a 
     25       xor a 
     26       in a,(4Ch) 
     27       ld a,2 
     28       out (54h),a 
     29       ld a,20h 
     30       out (4Ah),a 
     31       xor a 
     32       out (4Bh),a 
     33       in a,(3Ah) 
     34       bit 3,a 
     35       jr z,$F 
     36       ld a,20h 
     37       out (4Bh),a 
     38$$:    xor a 
     39       out (54h),a 
     40       ld b,1 
     41       call WaitTimerBms 
     42       in a,(3Ah) 
     43       bit 3,a 
     44       jr z,$F 
     45       ld a,44h 
     46       out (54h),a 
     47$$:    ld a,0C4h 
     48       out (54h),a 
     49       ld a,8 
     50       out (4Ch),a 
     51       ld de,0FFFFh 
     52$$:    call DecreaseCounter 
     53       jr z,killUSBscfRet 
     54       in a,(4Ch) 
     55       cp 1Ah 
     56       jr z,$F 
     57       cp 5Ah 
     58       jr z,$B 
     59$$:    ld a,0FFh 
     60       out (87h),a 
     61       xor a 
     62       out (92h),a 
     63       in a,(87h) 
     64       ld a,0Eh 
     65       out (89h),a 
     66       xor a 
     67       ld (9C26h),a 
     68       ld (9C27h),a 
     69       ld a,5 
     70       out (8Bh),a 
     71       ld a,5 
     72       ld (9C28h),a 
     73       in a,(8Fh) 
     74       bit 2,a 
     75       jr z,$F 
     76       in a,(81h) 
     77       or 2 
     78       out (81h),a 
     79       call WaitTimer20ms 
     80       jr continue 
     81$$:    in a,(81h) 
     82       or 1 
     83       out (81h),a 
     84continue: 
     85       in a,(54h) 
     86       or 1 
     87       out (54h),a 
     88       ret 
     89 
    1190HandleUSBBCableUnplugged: 
     91       ret 
     92 
    1293HandleUSBInterruptInitialize: 
     94       in a,(4Dh) 
     95       bit 5,a 
     96       jr nz,handleFinalPeriphInit 
     97       ld a,20h 
     98       out (57h),a 
     99       in a,(4Ch) 
     100       cp 5Ah 
     101       ret z 
     102       cp 1Ah 
     103       ret z 
     104       ld a,4 
     105       ld (9C28h),a 
     106       xor a 
     107       out (4Ch),a 
     108       ld a,1 
     109       out (5Bh),a 
     110       xor a 
     111       in a,(4Ch) 
     112       ld a,2 
     113       out (54h),a 
     114       ld a,20h 
     115       out (4Ah),a 
     116       ;TODO: finish this...it's 7AM and I've been at this all night... 
     117       ret 
     118handleFinalPeriphInit: 
     119       set 5,(iy+1Bh) 
     120       ld a,2 
     121       ld (9C28h),a 
     122       ld a,80h 
     123       out (57h),a 
     124       xor a 
     125       out (4Ch),a 
     126       ld a,1 
     127       out (5Bh),a 
     128       ld a,2 
     129       out (54h),a 
     130       ld a,20h 
     131       out (4Ah),a 
     132       call ScrewWithUSBPorts 
     133       ld a,8 
     134       out (4Ch),a 
     135       ld de,0FFFFh 
     136$$:    call DecreaseCounter 
     137       jr z,die 
     138       in a,(4Ch) 
     139       cp 1Ah 
     140       jr z,$F 
     141       cp 5Ah 
     142       jr nz,$B 
     143$$:    ld a,0FFh 
     144       out (87h),a 
     145       xor a 
     146       out (92h),a 
     147       ld a,0Eh 
     148       out (89h),a 
     149       xor a 
     150       ld (9C26h),a 
     151       ld (9C27h),a 
     152       ld a,5 
     153       out (8Bh),a 
     154       ;TODO: finish this...it's 7:30AM and I've been at this all night... 
     155       ret 
     156die: 
     157ScrewWithUSBPorts: 
     158       ret 
     159 
    13160HandleDefaultUSBInterrupt: 
     161       di 
     162       bit 3,(iy+41h) 
     163       ret nz 
     164       in a,(8Fh) 
     165       bit 7,a 
     166       jr nz,killUSBInterruptsError 
     167       xor a 
     168       out (5Bh),a 
     169       ld a,20h 
     170       out (57h),a 
     171       ld a,(9C28h) 
     172       cp 4 
     173       jr nz,setUSBErrorStateAndStuff 
     174       ld a,1 
     175       ld (9C28h),a 
     176       ld b,50 
     177       call WaitTimerBms 
     178       ld a,1 
     179       out (5Bh),a 
     180       res 0,(iy+41h) 
     181       ret 
     182 
     183killUSBInterruptsError: 
     184       ld a,6 
     185       ld (9C28h),a 
     186       xor a 
     187       out (5Bh),a 
     188       jr setUSBErrorStateAndStuff 
     189 
    14190ReadUSBInterruptData: 
    15191       ret 
    16192 
     193DecreaseCounter: 
     194       dec de 
     195       ld a,d 
     196       or e 
     197       ret 
     198 
     199WaitTimer20ms: 
     200       ld b,2 
     201WaitTimerBms: 
     202       push hl 
     203       ld a,42h 
     204       out (36h),a 
     205       xor a 
     206       out (37h),a 
     207       ld a,b 
     208       out (38h),a 
     209       ld hl,0 
     210$$:    inc hl 
     211       in a,(4) 
     212       bit 7,a 
     213       jr z,$B 
     214       pop hl 
     215       ret 
     216 
     217killUSBscfRet: 
     218       xor a 
     219       out (5Bh),a 
     220setUSBErrorStateAndStuff: 
     221       in a,(4Dh) 
     222       bit 5,a 
     223       jr nz,$F 
     224       xor a 
     225       out (4Ch),a 
     226       res 6,(iy+41h) 
     227       jr continueFail 
     228$$:    ld b,8 
     229       in a,(4Dh) 
     230       bit 6,a 
     231       jr nz,$F 
     232       ld b,0 
     233$$:    ld a,b 
     234       out (4Ch),a 
     235continueFail: 
     236       ld a,2 
     237       out (54h),a 
     238       in a,(39h) 
     239       and 0F8h 
     240       out (39h),a 
     241       ld a,6 
     242       ld (9C28h),a 
     243       in a,(4Dh) 
     244       bit 5,a 
     245       jr nz,fail2 
     246       ld de,0FFFFh 
     247$$:    call DecreaseCounter 
     248       jr z,failUSBGood 
     249       in a,(4Dh) 
     250       bit 7,a 
     251       jr z,$B 
     252       in a,(4Dh) 
     253       bit 0,a 
     254       jr z,$B 
     255       ld a,22h 
     256       out (57h),a 
     257       scf 
     258       ret 
     259fail2: in a,(4Dh) 
     260       bit 6,a 
     261       jr nz,$F 
     262       xor a 
     263       out (4Ch),a 
     264       ld a,50h 
     265       jr fail3 
     266$$:    ld a,93h 
     267fail3: out (57h),a 
     268       scf 
     269       ret 
     270failUSBGood: 
     271       scf 
     272       ei 
     273       ld a,1 
     274       out (5Bh),a 
     275       res 0,(iy+41h) 
     276       ret 
     277