BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / c738dbb1e7e7a46a98436326234826eef71083e2 / include / nucleus

// Related

Nucleus

Barry CPU specific segment c738dbb (3 years, 2 months ago)
diff --git a/include/nucleus/cpu.h b/include/nucleus/cpu.h
index b1e4cae..f4d7175 100644
--- a/include/nucleus/cpu.h
+++ b/include/nucleus/cpu.h
@@ -2,9 +2,16 @@
 #define _NUCLEUS_CPU_H
 
 #include <stdint.h>
+#include <nucleus/types.h>
 
 typedef unsigned int cpu_t;
 
+/* Structure for CPU specific data */
+struct CPUData {
+	cpu_t id;
+	Task *task;
+};
+
 /* Structure for an Interrupt Frame */
 struct InterruptFrame {
 	uint32_t ds;
@@ -16,6 +23,8 @@ struct InterruptFrame {
 typedef void (*exc_handler_t)(struct InterruptFrame *);
 typedef void (*int_handler_t)(struct InterruptFrame *);
 
+extern struct CPUData __seg_gs *cpu;
+
 extern int apic;
 
 extern uintptr_t lapicPtr, ioapicPtr;
@@ -29,4 +38,7 @@ extern cpu_t lapicNums[];
 void register_exception(int num, exc_handler_t addr);
 void register_interrupt(int num, int_handler_t addr);
 
+void set_fs_base(uintptr_t base);
+void set_gs_base(uintptr_t base);
+
 #endif
diff --git a/include/nucleus/driver.h b/include/nucleus/driver.h
index 53df5ec..57eb42f 100644
--- a/include/nucleus/driver.h
+++ b/include/nucleus/driver.h
@@ -3,14 +3,13 @@
 
 #include <sys/types.h>
 #include <nucleus/object.h>
+#include <nucleus/types.h>
 #include <nucleus/vfs.h>
 
 #define MKDEV(maj,min) ((dev_t) (((maj & 0xFFFF) << 16) | (min & 0xFFFF)))
 #define MAJOR(dev) ((dev >> 16) & 0xFFFF)
 #define MINOR(dev) (dev & 0xFFFF)
 
-typedef struct Driver Driver;
-
 extern ObjectType driverType;
 
 unsigned short register_driver(unsigned short major, FileOps *ops);
diff --git a/include/nucleus/memory.h b/include/nucleus/memory.h
index 059ba9f..595d152 100644
--- a/include/nucleus/memory.h
+++ b/include/nucleus/memory.h
@@ -5,6 +5,7 @@
 #include <stddef.h>
 #include <sys/mman.h>
 #include <nucleus/object.h>
+#include <nucleus/types.h>
 
 #define PAGE_SIZE 0x1000
 
@@ -14,9 +15,6 @@
 typedef uint32_t page_t;
 typedef uint32_t page_table_t;
 typedef uint32_t page_dir_t;
-typedef struct Page Page;
-typedef struct VirtualMemory VirtualMemory;
-typedef struct VMRegion VMRegion;
 
 /* Page Table Entry flags */
 enum PTEFlag {
diff --git a/include/nucleus/object.h b/include/nucleus/object.h
index 139f7ca..9683410 100644
--- a/include/nucleus/object.h
+++ b/include/nucleus/object.h
@@ -4,6 +4,7 @@
 #include <sys/types.h>
 #include <stddef.h>
 #include <nucleus/cpu.h>
+#include <nucleus/types.h>
 
 typedef struct Spinlock Spinlock;
 typedef struct ObjectType ObjectType;
@@ -11,7 +12,6 @@ typedef struct Object Object;
 typedef struct ObjectList ObjectList;
 typedef struct Iterator Iterator;
 typedef int (*compare_callback_t)(void *, void *);
-typedef struct Task Task;
 
 /* Spinlock */
 struct Spinlock {
diff --git a/include/nucleus/task.h b/include/nucleus/task.h
index 1e91a33..80a2a71 100644
--- a/include/nucleus/task.h
+++ b/include/nucleus/task.h
@@ -6,11 +6,9 @@
 #include <nucleus/cpu.h>
 #include <nucleus/object.h>
 #include <nucleus/memory.h>
+#include <nucleus/types.h>
 #include <nucleus/vfs.h>
 
-typedef struct Task Task;
-typedef struct Signals Signals;
-
 /* Task priorities */
 enum Priority {
 	NONE,
@@ -57,12 +55,11 @@ struct Task {
 	Signals *signals;
 };
 
+#define current cpu->task
+
 extern ObjectType taskType;
 extern ObjectType signalsType;
 
-extern Task *currentTask[];
-#define current currentTask[CPUID]
-
 /* Check if super-user */
 static inline int
 super_user(void)
diff --git a/include/nucleus/types.h b/include/nucleus/types.h
new file mode 100644
index 0000000..d64d543
--- /dev/null
+++ b/include/nucleus/types.h
@@ -0,0 +1,28 @@
+#ifndef _NUCLEUS_TYPES_H
+#define _NUCLEUS_TYPES_H
+
+/* Driver */
+typedef struct Driver Driver;
+
+/* Memory */
+typedef struct Page Page;
+typedef struct VirtualMemory VirtualMemory;
+typedef struct VMRegion VMRegion;
+
+/* Task */
+typedef struct Task Task;
+typedef struct Signals Signals;
+
+/* VFS */
+typedef struct FSType FSType;
+typedef struct FileSystem FileSystem;
+typedef struct Files Files;
+typedef struct SuperBlock SuperBlock;
+typedef struct SuperOps SuperOps;
+typedef struct Inode Inode;
+typedef struct InodeOps InodeOps;
+typedef struct DirEntry DirEntry;
+typedef struct File File;
+typedef struct FileOps FileOps;
+
+#endif
diff --git a/include/nucleus/vfs.h b/include/nucleus/vfs.h
index 8dd295a..6bdf673 100644
--- a/include/nucleus/vfs.h
+++ b/include/nucleus/vfs.h
@@ -6,22 +6,12 @@
 #include <dirent.h>
 #include <nucleus/object.h>
 #include <nucleus/memory.h>
+#include <nucleus/types.h>
 
 #define NFILES 32
 #define NAME_MAX 255
 #define PATH_MAX 1024
 
-typedef struct FSType FSType;
-typedef struct FileSystem FileSystem;
-typedef struct Files Files;
-typedef struct SuperBlock SuperBlock;
-typedef struct SuperOps SuperOps;
-typedef struct Inode Inode;
-typedef struct InodeOps InodeOps;
-typedef struct DirEntry DirEntry;
-typedef struct File File;
-typedef struct FileOps FileOps;
-
 typedef Inode *(*mount_callback_t)(FSType *, int, const char *, void *);
 
 /* Structure for a Super Block */