Changeset 86 in xtideuniversalbios


Ignore:
Timestamp:
Jan 25, 2011, 9:13:56 PM (13 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Size optimizations in various files in the XTIDE BIOS.
Also added a new include file for generic macros (macros.inc).

Location:
trunk/XTIDE_Universal_BIOS
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm

    r35 r86  
    1 ; File name     :   HError.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   30.11.2007
    4 ; Last update   :   24.8.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Error checking functions for BIOS Hard disk functions.
    73
     
    3430ALIGN JUMP_ALIGN
    3531HError_ProcessErrorsAfterPollingBSY:
     32%ifndef USE_186
    3633    call    HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
    3734    jmp     SHORT GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
     35%else
     36    push    GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
     37    ; Fall through to HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
     38%endif
    3839
    3940
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm

    r35 r86  
    1 ; File name     :   HIRQ.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   11.12.2009
    4 ; Last update   :   24.8.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Interrupt handling related functions.
    73
     
    4137    LOAD_BDA_SEGMENT_TO ds, ax          ; Zero AX
    4238    cli                                 ; Disable interrupts
    43     cmp     al, [ds:BDA.bHDTaskFlg]     ; Task flag already set?
     39    cmp     al, [BDA.bHDTaskFlg]        ; Task flag already set?
    4440    jc      SHORT .ReturnFromWaitNotify ;  If so, skip OS notification
    4541
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm

    r28 r86  
    1 ; File name     :   HPIO.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   14.12.2007
    4 ; Last update   :   1.8.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   PIO transfer functions.
    73
    84; Structure containing variables for PIO transfer functions
    9 struc PIOVARS
     5struc PIOVARS, -6
    106    .fnXfer         resb    2   ; Offset to transfer function
    117    .wBlockSize     resb    2   ; Block size in WORDs
     
    6359    ; Create PIOVARS to stack
    6460    eENTER  PIOVARS_size, 0
    65     sub     bp, BYTE PIOVARS_size           ; SS:BP now points to PIOVARS
     61
    6662    push    si
    6763    mov     si, g_rgfnPioRead               ; Offset to read function lookup
     
    7571
    7672    ; Destroy stack frame
    77     rcl     al, 1                           ; CF to AL bit 0
    78     add     bp, BYTE PIOVARS_size
    7973    eLEAVE
    80     rcr     al, 1                           ; Restore CF
    8174    mov     di, bx                          ; Restore DI
    8275    pop     es
     
    158151.BlockLoop:
    159152    call    HStatus_WaitIrqOrDrq        ; Wait until ready to transfer
    160     jc      SHORT .RetError             ; Return if error (code in AH)
     153    jc      SHORT HPIO_WriteToDrive.RetError    ; Return if error (code in AH)
    161154    mov     cx, [bp+PIOVARS.wBlockSize] ; Load block size
    162155    sub     [bp+PIOVARS.wWordsLeft], cx ; Transferring last (possibly partial) block?
     
    169162    call    [bp+PIOVARS.fnXfer]         ; Transfer possibly partial block
    170163    jmp     HStatus_WaitBsyDefTime      ; Check for errors
    171 .RetError:
    172     ret
    173164
    174165
     
    195186    ; Create PIOVARS to stack
    196187    eENTER  PIOVARS_size, 0
    197     sub     bp, BYTE PIOVARS_size           ; SS:BP now points to PIOVARS
     188
    198189    mov     si, g_rgfnPioWrite              ; Offset to write function lookup
    199190    call    HPIO_InitializePIOVARS          ; Store word count and block size
     
    205196
    206197    ; Destroy stack frame
    207     rcl     al, 1                           ; CF to AL bit 0
    208     add     bp, BYTE PIOVARS_size
    209198    eLEAVE
    210     rcr     al, 1                           ; Restore CF
     199
    211200    pop     si
    212201    pop     es
    213202    ret
     203
    214204
    215205;--------------------------------------------------------------------
     
    243233    jnc     SHORT .BlockLoop                ; If no error, loop while blocks left
    244234.RetError:
    245     ret
     235    ret                                     ; This ret is shared with HPIO_ReadFromDrive
    246236ALIGN JUMP_ALIGN
    247237.XferLastBlock:
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm

    r33 r86  
    1 ; File name     :   DetectDrives.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   17.3.2010
    4 ; Last update   :   23.8.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Functions for detecting drive for the BIOS.
    7 
    83
    94; Section containing code
     
    8075DetectDrives_DetectMasterDrive:
    8176    mov     bh, MASK_IDE_DRVHD_SET      ; Select Master drive
    82     jmp     SHORT DetectDrives_StartDetection
    83 ALIGN JUMP_ALIGN
     77    SKIP2B  ax                          ; mov ax, <next instruction>
    8478DetectDrives_DetectSlaveDrive:
    8579    mov     bh, MASK_IDE_DRVHD_SET | FLG_IDE_DRVHD_DRV
     
    134128    call    AH25h_GetDriveInfo
    135129    mov     si, di                      ; ES:SI now points to ATA information
    136     ret
    137 
    138 
    139 ;--------------------------------------------------------------------
    140 ; Reads ATAPI information from the drive (for CD/DVD-ROMs).
    141 ;
    142 ; DetectDrives_ReadAtapiInfoFromDrive
    143 ;   Parameters:
    144 ;       BH:     Drive Select byte for Drive and Head Register
    145 ;       CS:BP:  Ptr to IDEVARS for the drive
    146 ;       DS:     RAMVARS segment
    147 ;       ES:     Zero (BDA segment)
    148 ;   Returns:
    149 ;       ES:SI   Ptr to ATAPI information (read with IDENTIFY PACKET DEVICE command)
    150 ;       CF:     Cleared if ATAPI-information read successfully
    151 ;               Set if any error
    152 ;   Corrupts registers:
    153 ;       AX, BL, CX, DX, DI
    154 ;--------------------------------------------------------------------
    155 ALIGN JUMP_ALIGN
    156 DetectDrives_ReadAtapiInfoFromDrive:
    157     stc
    158130    ret
    159131
     
    188160
    189161;--------------------------------------------------------------------
     162; Reads ATAPI information from the drive (for CD/DVD-ROMs).
     163;
     164; DetectDrives_ReadAtapiInfoFromDrive
     165;   Parameters:
     166;       BH:     Drive Select byte for Drive and Head Register
     167;       CS:BP:  Ptr to IDEVARS for the drive
     168;       DS:     RAMVARS segment
     169;       ES:     Zero (BDA segment)
     170;   Returns:
     171;       ES:SI   Ptr to ATAPI information (read with IDENTIFY PACKET DEVICE command)
     172;       CF:     Cleared if ATAPI-information read successfully
     173;               Set if any error
     174;   Corrupts registers:
     175;       AX, BL, CX, DX, DI
     176;--------------------------------------------------------------------
     177ALIGN JUMP_ALIGN
     178DetectDrives_ReadAtapiInfoFromDrive:
     179    ;stc
     180    ;ret
     181    ; Fall through to DetectDrives_CreateBiosTablesForCDROM
     182
     183
     184;--------------------------------------------------------------------
    190185; Creates all BIOS tables for detected CD/DVD-ROM.
    191186;
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm

    r3 r86  
    1 ; File name     :   DetectPrint.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   28.3.2010
    4 ; Last update   :   9.4.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Functions for printing drive detection strings.
    73
     
    2521    ePUSH_T ax, ROMVARS.szTitle
    2622    mov     si, g_szRomAt
    27     mov     dh, 4                       ; 4 bytes pushed to stack
    28     jmp     PrintString_JumpToFormat
     23    jmp     SHORT DetectPrint_4BytesPushedToStack
    2924
    3025
     
    6762    push    ax
    6863    mov     si, g_szDetect
     64DetectPrint_4BytesPushedToStack:
    6965    mov     dh, 4                       ; 4 bytes pushed to stack
    7066    jmp     PrintString_JumpToFormat
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm

    r39 r86  
    1 ; File name     :   FloppyDrive.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   25.3.2010
    4 ; Last update   :   13.9.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Various floppy drive related functions that
    73;                   Boot Menu uses.
     
    2117;   Corrupts registers:
    2218;       BX, CX, DI
    23 ;--------------------------------------------------------------------   
     19;--------------------------------------------------------------------
    2420;ALIGN JUMP_ALIGN
    2521FloppyDrive_IsInt40hInstalled:
     
    4036;   Corrupts registers:
    4137;       BX, CX, DI
    42 ;--------------------------------------------------------------------   
     38;--------------------------------------------------------------------
    4339;ALIGN JUMP_ALIGN
    4440.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
     
    8480;   Corrupts registers:
    8581;       DH
    86 ;--------------------------------------------------------------------   
     82;--------------------------------------------------------------------
    8783;ALIGN JUMP_ALIGN
    8884.LoadInt40hVerifyParameters:
    89     xor     dx, dx              ; Floppy drive 0
     85    mov     ah, 08h             ; Get Drive Parameters
     86    cwd                         ; Floppy drive 0
    9087    mov     di, dx
    9188    mov     es, dx              ; ES:DI = 0000:0000h to guard against BIOS bugs
    92     mov     ah, 08h             ; Get Drive Parameters
    9389    ret
    9490
     
    171167
    172168    mov     ah, 08h                 ; Get Drive Parameters
    173     xor     dx, dx                  ; Floppy Drive 00h
     169    cwd                             ; Floppy Drive 00h
    174170    int     INTV_FLOPPY_FUNC
    175171    mov     cl, dl                  ; Number of Floppy Drives to CL
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm

    r33 r86  
    1 ; File name     :   Interrupts.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   23.8.2010
    4 ; Last update   :   23.8.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Functions for initializing the BIOS.
    73
     
    1814;   Corrupts registers:
    1915;       All except segments
    20 ;--------------------------------------------------------------------   
     16;--------------------------------------------------------------------
    2117ALIGN JUMP_ALIGN
    2218Interrupts_InitializeInterruptVectors:
     
    2420    call    Interrupts_InitializeInt19h
    2521    jmp     SHORT Interrupts_InitializeHardwareIrqHandlers
     22    ; Maybe all this should be inlined?
    2623
    2724
     
    3532;   Corrupts registers:
    3633;       AX, BX, CX, DX, SI, DI
    37 ;--------------------------------------------------------------------   
     34;--------------------------------------------------------------------
    3835ALIGN JUMP_ALIGN
    3936Interrupts_InitializeInt13hAnd40h:
     
    5047    ; 40h from 13h. That system locks to infinite loop if we copy 13h to 40h.
    5148    call    FloppyDrive_IsInt40hInstalled
    52     jnc     SHORT .InitializeInt40h
    53     ret
    54 
    55 ;--------------------------------------------------------------------
    56 ; .InitializeInt40h
    57 ;   Parameters:
    58 ;       DX:AX:  Ptr to old INT 13h handler
    59 ;       ES:     BDA and Interrupt Vector segment (zero)
    60 ;   Returns:
    61 ;       Nothing
    62 ;   Corrupts registers:
    63 ;       Nothing
    64 ;--------------------------------------------------------------------   
    65 ALIGN JUMP_ALIGN
    66 .InitializeInt40h:
     49    jc      SHORT .Return
    6750    mov     [es:INTV_FLOPPY_FUNC*4], ax     ; Store offset
    6851    mov     [es:INTV_FLOPPY_FUNC*4+2], dx   ; Store segment
     52.Return:
    6953    ret
    7054
     
    7963;   Corrupts registers:
    8064;       BX, SI
    81 ;--------------------------------------------------------------------   
     65;--------------------------------------------------------------------
    8266ALIGN JUMP_ALIGN
    8367Interrupts_InitializeInt19h:
     
    116100;   Corrupts registers:
    117101;       BX, CX, DX, SI, DI
    118 ;--------------------------------------------------------------------       
     102;--------------------------------------------------------------------
    119103ALIGN JUMP_ALIGN
    120104Interrupts_InitializeHardwareIrqHandlers:
     
    127111    call    .InstallLowOrHighIrqHandler
    128112    loop    .IdeControllerLoop
    129     ret
     113.Return:
     114    ret     ; This ret is shared with .InstallLowOrHighIrqHandler
    130115
    131116;--------------------------------------------------------------------
     
    138123;   Corrupts registers:
    139124;       BX, SI
    140 ;--------------------------------------------------------------------       
     125;--------------------------------------------------------------------
    141126ALIGN JUMP_ALIGN
    142127.InstallLowOrHighIrqHandler:
     128    test    bl, bl
     129    jz      SHORT .Return   ; IRQ not used
    143130    cmp     bl, 8
    144     jae     SHORT .InstallHighIrqHandler
    145     test    bl, bl
    146     jnz     SHORT .InstallLowIrqHandler
    147     ret     ; IRQ not used
     131    jb      SHORT .InstallLowIrqHandler
     132    ; Fall through to .InstallHighIrqHandler
    148133
    149134;--------------------------------------------------------------------
     
    156141;   Corrupts registers:
    157142;       BX, SI
    158 ;--------------------------------------------------------------------       
    159 ALIGN JUMP_ALIGN
    160 .InstallHighIrqHandler:
     143;--------------------------------------------------------------------
     144;ALIGN JUMP_ALIGN
     145;.InstallHighIrqHandler:
    161146    add     bx, BYTE INTV_IRQ8 - 8          ; Interrupt vector number
    162147    mov     si, HIRQ_InterruptServiceRoutineForIrqs8to15
     
    172157;   Corrupts registers:
    173158;       BX, SI
    174 ;--------------------------------------------------------------------       
     159;--------------------------------------------------------------------
    175160ALIGN JUMP_ALIGN
    176161.InstallLowIrqHandler:
     
    190175;   Corrupts registers:
    191176;       BX
    192 ;--------------------------------------------------------------------   
     177;--------------------------------------------------------------------
    193178ALIGN JUMP_ALIGN
    194179Interrupts_InstallHandlerToVectorInBXFromCSSI:
     
    212197    eMOVZX  bx, BYTE [di+DPT.bIdeOff]
    213198    mov     al, [cs:bx+IDEVARS.bIRQ]
     199    test    al, al
     200    jz      SHORT .Return   ; Interrupts disabled
    214201    cmp     al, 8
    215     jae     SHORT .UnmaskHighIrqController
    216     test    al, al
    217     jnz     SHORT .UnmaskLowIrqController
    218     ret     ; Interrupts disabled
     202    jb      SHORT .UnmaskLowIrqController
     203    ; Fall through to .UnmaskHighIrqController
    219204
    220205;--------------------------------------------------------------------
     
    227212;       AX, DX
    228213;--------------------------------------------------------------------
    229 ALIGN JUMP_ALIGN
    230 .UnmaskHighIrqController:
     214;ALIGN JUMP_ALIGN
     215;.UnmaskHighIrqController:
    231216    sub     al, 8               ; Slave interrupt number
    232217    mov     dx, PORT_8259SL_IMR ; Load Slave Mask Register address
     
    270255    out     dx, al              ; Write modified Interrupt Mask Register
    271256    pop     cx
    272     ret
     257.Return:
     258    ret
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/PrintString.asm

    r3 r86  
    1 ; File name     :   PrintString.asm
    21; Project name  :   IDE BIOS
    3 ; Created date  :   19.3.2010
    4 ; Last update   :   31.3.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   Functions for printing strings used in this IDE BIOS.
    7 
    83
    94; Section containing code
     
    138; Prints string with formatting parameters.
    149; Do not call PrintString_JumpToFormat!!! Jump there only!
    15 ; 
     10;
    1611; PrintString_JumpToFormat
    1712;   Parameters:
     
    4237;--------------------------------------------------------------------
    4338; Prints STOP terminated string from wanted segment.
    44 ; 
     39;
    4540; PrintString_FromCS
    4641; PrintString_FromES
     
    5651PrintString_FromCS:
    5752    push    ds
    58     push    cs                  ; Push string segment...
    59     pop     ds                  ; ...and pop it to DS
    60     call    PrintString_FromDS
    61     pop     ds
    62     ret
    63 
    64 ALIGN JUMP_ALIGN
     53    push    cs                  ; Push string segment here...
     54    SKIP2B  ax                  ; mov ax, <next 2 bytes/instructions>
    6555PrintString_FromES:
    6656    push    ds
    67     push    es                  ; Push string segment...
     57    push    es                  ; ...or here...
    6858    pop     ds                  ; ...and pop it to DS
    6959    call    PrintString_FromDS
  • trunk/XTIDE_Universal_BIOS/Src/Libraries/menu/menucrsr.asm

    r3 r86  
    1 ; File name     :   menucrsr.asm
    21; Project name  :   Menu library
    3 ; Created date  :   10.11.2009
    4 ; Last update   :   17.1.2010
    5 ; Author        :   Tomi Tilli
    62; Description   :   ASM library to menu system.
    73;                   Contains menu cursor functions.
     
    160156ALIGN JUMP_ALIGN
    161157MenuCrsr_SetCursor:
    162     xor     bx, bx                      ; Zero page
    163158    mov     ah, 02h                     ; Set Cursor Position and Size
    164     int     10h
    165     ret
     159    SKIP2B  bx                          ; mov bx, <next instruction>
     160    ; Fall through to MenuCrsr_GetCursor
    166161
    167162
     
    178173;       AX, BX
    179174;--------------------------------------------------------------------
    180 ALIGN JUMP_ALIGN
     175;ALIGN JUMP_ALIGN
    181176MenuCrsr_GetCursor:
     177    mov     ah, 03h                     ; Get Cursor Position and Size
    182178    xor     bx, bx                      ; Zero page
    183     mov     ah, 03h                     ; Get Cursor Position and Size
    184179    int     10h
    185180    ret
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r61 r86  
    1 ; File name     :   Main.asm
    21; Project name  :   XTIDE Universal BIOS
    3 ; Created date  :   28.7.2007
    4 ; Last update   :   28.11.2010
    5 ; Author        :   Tomi Tilli
     2; Authors       :   Tomi Tilli
     3;               :   aitotat@gmail.com
     4;               :
     5;               :   Krister Nordvall
     6;               :   krille_n_@hotmail.com
     7;               :
    68; Description   :   Main file for BIOS. This is the only file that needs
    79;                   to be compiled since other files are included to this
    810;                   file (so no linker needed, Nasm does it all).
    9 ;
    10 ;                   Tomi Tilli
    11 ;                   aitotat@gmail.com
    1211
    1312ORG 000h                        ; Code start offset 0000h
     
    1514; Included .inc files
    1615%include "emulate.inc"          ; Must be included first!
     16%include "macros.inc"           ; For generic macros
    1717%include "BiosData.inc"         ; For BIOS Data area equates
    1818%include "Interrupts.inc"       ; For interrupt equates
Note: See TracChangeset for help on using the changeset viewer.