;       SCCSID = @(#)dosibm.asm 6.1 90/11/17
PAGE    ,132
NAME    DOSIBM
TITLE   DOSIBM.ASM - IBM CODE FOR DEBUGGER
.286p

;***    DOSIBM.ASM
;
;       SCCSID = @(#)dosibm.asm 13.8 90/04/17
;

.xlist
;        include dosseg.inc
;        include basemaca.inc
;        include osmaca.inc
        include debseg.inc
        include debmac.inc
        include debequ.inc
        include debinit.inc
        include debdesc.inc
        include debprt.inc
;        include struc.inc
        include abios.inc
.list

Extern checkchr, FAR

;        ReferGlobal     ABIOS_CDA_anchor_p, WORD
;        ReferGlobal     ABIOS_CDA_anchor_r, WORD
;        ReferGlobal     ABIOS_present, BYTE



DataSegmentStart

;
;       ABIOS Device Type Strings
;

ABIOSMsgs       label   word

        dw      dataOFFSET ABIOSmsg             ; 0
        dw      dataOFFSET DSKETTEmsg           ; 1
        dw      dataOFFSET DISKmsg              ; 2
        dw      dataOFFSET VIDEOmsg             ; 3
        dw      dataOFFSET KEYBDmsg             ; 4
        dw      dataOFFSET PRINTmsg             ; 5
        dw      dataOFFSET ASYNCHmsg            ; 6
        dw      dataOFFSET SYSTMRmsg            ; 7
        dw      dataOFFSET RTCTMRmsg            ; 8
        dw      dataOFFSET SYSSmsg              ; 9
        dw      dataOFFSET NMImsg               ; a
        dw      dataOFFSET POINTmsg             ; b
        dw      dataOFFSET LPENmsg              ; c
        dw      dataOFFSET JOYSmsg              ; d
        dw      dataOFFSET CMOSRmsg             ; e
        dw      dataOFFSET DMAmsg               ; f
        dw      dataOFFSET POSmsg               ; 10
        dw      dataOFFSET ELOGmsg              ; 11
        dw      dataOFFSET SADmsg               ; 12
        dw      dataOFFSET IOPmsg               ; 13
        dw      dataOFFSET AUDIOmsg             ; 14
        dw      dataOFFSET INTCmsg              ; 15
        dw      dataOFFSET SECmsg               ; 16


Static  ABIOSmsg,       STRING, "Internal   "
Static  DSKETTEmsg,     STRING, "Diskette   "
Static  DISKmsg,        STRING, "Disk       "
Static  VIDEOmsg,       STRING, "Video      "
Static  KEYBDmsg,       STRING, "Keyboard   "
Static  PRINTmsg,       STRING, "Printer    "
Static  ASYNCHmsg,      STRING  "Asynch     "
Static  SYSTMRmsg,      STRING, "SysTimer   "
Static  RTCTMRmsg,      STRING, "RTCTimer   "
Static  SYSSmsg,        STRING, "SysService "
Static  NMImsg,         STRING, "NMInterrupt"
Static  POINTmsg,       STRING, "PointDevice"
Static  LPENmsg,        STRING, "LightPen   "
Static  JOYSmsg,        STRING, "JoyStick   "
Static  CMOSRmsg,       STRING, "CMOSRam    "
Static  DMAmsg,         STRING, "DMA        "
Static  POSmsg,         STRING, "POS        "
Static  ELOGmsg,        STRING, "ErrorLog   "
Static  SADmsg,         STRING, "S/A Dump   "
Static  IOPmsg,         STRING, "IOPortAlloc"
Static  AUDIOmsg,       STRING, "AudioTone  "
Static  INTCmsg,        STRING, "Int/8259   "
Static  SECmsg,         STRING, "Security   "

;
;   Prints Device ID For a Logical ID
;

DumpDevID   label   word

        OutMsgBitF      0, 0, 16, ABIOSMsgs
        EndOp

str1    db  "ABIOS Not Present or Not Initialized",13,10,0
str2    db  "  LID(",0
str3    db  ")  Type=",0
str4    db  "Null       ",0
str5    db  "Reserved   ",0
str6    db  "  DB=",0
str7    db  "  FTT=",0
DataSegmentEnd



CodeSegmentStart

;***    DumpCDA
;
;       This Dumps the ABIOS Common Data Area
;
;       ENTRY:  NONE
;
;       EXIT:   NONE
;
;       USES:   ALL
;
        assumeDATA <ds, es, ss>

DefProc DumpCDA, NEAR, PUBLIC

LocVar CDASeg,    WORD                      ; Segment with ABIOS data
LocVar NumLids,   WORD                      ; number of Logical IDs in ABIOS
LocVar ThisDevID, WORD                      ; device ID of this LID
LocVar ThisEntry, <size LIDEntry>           ; LID currently being examined
LocVar CDAddrS, <size AddrS>
LocVar TempAddr, <size AddrS>

BeginProc
;    .if <ds:ABIOS_present ne 0> and  near
;    .if <ds:ABIOS_CDA_anchor_p ne 0> near
        lea     bx,[CDAddrS]
        Pcall   FillSelAddr, <bx, 70h, 0ah, 0>  ; point to SAS DD section
        Pcall   GetWord         ; read the offset of the DD section
        add     dx,6            ; plus 6 to point to ABIOS selector
        Pcall   FillSelAddr, <bx, 70h, dx, 0>
        Pcall   GetWord         ; get the selector of the ABIOS data
        mov     CDASeg,dx       ; save it here
        cmp     dx,0
        jnz     @F
        mov     dx,offset str1
        Pcall   rprbuf          ; print error message
        jmp     dcx             ; and end command
;        putstr  <"ABIOS Not Present or Not Initialized", CR, LF>


@@:     Pcall   FillSelAddr, <bx, dx, 0, 0>
        Pcall   GetWordOff, <CDALids, 0>
;        mov     cx, ds:[0].CDALids
        mov     NumLids, dx                 ; save number of LIDs
        xor     dx, dx                      ; (DX) = 0th LID

dc10:
;        mov     ds, CDASeg              ; (DS) = ABIOS segment
        mov     si, dx                  ; (SI) = current LID number
        shl     si, 3                   ; (DS:SI) -> nth LID
        .errnz  (size LIDEntry - 8)

        lea     di, ThisEntry           ; (ES:DI) -> current LID area
        mov     cx, size LIDEntry       ; # of bytes per LID
        lea     bx,[CDAddrS]
        Pcall   GetMemOff, <si, 0>
;        rep     movsw                   ; copy from ABIOS to ThisEntry

        lea     di, ThisEntry           ; (ES:DI) -> current LID area

        cmp     [di].DBSegment,0        ; DBSegment holds #LIDS in LID 0
        jz      @F
        cmp     dx,0
        jz      @F
;        mov     ds, es:[di].DBSegment
;        mov     si, es:[di].DBOffset ;(DS:SI) -> current data block
;        mov     ax, ds:[si].DevID
        push    dx
        lea     bx,[TempAddr]
        Pcall   FillSelAddr, <bx, [di].DBSegment, [di].DBOffset, 0>
        Pcall   GetWordOff <DevID, 0>
        mov     ThisDevID, dx       ; ThisDevID = this LID's devid
        pop     dx

@@:     SaveReg <dx>                    ; save current LID number
        mov     si,dx                   ; keep a copy in si
        mov     dx,offset str2
        Pcall   rprbuf
;        putstr  <"  LID(">              ; Print LID #

        mov     dx,si                   ; get DX back for out16
        Pcall   out16

        mov     dx,offset str3
        Pcall   rprbuf
;      putstr  <")  Type=">            ; Print Device Type

        cmp     [di].DBSegment,0
        jnz     @F
        cmp     [di].FTTSegment,0
        jnz     @F
        mov     dx,offset str4
        Pcall   rprbuf
;        putstr  <"Null       ">

@@:     cmp     si,0
        jnz     @F
        mov     dx,offset str5
        Pcall   rprbuf
;        putstr  <"Reserved   ">

@@:     cmp     [di].DBSegment,0
        jz      @F
        SaveReg <dx,si,di>
        lea     di, ThisDevID
        mov     si, dataOFFSET DumpDevID
        Pcall   OpInterpret
        RestReg <di,si,dx>

@@:     mov     dx,offset str6
        Pcall   rprbuf
;      putstr  <"  DB=">
        mov     dx, [di].DBSegment
        Pcall   out16
        mov     al,":"
        Pcall   put_ch
        mov     dx, [di].DBOffset
        Pcall   out16
        mov     dx,offset str7
        Pcall   rprbuf
;      putstr  <"  FTT=">
        mov     dx, [di].FTTSegment
        Pcall   out16
        mov     al,":"
        Pcall   put_ch
        mov     dx, [di].FTTOffset
        Pcall   out16
        Pcall   crlf                    ; NewLine

        Pcall   checkchr      ; check for stop key
        RestoreReg <dx>                 ; (DX) = current LID number
        inc     dx                      ; Next LID #

        cmp     dx, NumLids                   ; have we printed all LIDs?
        je      dcx                           ; yup, exit
        jmp     dc10                          ; nope, do next one

dcx:

EndProc

CodeSegmentEnd

        end
