diff --git a/kernel/bio.inc b/kernel/bio.inc index 32036e8..d768fa3 100644 --- a/kernel/bio.inc +++ b/kernel/bio.inc @@ -7,7 +7,7 @@ struc Buffer { .block dd ? .ulock dd ? .refcount dd ? - .data db 512 dup(?) + .data db 1024 dup(?) } DEFN Buffer diff --git a/kernel/dev/at/ata.inc b/kernel/dev/at/ata.inc index aece4c8..be25ded 100644 --- a/kernel/dev/at/ata.inc +++ b/kernel/dev/at/ata.inc @@ -14,9 +14,26 @@ ATA_CHAN1_IO = 0x170 ATA_CHAN2_IO = 0x1E8 ATA_CHAN3_IO = 0x168 + ;; Constant: ATA_DATA + ;; Read/Write data ATA_DATA = 0x0 + ;; Constant: ATA_ERROR ;; + ;; > ┌────┬─────┬────┬───┬────┬──┬───┬───┐ + ;; > │AMNF│TKZNF│ABRT│MCR│IDNF│MC│UNC│BBK│ + ;; > └────┴─────┴────┴───┴────┴──┴───┴───┘ + ;; > 7 6 5 4 3 2 1 0 + ;; + ;; AMNF - Address mark not found. + ;; TKZNF - Track zero not found. + ;; ABRT - Aborted command. + ;; MCR - Media change request. + ;; IDNF - ID not found. + ;; MC - Media changed + ;; UNC - Uncorrectable data error. + ;; BBK - Bad Block detected. + ;; ATA_ERROR = 0x1 ATA_ERROR_AMNF = 0x01 ATA_ERROR_TKZNF = 0x02 @@ -27,11 +44,21 @@ ATA_ERROR_MC = 0x20 ATA_ERROR_UNC = 0x40 ATA_ERROR_BBK = 0x80 + ;; Constant: ATA_FEATURES ATA_FEATURES = 0x1 + + ;; Constant: ATA_SECCOUNT ATA_SECCOUNT = 0x2 + + ;; Constant: ATA_SECNUM ATA_SECNUM = 0x3 + + ;; Constant: ATA_CYLLO ATA_CYLLO = 0x4 + + ;; Constant: ATA_CYLHI ATA_CYLHI = 0x5 + ;; Constant: ATA_DRVHEAD ;; Drive/Head register ;; @@ -39,8 +66,18 @@ ATA_DRVHEAD = 0x6 ATA_DRVHEAD_DRV = 0x10 ATA_DRVHEAD_LBA = 0x40 + ;; Constant: ATA_COMMAND ATA_COMMAND = 0x7 + ;; Constant: ATA_CMD_RESTORE + ;; Recalibrate +ATA_CMD_RESTORE = 0x10 + ;; Constant: ATA_CMD_DIAGNOSTIC + ;; Execute device diagnostic +ATA_CMD_DIAGNOSTIC = 0x90 + ;; Constant: ATA_CMD_IDENTIFY +ATA_CMD_IDENTIFY = 0xA0 + ;; Constant: ATA_STATUS ;; ATA_STATUS = 0x7 @@ -60,14 +97,13 @@ ATA_CTRL_nIEN = 0x02 ATA_CTRL_SRST = 0x04 ATA_CTRL_HOB = 0x80 + ;; Constant: ATA_DRVADDR + ;; ATA_DRVADDR = 0x1 ATA_DRVADDR_DS0 = 0x01 ATA_DRVADDR_DS1 = 0x02 ATA_DRVADDR_WTG = 0x40 -ATA_CMD_RESTORE = 0x10 -ATA_CMD_DIAGNOSTIC = 0x90 -ATA_CMD_IDENTIFY = 0xA0 ;; Function: ata_wait ;; @@ -88,6 +124,7 @@ ata_wait: @@: ret + ;; Function: ata_select ata_select: ret @@ -215,4 +252,7 @@ aAtaChans: dw ATA_CHAN3_IO .end: +ata_bdevsw: + dd 0 + szMsgAtaFound db "ATA: hd%u found", 0 diff --git a/kernel/dev/dev.inc b/kernel/dev/dev.inc index 0d7d0a5..2dd487a 100644 --- a/kernel/dev/dev.inc +++ b/kernel/dev/dev.inc @@ -15,6 +15,14 @@ struc Device { } DEFN Device + ;; Struc: BlkDev + ;; + ;; .open - Open the device in preparation for I/O operations + ;; .strategy - Start a read or write operation, and return immediately. + ;; .close - Close a device. + ;; .dump - Write all physical memory to the device. + ;; .psize - Return the size of a disk-drive partition. + ;; struc BlkDev { .open dd ? .strategy dd ? @@ -24,6 +32,18 @@ struc BlkDev { .psize dd ? } + ;; Struc: CharDev + ;; + ;; .open - open the device. + ;; .close - close the device.. + ;; .read - do an input operation. + ;; .write - do an output operation. + ;; .ioctl - do an I/O control operation. + ;; .select - poll device for I/O readiness. + ;; .stop - stop output on the device. + ;; .mmap - map device offset to memory location + ;; .reset - reinitialize device after a bus reset. + ;; struc CharDev { .open dd ? .close dd ? @@ -38,6 +58,7 @@ struc CharDev { aBlockDevices: dd floppy_bdevsw + dd ata_bdevsw .end: aCharDevices: @@ -54,6 +75,7 @@ aDevices: dd ata_device .end: + ;; Function: dev_init dev_init: mov ecx, aDevices @@: