BIOS PnP Instalation Check - Please HELP ! 
Author Message
 BIOS PnP Instalation Check - Please HELP !

Quote:

>Please help me with this, I have spend
>one month of thinking and still haven't
>came out with a working code.

If I may quote from Hamlet, "Cudgel thy brains no more about it, ..."

Quote:
>This is about Plug and Play BIOS support Installation
>Check. I am scanning memory between F0000h and
>FFFFFh for "$PnP" signature string. So I sucseeded
>in that.

Actually, to pick a nit, the signature must start on a paragraph
boundary, so the range is F0000h to FFFF0h.

Quote:
>4.8.1 Function 0Bh - Get APM ID Table
>Synopsis:
>int FAR (*entryPoint)(Function, Bufsize, ApmIdTable, BiosSelector);
>int Function; /* PnP BIOS Function 0Bh */
>unsigned int FAR *BufSize; /* Size of buffer to copy APM ID table to */
>unsigned char FAR *ApmIdTable; /* Address of caller's buffer for the table */
>unsigned int BiosSelector; /* PnP BIOS readable/writable selector */

The BiosSelector is the data pointer which was returned to you in the
PnP header structure.  The ApmIdTable is the buffer into which the ID
table is to be copied, and BufSize is the size of that buffer.  Here's
a DOS program which shows a working real mode version of the code:

-+--- shownodes.c begins
; getnodes.asm
comment ^
  searches for a Plug & Play header within the BIOS area, and
  prints the APM ID table obtained from PnP.
^
        .model small
        .386
        .stack 200h

        .data
pnpheader struc
        signature      dd  ?
        pnpversion     db  ?
        headerlen      db  ?
        controlfield   dw  ?
        checksum       db  ?
        eventflag      dd  ?
        RMentryoffset  dw  ?
        RMentrysegment dw  ?
        PM16offset     dw  ?
        PM16segbase    dd  ?
        OEM            dd  ?
        RMdatasegment  dw  ?
        PMdatasegbase  dd  ?
        reserved       db  ?
ends
        MAXDEVICES equ 25
        BUFFERSIZE equ 6 * MAXDEVICES
        buffsize dw BUFFERSIZE
        buffer   db BUFFERSIZE dup (?)
        .code
Start proc

        mov     ds,di
        call    FindPnPHeader
        jc      ErrorExit
        call    VerifyPnPHeader
        jc      ErrorExit

        push    es:[pnpheader ptr di].RMdatasegment
        push    ds                      ; push seg,offset of buffer
        push    offset buffer           ;
        push    ds                      ; push seg,offset of buffer
size
        push    offset buffsize         ;
        push    0Bh                     ; GetAPMIDInfo function number
        call    dword ptr es:[pnpheader ptr di].RMentryoffset
        add     sp,12                   ; clean up the stack
        jc      ErrorExit

        mov     si,offset buffer        ; ds:si points to buffer
        mov     cx,BUFFERSIZE           ; cx = buffer size
        call    PrintAPMTable           ;

ErrorExit:
        mov     ax,4c00h
        int     21h
Start endp

;
; searches paragraph boundaries from F0000h to FFFF0h for the PnP
signature
;
; returns
;       if CY set,
;               signature not found
;       if CY clear,
;              es:di points to $PnP signature
;
FindPnPHeader proc
        mov     eax,'PnP$'      ; signature is actually "$PnP"
        mov     di,0f000h
        mov     es,di
        xor     di,di
nextParagraph:
        cmp     es:[di],eax
        jz      FoundIt
        add     di,10h
        jnz     nextParagraph
FoundIt:
        ret
FindPnPHeader endp

;
; given the address of a suspected PnP header in es:di, this
; routine verifies the checksum
;
; returns
;       if CY set,
;               header not valid
;       if CY clear
;               this is a valid PnP header
;
VerifyPnPHeader proc
        push    ax
        push    cx
        push    di
        xor     cx,cx
        xor     ax,ax
        mov     cl,es:[pnpheader ptr di].headerlen
nextbyte:
        add     al,es:[di]
        inc     di
        loop    nextbyte
        add     al,0ffh                 ; sets carry unless al was
zero
        pop     di
        pop     cx
        pop     ax
        ret
VerifyPnPHeader endp

;
; prints the passed APM table
;
;
PrintAPMTable proc
        lodsw                           ; load first word
        cmp     ax,0                    ; is it zero?
        jz      done                    ;
        xchg    al,ah                   ; swap bytes

        rol     ax,6                    ; print first char
        call    UnpackChar              ;

        rol     ax,5                    ; print second char
        call    UnpackChar              ;

        rol     ax,5                    ; print third char
        call    UnpackChar              ;

        lodsw                           ;
        xchg    al,ah                   ; swap bytes
        call    PrintHexWord            ; print 4 digits
        mov     al,' '                  ;
        call    PrintChar               ;
        mov     al,'='                  ;
        call    PrintChar               ;
        mov     al,' '                  ;
        call    PrintChar               ;
        lodsw                           ;
        call    PrintHexWord            ;
        mov     al,0dh                  ;
        call    PrintChar               ;
        mov     al,0ah                  ;
        call    PrintChar               ;
        sub     cx,6                    ; keep track of buffer size
        jnb     PrintAPMTable           ;

done:
        ret
PrintAPMTable endp

PrintHexWord proc
        rol     ax,4                    ;
        call    PrintHexDigit           ;
        rol     ax,4                    ;
        call    PrintHexDigit           ;
        rol     ax,4                    ;
        call    PrintHexDigit           ;
        rol     ax,4                    ;
        call    PrintHexDigit           ;
        ret                             ;
PrintHexWord endp

PrintHexDigit proc
        push    ax                      ;
        and     al,0fh                  ;
        add     al,90h                  ;
        daa                             ;
        adc     al,40h                  ;
        daa                             ;
        call    PrintChar               ;
        pop     ax                      ;
        ret                             ;
PrintHexDigit endp

UnpackChar proc
        push    ax                      ;
        and     al,1fh                  ; use low five bits only
        add     al,40h                  ; convert to character
        call    PrintChar               ;
        pop     ax                      ;
        ret                             ;
UnpackChar endp

PrintChar proc
        mov     dl,al                   ;
        mov     ah,06h                  ; print single char to STDOUT
        int     21h
        ret
PrintChar endp

        end Start
-+--- shownodes.c end

The code isn't well commented, but it was put together rather quickly.
One thing may require a bit more explanation.  The function fills the
buffer with a table of six-byte entries.  Their structure is:

Device_ID dd ?
APM_device dw ?

The Device_ID is a compressed form of the PNP 7-byte product ID
string.  As an example, on my laptop, this function puts the following
six bytes into the buffer: 41 D0 09 30 FF 01.  The last two bytes are
the APM_device, which is 01FFh (the display device) in this case.  To
decode the Device_ID, start from the first byte, 41h and throw away
the first bit (which should always be zero).  Then get the next five
bits and add 40h to get a printable ASCII letter.  Repeat this twice
for a total of three letters, and then get the four digits by reading
in the bits four at a time.  In this case, 41 D0 09 30 translates into
the string "PNP0930" which corresponds to a Chips and Technologies
Super VGA display.

Ed



Tue, 29 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Pmode interface in PNP BIOS

2. PnP BIOS

3. BIOS listing...Please help

4. Help with BIOS data area please??

5. Help with Windex instalation

6. HELP PLEASE?? - Check for files in a directory

7. please, please, please, please, help

8. Naive polymorphic type checking - please help

9. will someone please, please, please, please HELP me?!!

10. Summary Printer check - BIOS/DOS - various languages

11. VSE 3.1 Repository Problem: Please help (please please?)

12. PLEASE PLEASE PLEASE HELP !!!!!!!!!!!!

 

 
Powered by phpBB® Forum Software