/* Copyright (C) 2021 Rain */ /* This file is part of XNIX. */ /* XNIX 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 3 of the License, or (at your option) and later version. */ /* XNIX 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 XNIX. If not, see . */ #include #include #include #include #define ide_info(fmt, ...) printk(yellow, "ide: " fmt, ##__VA_ARGS__); /* 0: PIO mode */ #define PROGIF_HD0MODE 0x01 /* 1: can change the pio mode to pci mode */ #define PROGIF_HD0CHANGABLE 0x02 #define PROGIF_HD1MODE 0x04 #define PROGIF_HD1CHANGABLE 0x08 #define PROGIF_DMA 0x80 #define PORT_DATA 0 #define PORT_ERR 1 #define PORT_NSECTORS 2 #define PORT_ADDR0 3 #define PORT_ADDR1 4 #define PORT_ADDR2 5 #define PORT_DEV 6 #define PORT_STAT 7 void do_ide_intr(void); void do_ide_id(void); void do_ide_read(void); int ide_cmdout(int, int, char *, int, __uint64_t); #define wait_disk_not_busy(port) while (inb(port + PORT_STAT) & ATASTAT_BUSY); #define wait_disk_ready(port) while (!(inb(port + PORT_STAT) & ATASTAT_READY));