English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. System (https://eab.abime.net/forumdisplay.php?f=113)
-   -   card.resource wtf (https://eab.abime.net/showthread.php?t=89431)

mark_k 12 November 2017 13:26

card.resource wtf
 
I've been looking at the code of card.resource after reading this thread. I checked v37.11 in A600 Kickstart 37.350 and v40.4 in A600 Kickstart 40.63. [There's also a loadable (with LoadModule) card.resource v43.1 linked in this post. Is that official? Where did it come from?]

Are there any known bugs/problems with PCMCIA cards (i.e. card.resource) in Kickstart 3.1? Because there definitely seems to be a bug in versions 40.4 and 43.1.

The initialisation routine is supposed to open timer.device. v37.11 code does that, but in v40.4:
Code:

        LEA        (ReplyPort-LibBase,A5),A0
        MOVEA.L        A0,A3
        MOVEQ        #IOTV_SIZE,D0
        JSR        (_LVOCreateIORequest,A6)
        MOVE.L        D0,(_SomeIORequest-LibBase,A5)
        MOVEA.L        D0,A1        ;IORequest
        SUBA.L        A0,A0        ;Device name pointer 0!!! Should point to "timer.device"
        MOVEQ        #UNIT_VBLANK,D0        ;Unit
        MOVEQ        #0,D1        ;Flags
        JSR        (_LVOOpenDevice,A6)

        LEA        (TaskStruct-LibBase,A5),A1
        MOVE.L        A1,(MP_SIGTASK,A3)

Then later on the task code issues TR_ADDREQUEST:
Code:

TaskCode
        MOVEA.L        (4,SP),A5
        MOVEA.L        (_SysBase-LibBase,A5),A6
        MOVEQ        #31,D0
        JSR        (_LVOAllocSignal,A6)
        BRA.B        lbC000678

lbC000644
        BSR.W        lbC000586
        SUBQ.B        #1,(IDNestCnt,A6)
        BGE.B        lbC000656

        MOVE.W        #$C000,(_custom+intena).L
lbC000656
        BSET        #1,(lbB001022-LibBase,A5)
        BNE.B        lbC000678

        MOVEA.L        (_SomeIORequest-LibBase,A5),A1
        MOVE.W        #TR_ADDREQUEST,(IO_COMMAND,A1)
        CLR.L        (IOTV_TIME,A1)
        MOVE.L        #100000,(IOTV_TIME+TV_MICRO,A1)        ;1/10 second
        JSR        (_LVOSendIO,A6)

lbC000678
        MOVE.L        #$80000000,D0
        JSR        (_LVOWait,A6)
        LEA        (ReplyPort-LibBase,A5),A0
        JSR        (_LVOGetMsg,A6)
        TST.L        D0
        BEQ.B        lbC000656

        BCLR        #1,(lbB001022-LibBase,A5)
        LEA        (SomeList-LibBase,A5),A0

How can that not crash?

phx 14 November 2017 10:50

Quote:

Originally Posted by mark_k (Post 1198926)
The initialisation routine is supposed to open timer.device. v37.11 code does that, but in v40.4:
Code:

    LEA    (ReplyPort-LibBase,A5),A0
    MOVEA.L    A0,A3
    MOVEQ    #IOTV_SIZE,D0
    JSR    (_LVOCreateIORequest,A6)
    MOVE.L    D0,(_SomeIORequest-LibBase,A5)
    MOVEA.L    D0,A1    ;IORequest
    SUBA.L    A0,A0    ;Device name pointer 0!!! Should point to "timer.device"
    MOVEQ    #UNIT_VBLANK,D0    ;Unit
    MOVEQ    #0,D1    ;Flags
    JSR    (_LVOOpenDevice,A6)


That's a shortcut used in the ROM to eliminate the many references to "timer.device" and "input.device" strings (probably to save space?).
OpenDevice() with name=0 means "timer.device" and name=1 means "input.device".

mark_k 14 November 2017 14:19

Thanks, I didn't know that! Do you know whether that behaviour was documented anywhere?

phx 14 November 2017 17:46

I don't remember having seen it documented anyhere. I discovered that by looking into the exec/OpenDevice function.

In any case it is not in the official Autodocs. ;)


All times are GMT +2. The time now is 03:56.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.06538 seconds with 11 queries