diff --git a/.cproject b/.cproject
index 815670f..8f89a2a 100644
--- a/.cproject
+++ b/.cproject
@@ -102,4 +102,4 @@
-
+
\ No newline at end of file
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 1650089..4573e6d 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -8,4 +8,4 @@
-
+
\ No newline at end of file
diff --git a/sys/include/sys/kern_sysctl.h b/sys/include/sys/kern_sysctl.h
index d13bc2a..c42a331 100644
--- a/sys/include/sys/kern_sysctl.h
+++ b/sys/include/sys/kern_sysctl.h
@@ -31,28 +31,26 @@
#include
#include
-#include
+#include
#define CTL_MAXNAME 24 /* largest number of components supported */
/*
* Top-level identifiers
*/
-#define CTL_UNSPEC 0 /* unused */
-#define CTL_KERN 1 /* "high kernel": proc, limits */
-#define CTL_VM 2 /* virtual memory */
-#define CTL_VFS 3 /* filesystem, mount type is next */
-#define CTL_NET 4 /* network, see socket.h */
-#define CTL_DEBUG 5 /* debugging parameters */
-#define CTL_HW 6 /* generic cpu/io */
-#define CTL_MACHDEP 7 /* machine dependent */
-#define CTL_USER 8 /* user-level */
-#define CTL_P1003_1B 9 /* POSIX 1003.1B */
-#define CTL_UBIX 10 /* ubixos */
+#define CTL_UNSPEC 0 /* unused */
+#define CTL_KERN 1 /* "high kernel": proc, limits */
+#define CTL_VM 2 /* virtual memory */
+#define CTL_VFS 3 /* filesystem, mount type is next */
+#define CTL_NET 4 /* network, see socket.h */
+#define CTL_DEBUG 5 /* debugging parameters */
+#define CTL_HW 6 /* generic cpu/io */
+#define CTL_MACHDEP 7 /* machine dependent */
+#define CTL_USER 8 /* user-level */
+#define CTL_P1003_1B 9 /* POSIX 1003.1B */
+#define CTL_UBIX 10 /* ubixos */
-#define CTL_KERN_OPENFILES 1 /* kernel openfiles */
-
-//#define EINVAL -1 /* */
+#define CTL_KERN_OPENFILES 1 /* kernel openfiles */
struct sysctl_entry {
struct sysctl_entry *prev;
diff --git a/sys/include/sys/types.h b/sys/include/sys/types.h
index 9b647ef..8bfca56 100644
--- a/sys/include/sys/types.h
+++ b/sys/include/sys/types.h
@@ -33,7 +33,7 @@
#include
#ifndef NULL
-#define NULL 0
+#define NULL 0x0
#endif
typedef __uintfptr_t uintfptr_t;
diff --git a/sys/include/ubixos/spinlock.h b/sys/include/ubixos/spinlock.h
index 2ebfa2a..c32eaef 100644
--- a/sys/include/ubixos/spinlock.h
+++ b/sys/include/ubixos/spinlock.h
@@ -33,7 +33,7 @@
#define LOCKED 1
#define UNLOCKED 0
-#define SPIN_LOCK_INITIALIZER {NULL, 0}
+#define SPIN_LOCK_INITIALIZER { (void *)0x0, 0 }
#define LLOCK_FLAG 1
//typedef volatile int spinLock_t;
diff --git a/sys/sys/device.c b/sys/sys/device.c
index 414dc70..e583e77 100644
--- a/sys/sys/device.c
+++ b/sys/sys/device.c
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
/* Linked list of drivers loaded in the system accessable by the subsystem only */
@@ -51,6 +52,7 @@
struct device_node *tmpDev = 0x0;
tmpDev = (struct device_node *) kmalloc(sizeof(struct device_node));
+
if (tmpDev == NULL)
kprintf("Error Adding Device: memory failure\n");
@@ -60,14 +62,19 @@
tmpDev->devInfo = devInfo;
spinLock(&deviceSpinLock);
+
tmpDev->next = devices;
+
devices = tmpDev;
+
spinUnlock(&deviceSpinLock);
+
if (tmpDev->devInfo->initialized == 0x0)
return (tmpDev->devInfo->init(tmpDev));
else
return (0x0);
+
}
/*****************************************************************************************
@@ -82,19 +89,27 @@
*****************************************************************************************/
struct device_node *device_find(int major, int minor) {
+
struct device_node *tmpDev = 0x0;
spinLock(&deviceSpinLock);
for (tmpDev = devices; tmpDev; tmpDev = tmpDev->next) {
+
if ((tmpDev->devInfo->major == major) && (tmpDev->minor == minor)) {
+
spinUnlock(&deviceSpinLock);
+
return (tmpDev);
+
}
+
}
spinUnlock(&deviceSpinLock);
+
return (0x0);
+
}
/********************************************************************************************
@@ -105,33 +120,54 @@
*********************************************************************************************/
int device_remove(struct device_node *deviceToDelete) {
+
struct device_node *current, *previous;
current = devices;
previous = NULL;
+
spinLock(&deviceSpinLock);
+
while (current != NULL) {
- if (current == deviceToDelete)
+
+ if (current == deviceToDelete) {
+
break;
+
+ }
else {
+
previous = current;
current = current->next;
+
}
+
}
+
if (current == NULL) {
+
spinUnlock(&deviceSpinLock);
+
return 1;
+
}
else {
+
if (current == devices)
devices = devices->next;
else
previous->next = current->next;
+
kfree(current);
+
spinUnlock(&deviceSpinLock);
+
return 1;
+
}
spinUnlock(&deviceSpinLock);
+
return 0x0;
+
}