Changeset 601 in xtideuniversalbios for trunk/Assembly_Library


Ignore:
Timestamp:
Feb 14, 2019, 7:38:08 PM (5 years ago)
Author:
krille_n_
Message:

Changes:

  • Building the BIOS now works again.
  • Added a new IDE device type/transfer mode for use only with XT-IDE rev 2+ (or Chuck(G)-modded rev 1) cards installed in any of the following machines: Olivetti M24, AT&T PC6300, Xerox 6060 and Logabax Persona 1600. This new transfer mode is slightly faster than the regular XT-IDE rev 1 device type and requires that the card is configured for High Speed mode (or, in case of the card being a rev 1 card, has the Chuck(G) mod done). The new device type is called "XTIDE rev 2 (Olivetti M24)" in XTIDECFG.
  • Made some minor improvements to the library code that handles 'Drive Not Ready' errors in XTIDECFG.
  • Optimizations.
Location:
trunk/Assembly_Library
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/BiosFunctions.inc

    r596 r601  
    55
    66; BIOS interrupts
    7 BIOS_VIDEO_INTERRUPT_10h        EQU     10h
    8 BIOS_EQUIPMENT_INTERRUPT_11h    EQU     11h
    9 BIOS_DISK_INTERRUPT_13h         EQU     13h
    10 BIOS_SYSTEM_INTERRUPT_15h       EQU     15h
    11 BIOS_KEYBOARD_INTERRUPT_16h     EQU     16h
    12 BIOS_BOOT_FAILURE_INTERRUPT_18h EQU     18h
    13 BIOS_BOOT_LOADER_INTERRUPT_19h  EQU     19h
    14 BIOS_TIME_PCI_PNP_1Ah           EQU     1Ah
    15 BIOS_DISKETTE_INTERRUPT_40h     EQU     40h
    16 HD0_DPT_POINTER_41h             EQU     41h
    17 HD1_DPT_POINTER_46h             EQU     46h
     7BIOS_VIDEO_INTERRUPT_10h                EQU     10h
     8BIOS_EQUIPMENT_INTERRUPT_11h            EQU     11h
     9BIOS_DISK_INTERRUPT_13h                 EQU     13h
     10BIOS_SYSTEM_INTERRUPT_15h               EQU     15h
     11BIOS_KEYBOARD_INTERRUPT_16h             EQU     16h
     12BIOS_BOOT_FAILURE_INTERRUPT_18h         EQU     18h
     13BIOS_BOOT_LOADER_INTERRUPT_19h          EQU     19h
     14BIOS_TIME_PCI_PNP_INTERRUPT_1Ah         EQU     1Ah
     15BIOS_SYSTEM_TIMER_TICK_INTERRUPT_1Ch    EQU     1Ch
     16BIOS_DISKETTE_INTERRUPT_40h             EQU     40h
     17HD0_DPT_POINTER_41h                     EQU     41h
     18HD1_DPT_POINTER_46h                     EQU     46h
    1819
    1920; Hardware interrupts
    20 HARDWARE_IRQ_0_INTERRUPT_08h    EQU     08h     ; System timer
    21 HARDWARE_IRQ_1_INTERRUPT_09h    EQU     09h     ; Keyboard
    22 HARDWARE_IRQ_2_INTERRUPT_0Ah    EQU     0Ah
    23 HARDWARE_IRQ_3_INTERRUPT_0Bh    EQU     0Bh
    24 HARDWARE_IRQ_4_INTERRUPT_0Ch    EQU     0Ch
    25 HARDWARE_IRQ_5_INTERRUPT_0Dh    EQU     0Dh
    26 HARDWARE_IRQ_6_INTERRUPT_0Eh    EQU     0Eh
    27 HARDWARE_IRQ_7_INTERRUPT_0Fh    EQU     0Fh
    28 HARDWARE_IRQ_8_INTERRUPT_70h    EQU     70h
    29 HARDWARE_IRQ_9_INTERRUPT_71h    EQU     71h
    30 HARDWARE_IRQ_10_INTERRUPT_72h   EQU     72h
    31 HARDWARE_IRQ_11_INTERRUPT_73h   EQU     73h
    32 HARDWARE_IRQ_12_INTERRUPT_74h   EQU     74h
    33 HARDWARE_IRQ_13_INTERRUPT_75h   EQU     75h
    34 HARDWARE_IRQ_14_INTERRUPT_76h   EQU     76h
    35 HARDWARE_IRQ_15_INTERRUPT_77h   EQU     77h
    36 
     21HARDWARE_IRQ_0_INTERRUPT_08h            EQU     08h     ; System timer
     22HARDWARE_IRQ_1_INTERRUPT_09h            EQU     09h     ; Keyboard
     23HARDWARE_IRQ_2_INTERRUPT_0Ah            EQU     0Ah
     24HARDWARE_IRQ_3_INTERRUPT_0Bh            EQU     0Bh
     25HARDWARE_IRQ_4_INTERRUPT_0Ch            EQU     0Ch
     26HARDWARE_IRQ_5_INTERRUPT_0Dh            EQU     0Dh
     27HARDWARE_IRQ_6_INTERRUPT_0Eh            EQU     0Eh
     28HARDWARE_IRQ_7_INTERRUPT_0Fh            EQU     0Fh
     29HARDWARE_IRQ_8_INTERRUPT_70h            EQU     70h
     30HARDWARE_IRQ_9_INTERRUPT_71h            EQU     71h
     31HARDWARE_IRQ_10_INTERRUPT_72h           EQU     72h
     32HARDWARE_IRQ_11_INTERRUPT_73h           EQU     73h
     33HARDWARE_IRQ_12_INTERRUPT_74h           EQU     74h
     34HARDWARE_IRQ_13_INTERRUPT_75h           EQU     75h
     35HARDWARE_IRQ_14_INTERRUPT_76h           EQU     76h
     36HARDWARE_IRQ_15_INTERRUPT_77h           EQU     77h
    3737
    3838; BIOS video functions
    39 SET_VIDEO_MODE                  EQU     00h
    40 SET_TEXT_MODE_CURSOR_SHAPE      EQU     01h
    41 SET_CURSOR_POSITION             EQU     02h
    42 GET_CURSOR_POSITION_AND_SIZE    EQU     03h
    43 SELECT_ACTIVE_DISPLAY_PAGE      EQU     05h
    44 TELETYPE_OUTPUT                 EQU     0Eh
     39SET_VIDEO_MODE                          EQU     00h
     40SET_TEXT_MODE_CURSOR_SHAPE              EQU     01h
     41SET_CURSOR_POSITION                     EQU     02h
     42GET_CURSOR_POSITION_AND_SIZE            EQU     03h
     43SELECT_ACTIVE_DISPLAY_PAGE              EQU     05h
     44TELETYPE_OUTPUT                         EQU     0Eh
    4545
    4646; BIOS disk functions
    47 READ_SECTORS_INTO_MEMORY        EQU     02h
    48 GET_DRIVE_PARAMETERS            EQU     08h
    49 RESET_HARD_DISK                 EQU     0Dh
    50 GET_DISK_TYPE                   EQU     15h
    51 LOTECH_XTCF_FEATURES            EQU     1Eh
    52 GET_DRIVE_INFORMATION           EQU     25h
    53 CHECK_EXTENSIONS_PRESENT        EQU     41h
    54 GET_EXTENDED_DRIVE_INFORMATION  EQU     48h
     47READ_SECTORS_INTO_MEMORY                EQU     02h
     48GET_DRIVE_PARAMETERS                    EQU     08h
     49RESET_HARD_DISK                         EQU     0Dh
     50GET_DISK_TYPE                           EQU     15h
     51LOTECH_XTCF_FEATURES                    EQU     1Eh
     52GET_DRIVE_INFORMATION                   EQU     25h
     53CHECK_EXTENSIONS_PRESENT                EQU     41h
     54GET_EXTENDED_DRIVE_INFORMATION          EQU     48h
    5555
    5656; BIOS system functions
    57 OS_HOOK_DEVICE_BUSY             EQU     90h
    58 OS_HOOK_DEVICE_POST             EQU     91h
     57OS_HOOK_DEVICE_BUSY                     EQU     90h
     58OS_HOOK_DEVICE_POST                     EQU     91h
    5959
    6060; BIOS keyboard functions
    61 GET_KEYSTROKE                   EQU     00h
    62 CHECK_FOR_KEYSTROKE             EQU     01h
     61GET_KEYSTROKE                           EQU     00h
     62CHECK_FOR_KEYSTROKE                     EQU     01h
    6363
    6464; BIOS system functions
    65 EVENT_WAIT                      EQU     86h
     65EVENT_WAIT                              EQU     86h
    6666
    67 ; BIOS PCI 2.0+ functions
    68 PCI_INSTALLATION_CHECK          EQU     0B101h
    69 
     67; BIOS PCI 2.0c+ functions
     68PCI_INSTALLATION_CHECK                  EQU     0B101h
    7069
    7170%endif ; BIOS_FUNCTIONS_INC
  • trunk/Assembly_Library/Inc/DosFunctions.inc

    r592 r601  
    3636; DOS errors
    3737ERR_DOS_FUNCTION_NUMBER_INVALID                     EQU     01h
     38ERR_DOS_PATH_NOT_FOUND                              EQU     03h
    3839ERR_DOS_INVALID_DRIVE                               EQU     0Fh
     40ERR_DOS_NO_MORE_FILES                               EQU     12h
    3941ERR_DOS_DRIVE_NOT_READY                             EQU     15h
    4042
  • trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm

    r596 r601  
    746746    mov     ax, FIND_FIRST_MATCHING_FILE<<8
    747747    int     DOS_INTERRUPT_21h
     748    ; Returns ERR_DOS_NO_MORE_FILES only when the root directory is the current directory (at least under Windows XP).
     749    cmp     al, ERR_DOS_PATH_NOT_FOUND
    748750    pop     ax
    749751    pop     ds
     
    752754
    753755    xchg    ah, [cs:bLastCriticalError]         ; Zero bLastCriticalError and fetch error code to AH
     756    je      SHORT .DriveIsNotReady              ; A removable drive with no media (or possibly a drive that has not been formatted?)
    754757    cmp     ah, ERR_DOS_DRIVE_NOT_READY
    755758    jne     SHORT .DriveIsReady
    756 
     759.DriveIsNotReady:
    757760    mov     bx, g_szDlgDriveNotReady
    758761    call    Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
  • trunk/Assembly_Library/Src/Menu/MenuAttributes.asm

    r592 r601  
    6868    cmp     al, 7
    6969    je      SHORT .LoadMonoAttribute
    70     test    al, 1                       ; Even modes (0 and 2) are B/W
    71     jnz     SHORT .LoadColorAttribute
     70    shr     al, 1                       ; Even modes (0 and 2) are B/W
     71    jc      SHORT .LoadColorAttribute
    7272
    7373.LoadBlackAndWhiteAttribute:
  • trunk/Assembly_Library/Src/Serial/SerialServer.asm

    r592 r601  
    3838;--------------------------------------------------------------------
    3939SerialServer_SendReceive:
    40 
    41         push    si
    42         push    di
    43         push    bp
     40    push    si
     41    push    di
     42    push    bp
    4443
    4544;
     
    4847;       Baud in CH until UART initialization is complete
    4948;
    50         mov     ch,dh
    51         xor     dh,dh
    52         eSHL_IM dx, 2           ; shift from one byte to two
    53 
    54         mov     al,[bp+SerialServer_Command.bSectorCount]
    55         mov     ah,[bp+SerialServer_Command.bCommand]
     49    mov     ch, dh
     50    xor     dh, dh
     51    eSHL_IM dx, 2                       ; shift from one byte to two
     52
     53    mov     al, [bp+SerialServer_Command.bSectorCount]
     54    mov     ah, [bp+SerialServer_Command.bCommand]
    5655
    5756;
    5857; Command byte and sector count live at the top of the stack, pop/push are used to access
    5958;
    60         push    ax              ; save sector count for return value
    61         push    ax              ; working copy on the top of the stack
    62 
    63 %ifndef EXCLUDE_FROM_XUB        ; DF already cleared in Int13h.asm
     59    push    ax                          ; save sector count for return value
     60    push    ax                          ; working copy on the top of the stack
     61
     62%ifndef EXCLUDE_FROM_XUB                ; DF already cleared in Int13h.asm
    6463%ifdef CLD_NEEDED
    65         cld
     64    cld
    6665%endif
    6766%endif
     
    7473; decided to reprogram the UART
    7574;
    76         mov     bl,dl           ; setup BL with proper values for read/write loops (BH comes later)
    77 
    78         mov     al,83h
    79         add     dl, Serial_UART_lineControl ; Clears CF
    80         out     dx,al
    81 
    82         mov     al,ch
    83         mov     dl,bl           ; divisor low
    84         out     dx,al
     75    mov     bl, dl                      ; setup BL with proper values for read/write loops (BH comes later)
     76    mov     al, 83h
     77    add     dl, Serial_UART_lineControl ; Clears CF
     78    out     dx, al
     79
     80    mov     al, ch
     81    mov     dl, bl                      ; divisor low
     82    out     dx, al
    8583
    8684%ifdef USE_UNDOC_INTEL
    87         salc    ; Clear AL using CF
     85    salc                                ; Clear AL using CF
    8886%else
    89         xor     al, al
    90 %endif
    91         inc     dx              ; divisor high
    92         push    dx
    93         out     dx,al
    94 
    95         mov     al,047h
    96         inc     dx              ; fifo
    97         out     dx,al
    98 
    99         mov     al,03h
    100         inc     dx              ; linecontrol
    101         out     dx,al
    102 
    103         mov     al,0bh
    104         inc     dx              ; modemcontrol
    105         out     dx,al
    106 
    107         inc     dx              ; linestatus (no output now, just setting up BH for later use)
    108         mov     bh,dl
    109 
    110         pop     dx              ; base, interrupts disabled
     87    xor     al, al
     88%endif
     89    inc     dx                          ; divisor high
     90    push    dx
     91    out     dx, al
     92
     93    mov     al, 47h
     94    inc     dx                          ; fifo
     95    out     dx, al
     96
     97    mov     al, 03h
     98    inc     dx                          ; linecontrol
     99    out     dx, al
     100
     101    mov     al, 0Bh
     102    inc     dx                          ; modemcontrol
     103    out     dx, al
     104
     105    inc     dx                          ; linestatus (no output now, just setting up BH for later use)
     106    mov     bh, dl
     107
     108    pop     dx                          ; base, interrupts disabled
    111109%ifdef USE_UNDOC_INTEL
    112         salc    ; Clear AL using CF
     110    salc                                ; Clear AL using CF
    113111%else
    114         xor     al, al
    115 %endif
    116         out     dx,al
     112    xor     al, al
     113%endif
     114    out     dx, al
    117115
    118116;----------------------------------------------------------------------
     
    122120; Sends first six bytes of IDEREGS_AND_INTPACK as the command
    123121;
    124         push    es              ; save off real buffer location
    125         push    si
    126 
    127         mov     si,bp           ; point to IDEREGS for command dispatch;
    128         push    ss
    129         pop     es
    130 
    131         mov     di,0ffffh       ; initialize checksum for write
    132         mov     bp,di
    133 
    134         mov     cx,4            ; writing 3 words (plus 1)
    135 
    136         cli                     ; interrupts off...
    137 
    138         call    SerialServer_WriteProtocol.entry
    139 
    140         pop     di              ; restore real buffer location (note change from SI to DI)
    141                                 ; Buffer is primarily referenced through ES:DI throughout, since
    142                                 ; we need to store (read sector) faster than we read (write sector)
    143         pop     es
    144 
    145         pop     ax              ; load command byte (done before call to .nextSector on subsequent iterations)
    146         push    ax
     122    push    es                          ; save off real buffer location
     123    push    si
     124
     125    mov     si, bp                      ; point to IDEREGS for command dispatch;
     126    push    ss
     127    pop     es
     128
     129    mov     di, 0FFFFh                  ; initialize checksum for write
     130    mov     bp, di
     131
     132    mov     cx, 4                       ; writing 3 words (plus 1)
     133
     134    cli                                 ; interrupts off...
     135
     136    call    SerialServer_WriteProtocol.entry
     137
     138    pop     di                          ; restore real buffer location (note change from SI to DI)
     139                                        ; Buffer is primarily referenced through ES:DI throughout, since
     140                                        ; we need to store (read sector) faster than we read (write sector)
     141    pop     es
     142
     143    pop     ax                          ; load command byte (done before call to .nextSector on subsequent iterations)
     144    push    ax
    147145
    148146%ifndef SERIALSERVER_NO_ZERO_SECTOR_COUNTS
    149         test    al,al           ; if no sectors to be transferred, wait for the ACK checksum on the command
    150         jz      .zeroSectors
     147    test    al, al                      ; if no sectors to be transferred, wait for the ACK checksum on the command
     148    jz      SHORT .zeroSectors
    151149%endif
    152150
     
    155153;
    156154.nextSector:
    157         mov     si,0ffffh       ; initialize checksum for read or write
    158         mov     bp,si
    159 
    160         mov     cx,0101h        ; writing 256 words (plus 1)
    161 
    162         sahf                    ; command byte, are we doing a write?
    163         jnc     .readEntry
    164 
    165         xchg    si,di           ; swap pointer and checksum, will be re-swap'ed in WriteProtocol
    166         call    SerialServer_WriteProtocol.entry
     155    mov     si, 0FFFFh                  ; initialize checksum for read or write
     156    mov     bp, si
     157
     158    mov     cx, 0101h                   ; writing 256 words (plus 1)
     159
     160    sahf                                ; command byte, are we doing a write?
     161    jnc     SHORT .readEntry
     162
     163    xchg    si, di                      ; swap pointer and checksum, will be re-swap'ed in WriteProtocol
     164    call    SerialServer_WriteProtocol.entry
    167165
    168166.zeroSectors:
    169         inc     cx              ; CX = 1 now (0 out of WriteProtocol)
    170         jmp     .readEntry
     167    inc     cx                          ; CX = 1 now (0 out of WriteProtocol)
     168    jmp     SHORT .readEntry
    171169
    172170;----------------------------------------------------------------------
     
    177175;
    178176.readTimeout:
    179         push    ax              ; not only does this push preserve AX (which we need), but it also
    180                                 ; means the stack has the same number of bytes on it as when we are
    181                                 ; sending a packet, important for error cleanup and exit
    182         mov     ah,1
    183         call    SerialServer_WaitAndPoll_Read
    184         pop     ax
    185         test    dl,1
    186         jz      .readByte1Ready
    187         jmp     .readByte2Ready
     177    push    ax                          ; not only does this push preserve AX (which we need), but it also
     178                                        ; means the stack has the same number of bytes on it as when we are
     179                                        ; sending a packet, important for error cleanup and exit
     180    mov     ah, 1
     181    call    SerialServer_WaitAndPoll_Read
     182    pop     ax
     183    test    dl, 1
     184    jz      SHORT .readByte1Ready
     185    jmp     SHORT .readByte2Ready
    188186
    189187;----------------------------------------------------------------------------
     
    197195;
    198196.readLoop:
    199         stosw                   ; store word in caller's data buffer
    200 
    201         add     bp, ax          ; update Fletcher's checksum
    202         adc     bp, 0
    203         add     si, bp
    204         adc     si, 0
     197    stosw                               ; store word in caller's data buffer
     198
     199    add     bp, ax                      ; update Fletcher's checksum
     200    adc     bp, 0
     201    add     si, bp
     202    adc     si, 0
    205203
    206204.readEntry:
    207         mov     dl,bh
    208         in      al,dx
    209         shr     al,1            ; data ready (byte 1)?
    210         mov     dl,bl           ; get ready to read data
    211         jnc     .readTimeout    ; nope not ready, update timeouts
     205    mov     dl, bh
     206    in      al, dx
     207    shr     al, 1                       ; data ready (byte 1)?
     208    mov     dl, bl                      ; get ready to read data
     209    jnc     SHORT .readTimeout          ; nope not ready, update timeouts
    212210
    213211;
     
    216214;
    217215.readByte1Ready:
    218         in      al, dx          ; read data byte 1
    219 
    220         mov     ah, al          ; store byte in ah for now
     216    in      al, dx                      ; read data byte 1
     217    mov     ah, al                      ; store byte in ah for now
    221218
    222219;
     
    227224; .read_byte2_ready)
    228225;
    229         mov     dl,bh
    230 
    231         in      al,dx
    232         shr     al,1            ; data ready (byte 2)?
    233         jnc     .readTimeout
     226    mov     dl, bh
     227
     228    in      al, dx
     229    shr     al, 1                       ; data ready (byte 2)?
     230    jnc     SHORT .readTimeout
    234231.readByte2Ready:
    235         mov     dl,bl
    236         in      al, dx          ; read data byte 2
    237 
    238         xchg    al, ah          ; ah was holding byte 1, reverse byte order
    239 
    240         loop    .readLoop
    241 
    242         sti                     ; interrupts back on ASAP, between packets
     232    mov     dl, bl
     233    in      al, dx                      ; read data byte 2
     234    xchg    al, ah                      ; ah was holding byte 1, reverse byte order
     235    loop    .readLoop
     236    sti                                 ; interrupts back on ASAP, between packets
    243237
    244238;
    245239; Compare checksums
    246240;
    247         xchg    ax,bp
    248         xor     ah,al
    249         mov     cx,si
    250         xor     cl,ch
    251         mov     al,cl
    252         cmp     ax,bp
    253         jnz     SerialServer_OutputWithParameters_Error
    254 
    255         pop     ax              ; sector count and command byte
    256         dec     al              ; decrement sector count
    257         push    ax              ; save
    258         jz      SerialServer_OutputWithParameters_ReturnCodeInAL
    259 
    260         cli                     ; interrupts back off for ACK byte to host
    261                                 ; (host could start sending data immediately)
    262         out     dx,al           ; ACK with next sector number
    263 
    264         jmp     short .nextSector
     241    xchg    ax, bp
     242    xor     ah, al
     243    mov     cx, si
     244    xor     cl, ch
     245    mov     al, cl
     246    cmp     ax, bp
     247    jne     SHORT SerialServer_OutputWithParameters_Error
     248
     249    pop     ax                          ; sector count and command byte
     250    dec     al                          ; decrement sector count
     251    push    ax                          ; save
     252    jz      SHORT SerialServer_OutputWithParameters_ReturnCodeInAL
     253
     254    cli                                 ; interrupts back off for ACK byte to host
     255                                        ; (host could start sending data immediately)
     256    out     dx, al                      ; ACK with next sector number
     257    jmp     SHORT .nextSector
    265258
    266259;---------------------------------------------------------------------------
     
    274267ALIGN JUMP_ALIGN
    275268SerialServer_OutputWithParameters_ErrorAndPop4Words:
    276         add     sp,8
     269    add     sp, 8
    277270;;; fall-through
    278271
     
    287280; taken care of this, but I have seen cases where this is not true.
    288281;
    289         xor     cx,cx           ; timeout this clearing routine, in case the UART isn't there
     282    xor     cx, cx                      ; timeout this clearing routine, in case the UART isn't there
    290283.clearBuffer:
    291         mov     dl,bh
    292         in      al,dx
    293         mov     dl,bl
    294         test    al,08fh
    295         jz      .clearBufferComplete
    296         test    al,1
    297         in      al,dx
    298         loopnz  .clearBuffer    ; note ZF from test above
     284    mov     dl, bh
     285    in      al, dx
     286    mov     dl, bl
     287    test    al, 8Fh
     288    jz      SHORT .clearBufferComplete
     289    test    al, 1
     290    in      al, dx
     291    loopnz  .clearBuffer                ; note ZF from test above
    299292
    300293.clearBufferComplete:
    301         mov     al, 1           ; error return code
     294    mov     al, 1                       ; error return code
    302295
    303296ALIGN JUMP_ALIGN
    304297SerialServer_OutputWithParameters_ReturnCodeInAL:
    305298%if 0
    306         sti                     ; all paths here will already have interrupts turned back on
    307 %endif
    308         mov     ah, al          ; for success, AL will already be zero
    309 
    310         pop     bx              ; recover "ax" (command and count) from stack
    311         pop     cx              ; recover saved sector count
    312         xor     ch, ch
    313         sub     cl, bl          ; subtract off the number of sectors that remained
    314 
    315         pop     bp
    316         pop     di
    317         pop     si
    318 
    319         sahf                    ; error return code to CF
    320 
    321         ret
     299    sti                                 ; all paths here will already have interrupts turned back on
     300%endif
     301    mov     ah, al                      ; for success, AL will already be zero
     302
     303    pop     bx                          ; recover "ax" (command and count) from stack
     304    pop     cx                          ; recover saved sector count
     305    xor     ch, ch
     306    sub     cl, bl                      ; subtract off the number of sectors that remained
     307
     308    pop     bp
     309    pop     di
     310    pop     si
     311
     312    sahf                                ; error return code to CF
     313    ret
     314
    322315
    323316;--------------------------------------------------------------------
     
    345338SerialServer_WriteProtocol:
    346339.writeLoop:
    347         es lodsw                ; fetch next word
    348 
    349         out     dx,al           ; output first byte
    350 
    351         add     bp,ax           ; update checksum
    352         adc     bp,0
    353         add     di,bp
    354         adc     di,0
    355 
    356         mov     dl,bh           ; transmit buffer empty?
    357         in      al,dx
    358         test    al,20h
    359         jz      .writeTimeout2  ; nope, use our polling routine
     340    es lodsw                            ; fetch next word
     341
     342    out     dx, al                      ; output first byte
     343
     344    add     bp, ax                      ; update checksum
     345    adc     bp, 0
     346    add     di, bp
     347    adc     di, 0
     348
     349    mov     dl, bh                      ; transmit buffer empty?
     350    in      al, dx
     351    test    al, 20h
     352    jz      SHORT .writeTimeout2        ; nope, use our polling routine
    360353
    361354.writeByte2Ready:
    362         mov     dl,bl
    363         mov     al,ah           ; output second byte
    364         out     dx,al
     355    mov     dl, bl
     356    mov     al, ah                      ; output second byte
     357    out     dx, al
    365358
    366359.entry:
    367         mov     dl,bh           ; transmit buffer empty?
    368         in      al,dx
    369         test    al,20h
    370         mov     dl,bl
    371         jz      .writeTimeout1  ; nope, use our polling routine
     360    mov     dl, bh                      ; transmit buffer empty?
     361    in      al, dx
     362    test    al, 20h
     363    mov     dl, bl
     364    jz      SHORT .writeTimeout1        ; nope, use our polling routine
    372365
    373366.writeByte1Ready:
    374         loop    .writeLoop
    375 
    376         mov     ax,di           ; fold Fletcher's checksum and output
    377         xor     al,ah
    378         out     dx,al           ; byte 1
    379 
    380         call    SerialServer_WaitAndPoll_Write
    381 
    382         mov     ax,bp
    383         xor     al,ah
    384         out     dx,al           ; byte 2
    385 
    386         xchg    si,di           ; preserve checksum word in si, move pointer back to di
    387 
    388         ret
     367    loop    .writeLoop
     368
     369    mov     ax, di                      ; fold Fletcher's checksum and output
     370    xor     al, ah
     371    out     dx, al                      ; byte 1
     372
     373    call    SerialServer_WaitAndPoll_Write
     374
     375    mov     ax, bp
     376    xor     al, ah
     377    out     dx, al                      ; byte 2
     378
     379    xchg    si, di                      ; preserve checksum word in si, move pointer back to di
     380    ret
    389381
    390382.writeTimeout2:
    391         mov     dl,ah           ; need to preserve AH, but don't need DL (will be reset upon return)
    392         call    SerialServer_WaitAndPoll_Write
    393         mov     ah,dl
    394         jmp     .writeByte2Ready
     383    mov     dl, ah                      ; need to preserve AH, but don't need DL (will be reset upon return)
     384    call    SerialServer_WaitAndPoll_Write
     385    mov     ah, dl
     386    jmp     SHORT .writeByte2Ready
    395387
    396388.writeTimeout1:
    397         ePUSH_T ax, .writeByte1Ready    ; return address for ret at end of SC_writeTimeout2
     389    ePUSH_T ax, .writeByte1Ready        ; return address for ret at end of SC_writeTimeout2
    398390;;; fall-through
    399391
     
    418410ALIGN JUMP_ALIGN
    419411SerialServer_WaitAndPoll_Write:
    420         mov     ah,20h
     412    mov     ah, 20h
    421413;;; fall-through
    422414
    423415ALIGN JUMP_ALIGN
    424416SerialServer_WaitAndPoll_Read:
    425         push    cx
    426         push    dx
     417    push    cx
     418    push    dx
    427419
    428420;
    429421; We first poll in a tight loop, interrupts off, for the next character to come in/be sent
    430422;
    431         xor     cx,cx
     423    xor     cx, cx
    432424.readTimeoutLoop:
    433         mov     dl,bh
    434         in      al,dx
    435         test    al,ah
    436         jnz     .readTimeoutComplete
    437         loop    .readTimeoutLoop
     425    mov     dl, bh
     426    in      al, dx
     427    test    al, ah
     428    jnz     SHORT .readTimeoutComplete
     429    loop    .readTimeoutLoop
    438430
    439431;
     
    441433; and wait for a given number of timer ticks to pass.
    442434;
    443         sti
     435    sti
    444436%ifndef SERIALSERVER_TIMER_LOCATION
    445         mov     cl,SerialServer_WaitAndPoll_SoftDelayTicks
    446         call    Timer_InitializeTimeoutWithTicksInCL
     437    mov     cl, SerialServer_WaitAndPoll_SoftDelayTicks
     438    call    Timer_InitializeTimeoutWithTicksInCL
    447439%else
    448         push    ax
    449         push    bx
    450         mov     ax,SerialServer_WaitAndPoll_SoftDelayTicks
    451         mov     bx,SERIALSERVER_TIMER_LOCATION
    452         call    TimerTicks_InitializeTimeoutFromAX
    453         pop     bx
    454         pop     ax
     440    push    ax
     441    push    bx
     442    mov     ax, SerialServer_WaitAndPoll_SoftDelayTicks
     443    mov     bx, SERIALSERVER_TIMER_LOCATION
     444    call    TimerTicks_InitializeTimeoutFromAX
     445    pop     bx
     446    pop     ax
    455447%endif
    456448
    457449.WaitAndPoll:
    458450%ifndef SERIALSERVER_TIMER_LOCATION
    459         call    Timer_SetCFifTimeout
     451    call    Timer_SetCFifTimeout
    460452%else
    461         push    ax
    462         push    bx
    463         mov     bx,SERIALSERVER_TIMER_LOCATION
    464         call    TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
    465         pop     bx
    466         pop     ax
    467 %endif
    468         jc      SerialServer_OutputWithParameters_ErrorAndPop4Words
    469         in      al,dx
    470         test    al,ah
    471         jz      .WaitAndPoll
    472         cli
     453    push    ax
     454    push    bx
     455    mov     bx, SERIALSERVER_TIMER_LOCATION
     456    call    TimerTicks_GetTimeoutTicksLeftToAXfromDSBX
     457    pop     bx
     458    pop     ax
     459%endif
     460    jc      SerialServer_OutputWithParameters_ErrorAndPop4Words
     461    in      al, dx
     462    test    al, ah
     463    jz      SHORT .WaitAndPoll
     464    cli
    473465
    474466.readTimeoutComplete:
    475         pop     dx
    476         pop     cx
    477         ret
    478 
    479 
     467    pop     dx
     468    pop     cx
     469    ret
     470
  • trunk/Assembly_Library/Src/Serial/SerialServerScan.asm

    r589 r601  
    11; Project name  :   Assembly Library
    22; Description   :   Serial Server Support, Scan for Server
     3
    34;
    45; This functionality is broken out from SerialServer as it may only be needed during
     
    4344;--------------------------------------------------------------------
    4445SerialServerScan_ScanForServer:
    45         mov     cx, 1           ; one sector, not scanning (default)
     46    mov     cx, 1           ; one sector, not scanning (default)
    4647
    47         test    dx, dx
    48         jnz     SHORT SerialServerScan_CheckForServer_PortAndBaudInDX
     48    test    dx, dx
     49    jnz     SHORT SerialServerScan_CheckForServer_PortAndBaudInDX
    4950
    50         mov     di, .scanPortAddresses-1
    51         mov     ch, 1           ;  tell server that we are scanning
     51    mov     di, .scanPortAddresses-1
     52    mov     ch, 1           ;  tell server that we are scanning
    5253
    5354.nextPort:
    54         inc     di              ; load next port address
    55         mov     dh, 40h         ; Clear DH and make sure CF is set if error
    56         mov     dl, [cs:di]
    57         eSHL_IM dx, 2           ; shift from one byte to two
    58         jz      SHORT .error
     55    inc     di              ; load next port address
     56    mov     dh, 40h         ; Clear DH and make sure CF is set if error
     57    mov     dl, [cs:di]
     58    eSHL_IM dx, 2           ; shift from one byte to two
     59    jz      SHORT .error
    5960
    6061;
    6162; Test for COM port presence, write to and read from registers
    6263;
    63         push    dx
    64         add     dl, Serial_UART_lineControl
    65         mov     al, 9Ah
    66         out     dx, al
    67         in      al, dx
    68         pop     dx
    69         cmp     al, 9Ah
    70         jne     SHORT .nextPort
     64    push    dx
     65    add     dl, Serial_UART_lineControl
     66    mov     al, 9Ah
     67    out     dx, al
     68    in      al, dx
     69    pop     dx
     70    cmp     al, 9Ah
     71    jne     SHORT .nextPort
    7172
    72         mov     al, 0Ch
    73         out     dx, al
    74         in      al, dx
    75         cmp     al, 0Ch
    76         jne     SHORT .nextPort
     73    mov     al, 0Ch
     74    out     dx, al
     75    in      al, dx
     76    cmp     al, 0Ch
     77    jne     SHORT .nextPort
    7778
    7879;
     
    8889; Note: hardware baud multipliers (2x, 4x, 8x) will impact the final baud rate and are not known at this level
    8990;
    90         mov     dh, 30h * 2     ; multiply by 2 since we are about to divide by 2
    91         mov     dl, [cs:di]     ; restore single byte port address for scan
     91    mov     dh, 30h * 2     ; multiply by 2 since we are about to divide by 2
     92    mov     dl, [cs:di]     ; restore single byte port address for scan
    9293
    9394.nextBaud:
    94         shr     dh, 1
    95         jz      SHORT .nextPort
    96         cmp     dh, 6           ; skip from 6 to 4, to move from the top of the 9600 baud range
    97         jne     SHORT .testBaud ; to the bottom of the 115200 baud range
    98         mov     dh, 4
     95    shr     dh, 1
     96    jz      SHORT .nextPort
     97    cmp     dh, 6           ; skip from 6 to 4, to move from the top of the 9600 baud range
     98    jne     SHORT .testBaud ; to the bottom of the 115200 baud range
     99    mov     dh, 4
    99100
    100101.testBaud:
    101         call    SerialServerScan_CheckForServer_PortAndBaudInDX
    102         jc      SHORT .nextBaud
     102    call    SerialServerScan_CheckForServer_PortAndBaudInDX
     103    jc      SHORT .nextBaud
    103104
    104105.error:
    105         ret
     106    ret
    106107
    107 .scanPortAddresses: db  SERIAL_COM7_IOADDRESS >> 2
    108                     db  SERIAL_COM6_IOADDRESS >> 2
    109                     db  SERIAL_COM5_IOADDRESS >> 2
    110                     db  SERIAL_COM4_IOADDRESS >> 2
    111                     db  SERIAL_COM3_IOADDRESS >> 2
    112                     db  SERIAL_COM2_IOADDRESS >> 2
    113                     db  SERIAL_COM1_IOADDRESS >> 2
    114                     db  0
     108.scanPortAddresses:
     109    db  SERIAL_COM7_IOADDRESS >> 2
     110    db  SERIAL_COM6_IOADDRESS >> 2
     111    db  SERIAL_COM5_IOADDRESS >> 2
     112    db  SERIAL_COM4_IOADDRESS >> 2
     113    db  SERIAL_COM3_IOADDRESS >> 2
     114    db  SERIAL_COM2_IOADDRESS >> 2
     115    db  SERIAL_COM1_IOADDRESS >> 2
     116    db  0
    115117
    116118
     
    133135;--------------------------------------------------------------------
    134136SerialServerScan_CheckForServer_PortAndBaudInDX:
    135         push    bp              ; setup fake SerialServer_Command
    136         push    dx              ; send port baud and rate, returned in inquire packet
    137                                 ; (and possibly returned in the drive identification string)
    138         push    cx              ; send number of sectors, and if it is on a scan or not
    139         mov     bl, SerialServer_Command_Inquire        ; protocol command onto stack with bh
    140         push    bx
     137    push    bp              ; setup fake SerialServer_Command
     138    push    dx              ; send port baud and rate, returned in inquire packet
     139                            ; (and possibly returned in the drive identification string)
     140    push    cx              ; send number of sectors, and if it is on a scan or not
     141    mov     bl, SerialServer_Command_Inquire        ; protocol command onto stack with bh
     142    push    bx
    141143
    142         mov     bp, sp
    143         call    SerialServer_SendReceive
     144    mov     bp, sp
     145    call    SerialServer_SendReceive
    144146
    145         pop     bx
    146         pop     cx
    147         pop     dx
    148         pop     bp
     147    pop     bx
     148    pop     cx
     149    pop     dx
     150    pop     bp
    149151
    150         ret
     152    ret
    151153
  • trunk/Assembly_Library/Src/Util/CMOS.asm

    r593 r601  
    131131GetSumOfBytes10hto2DhtoCX:
    132132    xor     cx, cx          ; Sum
    133     mov     dx, 10h         ; First index
     133    mov     dl, 10h         ; First index
     134    xor     ah, ah
    134135
    135136.AddNextByte:
    136137    call    CMOS_ReadFromIndexInDLtoAL
    137     xor     ah, ah
    138138    add     cx, ax
    139139    inc     dx
    140140    cmp     dl, 2Dh         ; Last index
    141     jbe     .AddNextByte
     141    jbe     SHORT .AddNextByte
    142142    ret
Note: See TracChangeset for help on using the changeset viewer.