⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nruntime.asm

📁 AMI 主板的BIOS源码。
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        ret
el2c_1:
        call    enable_l2_cache_wt
el2c_2:
        pop     ax
        ret
;-----------------------------------------------------------------------;
;                       GET_PIO_MODE_VALUE                              ;
;-----------------------------------------------------------------------;
;  this routine returns the highest PIO mode supported by the hard disk.;
;  input :                                                              ;
;       ds:bx   ptr to buffer containing the output of indentify drive  ;
;               command                                                 ;
;  output:                                                              ;
;       bl      mode value                                              ;
;       si      = 0000..drive supports IORDY                            ;
;               = FFFF..drive does not support IORDY                    ;
;  register destroyed : BX SI                                           ;
;-----------------------------------------------------------------------;
        public  get_pio_mode_value
get_pio_mode_value      proc    near
        push    di
        push    cx
        push    ax
        push    dx

        mov     di,bx                   ; DS:DI = ptr to buffer
        xor     si,si                   ; SI = 0000..drive does not support IORDY

        mov     bl,ds:byte ptr [di+51*2+1]; bit15-8 of word 51 = mode
        test    ds:byte ptr [di+53*2],02h; bit-1 of word 53 = 1 ?
        jz      pio_00                  ; word 64-70 are not valid

        test    ds:byte ptr [di+49*2+1],08h; bit-11 of word 49 = 1 ?
        jz      pio_no_iordy            ; no, drive does not support IORDY
        mov     si,0ffffh               ; SI = FFFF...drive supports IORDY
pio_no_iordy:

        mov     al,ds:byte ptr [di+64*2]; Get Advanced PIO mode value

        test    al,02h                  ; bit1 = 1 Mode 4 ?
        jnz     pio_mode_4              ; yes..

        test    al,01h                  ; bit0 = 1 Mode 3 ?
        jz      pio_00                  ; no..

        mov     bl,3                    ; Advanced PIO mode = 3
        jmp     short pio_00

pio_mode_4:
        mov     bl,4

pio_00:
        pop     dx
        pop     ax
        pop     cx
        pop     di
        ret
get_pio_mode_value      endp
COMMENT ~
pio_bit_check_table     label   byte
        db      01h             ; bit-0 for mode-0
        db      02h             ; bit-1 for mode-1
        db      04h             ; bit-2 for mode-2 to mode-4
        db      04h             ; bit-2 for mode-2 to mode-4
        db      04h             ; bit-2 for mode-2 to mode-4

        public  get_pio_mode_value
get_pio_mode_value      proc    near
        push    di
        push    cx
        push    ax
        mov     di,bx                   ; DS:DI = ptr to buffer
        xor     si,si                   ; SI = 0000..drive does not support IORDY
        test    ds:byte ptr [di+53*2],02h; bit-1 of word 53 = 1 ?
        jnz     pio_10                  ; word 64-70 are valid
pio_02:
        mov     bl,ds:byte ptr [di+51*2+1]; bit15-8 of word 51 = mode
;  word 64-67 are NOT valid..
;  BL = mode value..
        push    bx
        mov     al,bl
        mov     bx,offset cgroup:pio_bit_check_table
        xlat    cgroup:pio_bit_check_table; AL = bit to be checked
        pop     bx
;;;     test    ds:byte ptr [di+01h],al ; bit set ?
;;;     jnz     pio_00
;;;     mov     bl,00h                  ; force mode-0
;  BL = mode value..
        jmp     short pio_00
pio_10:
        mov     ax,ds:word ptr [di+67*2]; cycle time without IORDY
        call    get_pio_mode_from_cycle_time; BL = PIO mode
        test    ds:byte ptr [di+49*2+1],08h; bit-11 of word 49 = 1 ?
        jz      pio_00                  ; no, drive does not support IORDY
;  drive supports IORDY
        mov     ax,ds:word ptr [di+68*2]; cycle time with IORDY
        call    get_pio_mode_from_cycle_time; BL = PIO mode
;  AX = cycle time, BL = calculated mode
;  calculated mode value >= 3, check bit7-0 of word 64
;  bit7-0 of word 64 is bit map definition..
;       bit-0 = 1..mode 3 supported
;       bit-1 = 1..mode 4 supported
        mov     cl,bl
        sub     cl,03h
        jb      pio_01                  ; < mode 3, no need to check word 64
        mov     ch,1
        shl     ch,cl
        test    ds:byte ptr [di+64*2],ch; bit-x of word 64 = 0 ?
        jz      pio_02                  ; drive does not support advanced PIO mode
pio_01:
        mov     si,0ffffh               ; SI = FFFF...drive supports IORDY
pio_00:
        pop     ax
        pop     cx
        pop     di
        ret
get_pio_mode_value      endp
;---------------------------------------;
get_pio_mode_from_cycle_time:
;  input :  AX = cycle time
;  output:  BL = mode
;  register destroyed..BX
        xor     bx,bx
        or      ax,ax                   ; cycle time = 00 => mode 0
        jz      gmfct_00
        cmp     ax,383
        ja      gmfct_00                ; mode 0
        inc     bx
        cmp     ax,240
        ja      gmfct_00                ; mode 1
        inc     bx
        cmp     ax,180
        ja      gmfct_00                ; mode 2
        inc     bx
        cmp     ax,120
        ja      gmfct_00                ; mode 3
        inc     bx                      ; mode 4
gmfct_00:
        ret
;---------------------------------------;
get_pio_cycle_time_from_mode:
;  input :  BL = mode
;  output:  AX = cycle time
;  register destroyed..AX
        mov     ax,120
        cmp     bl,4
        ja      gctfm_01                ; invalid mode, assume 600ns
        jz      gctfm_00                ; mode 4, 120ns
        mov     ax,180
        cmp     bl,3
        jz      gctfm_00                ; mode 3, 180ns
        mov     ax,240
        cmp     bl,2
        jz      gctfm_00                ; mode 2, 240ns
        mov     ax,383
        cmp     bl,1
        jz      gctfm_00                ; mode 1, 383ns
gctfm_01:
        mov     ax,600                  ; mode 0, 600ns
gctfm_00:
        ret
~
;-----------------------------------------------------------------------;
;                       GET_DMA_MODE_VALUE                              ;
;-----------------------------------------------------------------------;
;  this routine returns the highest DMA mode supported by the hard disk.;
;  input :                                                              ;
;       ds:bx   ptr to buffer containing the output of indentify drive  ;
;               command                                                 ;
;  output:                                                              ;
;       ECX     Bit15-8 (CH) Non-Sync DMA mode information              ;
;                               = 00 Non-Sync DMA not supported         ;
;                               <>00 Non-Sync DMA mode                  ;
;               Bit31-24 Sync DMA mode information                      ;
;                               = 00 Sync DMA not supported             ;
;                               <>00 Sync DMA mode                      ;
;  register destroyed : ECX Bit33-8 (i.e. CL can NOT be destroyed)      ;
;-----------------------------------------------------------------------;
        public  get_dma_mode_value
get_dma_mode_value      proc    near
        push    si
        push    ax
        push    cx
;  DS:BX = ptr to buffer

;;;;    mov     ch,00h                  ; init DMA mode value
        xor     ecx,ecx                 ; init DMA mode value

        test    ds:byte ptr [bx+49*2+1],01h; Non-Sync DMA supported ?
        jz      short check_sync_dma    ; no
        mov     ch,ds:byte ptr [bx+52*2+1]; bit15-8 of word 52 = single word Non-Sync DMA mode
        test    ds:byte ptr [bx+53*2],02h; bit-1 of word 53 = 1 ?
        jnz     short non_sync_dma_00   ; word 64-70 are valid
;  word 64-67 are NOT valid..
;  CH = single word Non-Sync DMA mode value..
        cmp     ch,02h                  ; maxm is single word Non-Sync DMA mode-2
        jbe     short non_sync_dma_01   ; valid Non-Sync DMA mode
        mov     ch,00h                  ; force Non-Sync DMA mode-0
        jmp     short non_sync_dma_01
non_sync_dma_00:
;  word 64-67 are valid..
        mov     al,ds:byte ptr [bx+62*2]; single word Non-Sync DMA transfer capibility
        call    get_dma_mode_from_capibility; CL = Non-Sync DMA mode
        push    cx
        mov     ax,ds:word ptr [bx+65*2]; multiword Non-Sync DMA cycle time
        mov     si,offset cgroup:non_sync_dma_mode_time_table
        call    get_dma_mode_from_cycle_time; CL = Non-Sync DMA mode
;  CL = multiword Non-Sync DMA mode, check this value with word 63
;  bit7-0 of word 63 is bit map definition..
;       bit-0 = 1..multiword mode 0 supported
;       bit-1 = 1..multiword mode 1 supported
;       bit-2 = 1..multiword mode 2 supported
        mov     al,1
        shl     al,cl
        test    ds:byte ptr [bx+63*2],al; bit-x of word 63 = 0 ?
        pop     ax                      ; AL = single word Non-Sync DMA mode
        jz      short non_sync_dma_02   ; drive does not support multiword Non-Sync DMA mode
        mov     ch,cl
        or      ch,20h                  ; bit-5 = 1..multi word Non-Sync DMA
        jmp     short check_sync_dma
non_sync_dma_02:
;  drive does not support found multiword Non-Sync DMA mode
        mov     ch,al                   ; use single word Non-Sync DMA mode
non_sync_dma_01:
        or      ch,10h                  ; bit-4 = 1..single word Non-Sync DMA
check_sync_dma:
;  CH = Non-Sync DMA information
;  check for Sync DMA
        rol     ecx,16
;----------------------------------------;
COMMENT ~               this code is according to Intel Spec Sep 20, 1996.
;                       Spec is changed in ATA Untra-DMA spec Oct 26, 1996.
        test    ds:byte ptr [bx+53*2],04h; bit-2 of word 53 = 1 ?
        jz      short sync_dma_00       ; word 84-85 are NOT valid, Sync DMA not supported
;  word 84-85 are valid..Sync DMA supported
        mov     ax,ds:word ptr [bx+85*2]; Sync DMA cycle time
        mov     si,offset cgroup:sync_dma_mode_time_table
        call    get_dma_mode_from_cycle_time; CL = Sync DMA mode
;  CL = Sync DMA mode, check this value with word 84
;  bit7-0 of word 84 is bit map definition..
;       bit-0 = 1..Sync DMA mode 0 supported
;       bit-1 = 1..Sync DMA mode 1 supported
;       bit-2 = 1..Sync DMA mode 2 supported
        mov     al,1
        shl     al,cl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -