source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc@ 420

Last change on this file since 420 was 411, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Moved some IRQ and LBA48 code to related modules.
File size: 5.7 KB
RevLine 
[99]1; Project name : XTIDE Universal BIOS
[3]2; Description : Defines for DPT structs containing custom
3; Disk Parameter Table used by this BIOS.
[376]4
5;
[399]6; XTIDE Universal BIOS and Associated Tools
[376]7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 2 of the License, or
12; (at your option) any later version.
[399]13;
[376]14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[399]17; GNU General Public License for more details.
[376]18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19;
20
[3]21%ifndef CUSTOMDPT_INC
22%define CUSTOMDPT_INC
23
[150]24; Base DPT for all device types
[173]25struc DPT ; 10 bytes
[3]26 ; General Disk Parameter Table related
[158]27 .wFlags:
[399]28 .bFlagsLow resb 1
29 .bFlagsHigh resb 1
30 .bIdevarsOffset resb 1 ; Offset to IDEVARS for this drive
[3]31
[150]32 ; IDE Drive related
[238]33 ; .bLbaHeads and .twLbaSectors are used for LBA addressing only.
[399]34 .bLbaHeads: resb 1 ; Number of LBA assisted heads (1...255)
35 .twLbaSectors resb 2 ; 48-bit sector count for LBA addressing
[238]36
37 ; .wPchsCylinders and .bPchsSectors are used for CHS addressing only.
[399]38 .wPchsCylinders resb 2 ; Number of P-CHS Cylinders (1...16383)
[227]39 .wPchsHeadsAndSectors:
[399]40 .bPchsHeads resb 1 ; Number of P-CHS heads (1...16)
41 .bPchsSectors resb 1 ; Number of P-CHS Sectors per Track (1...63)
[150]42endstruc
[3]43
[399]44 ; Bit definitions for DPT.bFlagsLow
45 MASKL_DPT_CHS_SHIFT_COUNT EQU (7<<0) ; Bits 0...2, P-CHS to L-CHS bit shift count (0...4)
46 FLGL_DPT_SLAVE EQU FLG_DRVNHEAD_DRV ; (1<<4), Drive is slave drive
[411]47 MASKL_DPT_ADDRESSING_MODE EQU (3<<ADDRESSING_MODE_FIELD_POSITION) ; Bits 5..6, Addressing Mode (bit 6 == FLG_DRVNHEAD_LBA)
48%ifdef MODULE_IRQ
[399]49 FLGL_DPT_ENABLE_IRQ EQU (1<<7)
[411]50%endif
[3]51
[399]52 ; Bit definitions for DPT.bFlagsHigh
53 FLGH_DPT_BLOCK_MODE_SUPPORTED EQU (1<<1) ; Use block transfer commands (must be bit 1!)
[411]54%ifdef MODULE_SERIAL
[399]55 FLGH_DPT_SERIAL_DEVICE EQU (1<<2) ; Serial Port Device
[411]56%endif
57%ifdef MODULE_IRQ
[399]58 FLGH_DPT_INTERRUPT_IN_SERVICE EQU (1<<3) ; Set when waiting for IRQ
[411]59%endif
60%ifdef MODULE_FEATURE_SETS
[399]61 FLGH_DPT_POWER_MANAGEMENT_SUPPORTED EQU (1<<5)
[411]62%endif
[158]63
[399]64 ; IDE device only
[411]65%ifdef MODULE_ADVANCED_ATA
[399]66 FLGH_DPT_IORDY EQU (1<<7) ; Controller and Drive supports IORDY
[411]67%endif
[363]68
[399]69 ; Serial device only
[411]70%ifdef MODULE_SERIAL_FLOPPY
[399]71 FLGH_DPT_SERIAL_FLOPPY EQU (1<<4)
72 FLGH_DPT_SERIAL_FLOPPY_TYPE_MASK EQU 0e0h
73 FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION EQU 5
[411]74%endif
[258]75
[399]76 ; Addressing modes for DPT.wFlags
77 ADDRESSING_MODE_FIELD_POSITION EQU 5
78 ADDRESSING_MODE_LCHS EQU 0 ; L-CHS Addressing Mode (NORMAL in many other BIOSes)
79 ADDRESSING_MODE_PCHS EQU 1 ; P-CHS Addressing Mode (LARGE in many other BIOSes)
80 ADDRESSING_MODE_LBA28 EQU 2 ; 28-bit LBA Addressing Mode
[411]81%ifdef MODULE_EBIOS
[399]82 ADDRESSING_MODE_LBA48 EQU 3 ; 48-bit LBA Addressing Mode
[411]83%endif
[3]84
[363]85
86; DPT for ATA devices
87struc DPT_ATA ; 10 + 2 bytes = 12 bytes
[399]88 .dpt resb DPT_size
89 .bBlockSize resb 1 ; Current block size in sectors (do not set to zero!)
[400]90 .bDevice resb 1 ; Device Type from IDEVARS (overrided when 32-bit controller detected)
[363]91endstruc
92
93
[364]94; Additional variables needed to initialize and reset Advanced IDE Controllers.
95; EBDA must be reserved for DPTs when using these!
[363]96%ifdef MODULE_ADVANCED_ATA
97struc DPT_ADVANCED_ATA
98 .dpt_ata resb DPT_ATA_size
[364]99 .wControllerID resb 2 ; Controller specific ID WORD (from Advanced Controller detection)
[363]100 .wControllerBasePort resb 2 ; Advanced Controller port (not IDE port)
[364]101 .wMinPioCycleTime resb 2 ; Minimum PIO Cycle Time in ns
102 .bPioMode resb 1 ; Best supported PIO mode
[400]103 .bInitError resb 1 ; Flags for initialization errors
[363]104endstruc
105
[400]106 ; Flags for DPT_ADVANCED_ATA.bInitError
107 FLG_INITERROR_FAILED_TO_SELECT_DRIVE EQU (1<<0)
108 FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS EQU (1<<1)
109 FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE EQU (1<<2)
110 FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE EQU (1<<3)
111 FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE EQU (1<<4)
112 FLG_INITERROR_FAILED_TO_SET_PIO_MODE EQU (1<<5)
113 FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER EQU (1<<6)
[411]114%endif
[363]115
[400]116
[364]117; DPT for Serial devices
[363]118%ifdef MODULE_SERIAL
119struc DPT_SERIAL
[399]120 .dpt resb DPT_size
[363]121 .wSerialPortAndBaud:
[399]122 .bSerialPort resb 1 ; Serial connection I/O port address, divided by 4
123 .bSerialBaud resb 1 ; Serial connection baud rate divisor
[363]124endstruc
125%endif
126
127
128; This is the common size for all DPTs. All DPTs must be equal size.
[364]129%ifdef MODULE_ADVANCED_ATA
[399]130 LARGEST_DPT_SIZE EQU DPT_ADVANCED_ATA_size
[364]131%else
[399]132 LARGEST_DPT_SIZE EQU DPT_ATA_size
[364]133%endif
[363]134
135
[399]136 ; Number of Sectors per Track is fixed to 63 for LBA assist calculation.
137 ; 1024 cylinders, 256 heads, 63 sectors = 8.4 GB limit (but DOS does not support more than 255 heads)
138 MAX_LCHS_CYLINDERS EQU 1024
139 LBA_ASSIST_SPT EQU 63
[3]140
[173]141
[358]142;--------------------------------------------------------------------
143; LIMIT_LBA_CYLINDERS_IN_DXAX_TO_LCHS_CYLINDERS
144; Parameters:
145; DX:AX: Number of LBA cylinders
146; Returns:
147; AX: Number of L-CHS cylinders
148; Corrupts registers:
149; Nothing
150;--------------------------------------------------------------------
151%macro LIMIT_LBA_CYLINDERS_IN_DXAX_TO_LCHS_CYLINDERS 0
152 test dx, dx
153 jnz SHORT %%LoadMaxValueToAX
154 cmp ax, MAX_LCHS_CYLINDERS
[370]155 jb SHORT %%NoNeedToModify
[358]156%%LoadMaxValueToAX:
157 mov ax, MAX_LCHS_CYLINDERS
158%%NoNeedToModify:
159%endmacro
160
161
[3]162%endif ; CUSTOMDPT_INC
Note: See TracBrowser for help on using the repository browser.