BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / 7864e7f8ed319f380849d97675be53f53c953f9d / drivers / storage / ata.c

// Related

Nucleus

Barry Device driver interface 7864e7f (3 years, 2 months ago)
diff --git a/drivers/storage/ata.c b/drivers/storage/ata.c
index 4d26ab2..d0ff1e8 100644
--- a/drivers/storage/ata.c
+++ b/drivers/storage/ata.c
@@ -5,7 +5,9 @@
  */
 
 #include <stdint.h>
+#include <sys/stat.h>
 #include <io.h>
+#include <nucleus/driver.h>
 #include <nucleus/panic.h>
 #include <nucleus/vfs.h>
 #include "ide.h"
@@ -169,11 +171,16 @@ ata_init(struct IDEDevice *dev)
 	static void *ataDmaArea = NULL;
 	if (!ataDmaArea)
 		ataDmaArea = (void *) alloc_frame();
+	static int ataMajor = 0;
+	if (!ataMajor)
+		ataMajor = register_driver(1, &ataFileOps);
+
 
 	/* Create device node */
 	char name[16];
+	int minor = drive * 16;
 	sprintf(name, "/dev/hd%d", drive);
-//	mknod(name, S_IFBLK | 0600, MKDEV());
+	mknod(name, S_IFBLK | 0600, MKDEV(ataMajor, minor));
 	kprintf("  ATA drive [%s] (%d MB) %s", name,
 	        dev->size / 1024 / 2, dev->model);
 
@@ -186,7 +193,7 @@ ata_init(struct IDEDevice *dev)
 		if (!part[i].type)
 			continue;
 		sprintf(name, "/dev/hd%dp%d", drive, i);
-//		mknod(name, S_IFBLK | 0600, MKDEV(ideDriver.major, ());
+		mknod(name, S_IFBLK | 0600, MKDEV(ataMajor, minor + i + 1));
 		kprintf("    Partition [%s] %#.8x - %#.8x", name,
 		        part[i].lba*512, (part[i].lba + part[i].size) * 512);
 	}