Bläddra i källkod

9.380u-mods: mv ahci driver to the dev branch

rain 5 år sedan
förälder
incheckning
0d94834663
8 ändrade filer med 7 tillägg och 264 borttagningar
  1. 1 1
      LINES
  2. 2 2
      Makefile
  3. 3 0
      README.md
  4. 0 3
      include/kernel/pci_vendors.h
  5. 0 194
      include/modules/ahci.h
  6. 1 1
      modules/Makefile
  7. 0 54
      modules/ahci.c
  8. 0 9
      modules/ide.c

+ 1 - 1
LINES

@@ -42,4 +42,4 @@
 2021-8-21 9.389: 9389 lines, 59 files, rain
 2021-8-22 9.808: 9808 lines, 63 files, rain
 2021-8-23 9.640: 9640 lines, 63 files, rain
-
+2021-8-23 9.380: 9380 lines, 61 files, rain

+ 2 - 2
Makefile

@@ -3,8 +3,8 @@ BOOT_SRCS = boot/boot.asm boot/loader.asm
 BOOT_OBJS = boot/boot.bin boot/loader.bin 
 RLIB_SRCS = kernel/rlib/bitman.c kernel/rlib/bitmap.c kernel/rlib/fifo.c 
 RLIB_OBJS = kernel/rlib/bitman.o kernel/rlib/bitmap.o kernel/rlib/fifo.o 
-MODULE_SRCS = modules/ahci.c modules/ide.c 
-MODULE_OBJS = modules/ahci.o modules/ide.o 
+MODULE_SRCS = modules/ide.c 
+MODULE_OBJS = modules/ide.o 
 KOBJS = init/head.o init/main.o kernel/int.o kernel/keyboard.o kernel/trap.o kernel/vsprintf.o kernel/irq.o kernel/panic.o kernel/mm.o kernel/pci.o kernel/timer.o kernel/sched.o kernel/sys.o kernel/tty.o kernel/console.o $(RLIB_OBJS) $(MODULE_OBJS) 
 KSRCS = init/head.S init/main.c kernel/int.c kernel/keyboard.c kernel/trap.S kernel/vsprintf.c kernel/irq.c kernel/panic.c kernel/mm.c kernel/pci.c kernel/timer.S kernel/sched.c kernel/sys.c kernel/tty.c kernel/console.c $(RLIB_SRCS) $(MODULE_SRCS) 
 

+ 3 - 0
README.md

@@ -169,3 +169,6 @@ source software, you can get its source code from <https://gitee.com/pengruiyang
 &nbsp;&nbsp;&nbsp;&nbsp;now we use another mode to `register_irq`: a new api that `set_irq`. 
 &nbsp;&nbsp;&nbsp;&nbsp;`set_irq` just need 2 arguments, it's simplier, and faster. 
 
+9.380u-mods:  
+&nbsp;&nbsp;&nbsp;&nbsp;move the ahci-driver to the dev branch, because it's unworkable (well...). 
+

+ 0 - 3
include/kernel/pci_vendors.h

@@ -42,12 +42,9 @@
 
 #define foo(fn) extern errno_t fn (struct pci_header0 *)
 
-foo(ahci_init);
 foo(ide_init);
 
-
 struct pci_vendor_table pci_vendors[] = {
-	{CLASS_DISK, 0x06, ahci_init},
 	{CLASS_DISK, 0x01, ide_init}, 
 	{0xff, 0xff, NULL}
 };

+ 0 - 194
include/modules/ahci.h

@@ -1,194 +0,0 @@
-/* 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 <https://www.gnu.org/licenses/>.  
-*/
-
-
-
-#include <kernel/init.h>
-#include <kernel/errno.h>
-#include <kernel/types.h>
-
-#include <modules/ata.h>
-
-
-/* i tried to keep this as simple as i can... */
-
-/* pci-configure.bar5 points to this, and this points to another things */
-
-/* 
- * PCI-config.bar5		-> 	AHCI HBA mem
- * AHCI HBA mem 		-> 	AHCI HBA ports (max 32)
- * AHCI_HBA ports 		-> 	command list (32 command headers)
- * command list [32]		-> 	command headers 
- * command headers		-> 	command table 
- * command table 		-> 	prdts
- * prdts [65536] (optional)	-> 	data buffer
- * command table 		-> 	fis 
- * fis				-> 	lba addresses and others
- * */
-
-
-struct ahci_hba_port {
-	__uint64_t cmd_list;
-
-	/* received fis base */
-	__uint64_t rfis_base;
-
-	__uint32_t int_status;
-	__uint32_t int_enable;
-
-	__uint32_t cmd;
-
-	__uint32_t rsvd0[3];
-
-	__uint32_t sata_status;
-	__uint32_t sata_ctl;
-	__uint32_t sata_error;
-
-	/* these look like bitmaps */
-	__uint32_t sata_active;
-	__uint32_t cmd_issue;
-
-	__uint32_t rsvd[17];
-} __attribute__ ((packed));
-
-
-struct ahci_hba_mem {
-
-#define HBA_MEM_CAP_MASK 	0x1f
-
-	__uint32_t cap;
-
-#define HBA_MEM_GHC_INT_ENABLE 	0x00000002
-#define HBA_MEM_GHC_AHCI_ENABLE	0x80000000
-
-	__uint32_t global_ctl;
-	__uint32_t int_status;
-
-	/* ports implemented */
-	__uint32_t ports_impled;
-
-	__uint32_t rsvd0[6];
-
-	/* ? */
-
-#define HBA_MEM_BHO_OWN_BIOS 	1
-#define HBA_MEM_BHO_OWN_OS	2
-#define HBA_MEM_BHO_OWN_CHANGED	8
-#define HBA_MEM_BHO_OWN_RWC 	8
-
-	__uint32_t bios_handoff;
-
-	__uint32_t rsvd1[53];
-
-	struct ahci_hba_port ports[32];
-} __attribute__ ((packed));
-
-
-struct ahci_cmd_header {
-
-#define CMDHDR_CFG_CFISLEN_SHIFT 	0
-#define CMDHDR_CFG_CFISLEN_MASK 	((1 << 5) - 1)
-
-	/* the mask for config */
-#define CMDHDR_CFG_ATAPI		0x20
-#define CMDHDR_CFG_WRITE 		0x40
-
-#define CMDHDR_CFG_PREFETCHABLE 	0x80
-
-#define CMDHDR_CFG_RESET 		0x100
-#define CMDHDR_CFG_BIST 		0x200
-#define CMDHDR_CFG_CLEAR_R_OK 		0x400
-
-#define CMDHDR_CFG_PORTML_MASK 		0xf000
-#define CMDHDR_CFG_PORTML_SHIFT 	12
-
-#define CMDHDR_CFG_PRDTLEN_MASK 	0xffff0000
-#define CMDHDR_CFG_PRDTLEN_SHIFT 	16
-
-#define CMDHDR_CFG_INTR			0x800000000
-
-	/* config word and prdt length (word) */
-	__uint32_t config;
-	/* total data length we transferred */
-	__uint32_t transfered;
-	__uint64_t cmd_table;
-
-	__uint32_t rsvd[4];
-} __attribute__((packed));
-
-struct ahci_prdt_entry {
-	__uint64_t buf;
-	__uint32_t rsvd;
-
-	/* size (of this.buf) */
-#define PRDT_SIZE_MASK 		((1 << 22) - 1)
-
-	/* interrupt on completion */
-#define PRDT_SIZE_INTR 		(0x80000000u)
-	__uint32_t size;
-} __attribute__ ((packed));
-
-struct ahci_cmd_table {
-	__uint8_t cmd_fis[64];
-	__uint8_t atapi_cmd[16];
-
-	__uint32_t rsvd[0x0c];
-
-	/* max 65536 */
-	/* TODO: support more prdt-entries */
-	struct ahci_prdt_entry prdts[1];
-} __attribute__ ((packed));
-
-struct fis_h2d {
-	__uint8_t fis_type;
-
-#define FISH2D_PORTMUL_MASK 	15
-#define FISH2D_PORTMUL_SHIFT 	0
-
-#define FISH2D_CMD 		0x80
-
-	__uint8_t config;
-
-	__uint8_t command;
-
-	__uint8_t lba0, lba1, lba2;
-	__uint8_t dev;
-
-	__uint8_t lba3, lba4, lba5;
-	__uint8_t feature0;
-
-	__uint16_t nsectors;
-	__uint8_t icc;
-
-	__uint8_t control;
-
-	__uint32_t rsvd;
-} __attribute__ ((packed));
-
-#define ahci_info(fmt, ...) printk(yellow, "ahci: " fmt, ##__VA_ARGS__)
-
-extern volatile struct ahci_hba_mem *hba;
-
-int ahci_rw_sect(volatile struct ahci_hba_port *, int, char *, __uint64_t);
-void do_ahci_intr(void);
-

+ 1 - 1
modules/Makefile

@@ -1,4 +1,4 @@
-OBJS = ahci.o ide.o  
+OBJS = ide.o  
 CFLAGS = -mcmodel=large -fno-builtin -m64 -I ../include -Wall -Werror -g
 
 all: $(OBJS)

+ 0 - 54
modules/ahci.c

@@ -1,54 +0,0 @@
-/* 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 <https://www.gnu.org/licenses/>.  
-*/
-
-
-
-#include <kernel/init.h>
-#include <kernel/errno.h>
-#include <kernel/types.h>
-
-#include <kernel/console.h>
-#include <kernel/pci.h>
-#include <kernel/mm.h>
-
-#include <kernel/int.h>
-#include <kernel/panic.h>
-#include <kernel/schk.h>
-
-#include <arch/x86/paging.h>
-#include <modules/ahci.h>
-#include <lib/string.h>
-
-
-
-errno_t ahci_init(struct pci_header0 *hdr) {
-	schk_init();
-
-	ahci_info("ahci initialized. \n");
-
-	schk_leave();
-
-	return 0;
-}
-
-

+ 0 - 9
modules/ide.c

@@ -144,15 +144,6 @@ errno_t ide_init(struct pci_header0 *hdr) {
 
 	ide_info("ide_init: id completed. \n");
 
-	ide_cmdout(HD0, BLKREAD, buffer, 1, 0x00000000);
-
-	while (ide_intr) hlt();
-
-	int i;
-
-	for (i = 0; i < 512; i++) 
-		printk(white, "%b", buffer[i]);
-
 	schk_leave();
 
 	return 0;