Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;MachinimaOS kernel pre-boot IDE driver
- ; Copyright (C) 2013 Jonathan Strobl ([email protected])
- ;This program is free software; you can redistribute it and/or modify
- ; it under the terms of the GNU General Public License as published by
- ; the Free Software Foundation; either version 2 of the License, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License along
- ; with this program; if not, write to the Free Software Foundation, Inc.,
- ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- ;ASM-Merkmal für IDE, auskommentiert
- {
- option casemap:none ;Assembler Merkmal
- }
- BOOTMEDIUM_KERNEL_DRIVER:
- ;CONSTANTS
- ;Supported card type
- .CARD_TYPE: EQU 2
- ;Register addresses
- .ALTERNATE_STATUS_REG: EQU 140
- .DEVICE_CTRL_REG: EQU 140
- .DATA_REG_LOW: EQU 144
- .DATA_REG_HIGH: EQU 145
- .ERROR_REG: EQU 146
- .FEATURES_REG: EQU 146
- .SECTOR_COUNT_REG: EQU 148
- .SECTOR_NUMBER_REG: EQU 150
- .LBA_BITS_0_7_REG: EQU 150
- .CYLINDER_LOW_REG: EQU 152
- .LBA_BITS_8_15_REG: EQU 152
- .CYLINDER_HIGH_REG: EQU 154
- .LBA_BITS_16_23_REG: EQU 154
- .DEVICE_REG: EQU 156
- .LBA_BITS_24_27_REG: EQU 156
- .STATUS_REG: EQU 158
- .COMMAND_REG: EQU 158
- ;Bit masks
- .BMASK_BUSY: EQU 1000 0000b
- .BMASK_DRDY: EQU 0100 0000b
- .BMASK_DF: EQU 0010 0000b
- .BMASK_DSC: EQU 0001 0000b
- .BMASK_DRQ: EQU 0000 1000b
- .BMASK_CORR: EQU 0000 0100b
- .BMASK_IDX: EQU 0000 0010b
- .BMASK_ERR: EQU 0000 0001b
- ;CODE
- .INIT:
- ;In: C (Slot)
- PUSH AF
- PUSH BC
- LD A, C
- LD (.drvprop_deviceslot), A
- PUSH BC
- LD IY, _KRNL_get_device_type
- RST 10h
- LD A, C
- CP A, .CARD_TYPE
- JP Z, .INIT_type_correct
- LD A, 0
- LD (.drvprop_deviceslot), A
- .INIT_type_correct:
- POP BC
- POP BC
- POP AF
- RET
- .READ_REGISTER:
- ;In: C (Adr)
- ;Out: D (Data)
- PUSH AF
- PUSH BC
- LD B, C
- LD A, (.drvprop_deviceslot)
- LD C, A
- IN D, (C)
- POP BC
- POP AF
- RET
- .WRITE_REGISTER:
- ;In: C (Adr), D (Data)
- PUSH AF
- PUSH BC
- LD B, C
- LD A, (.drvprop_deviceslot)
- LD C, A
- OUT (C), D
- POP BC
- POP AF
- RET
- .READDATA:
- ;In: HL (dest adr)
- ;Out: HL (ptr to end of data)
- PUSH AF
- PUSH BC
- PUSH DE
- .READDATA_readloop:
- ;Auf weitere Daten prüfen
- .READDATA_check_for_data_loop:
- LD C, .STATUS_REG
- CALL .READ_REGISTER
- LD A, .BMASK_BUSY
- AND A, D
- JP NZ, .READDATA_check_for_data_loop
- LD A, .BMASK_ERR
- AND A, D
- JP NZ, .READDATA_finish
- LD A, .BMASK_DRQ
- AND A, D
- JP Z, .READDATA_finish
- ;Daten lesen
- ;Lesen vom Low-Register triggert 16-Byte-Read des Controllers,
- ;High-Byte bleibt im Puffer des Controllers
- LD C, .DATA_REG_LOW
- CALL .READ_REGISTER
- LD (HL), D
- INC HL
- ;High-Byte aus dem Controller-Puffer lesen
- LD C, .DATA_REG_HIGH
- CALL .READ_REGISTER
- LD (HL), D
- INC HL
- JP .READDATA_readloop
- .READDATA_finish:
- POP DE
- POP BC
- POP AF
- RET
- ;DATA
- .drvprop_deviceslot: DB 0
Advertisement
Add Comment
Please, Sign In to add comment