changeset 13:d07d4701a103

Cleanup of header files
author windel
date Mon, 14 Nov 2011 21:44:35 +0100
parents fcdae30b2782
children a58904747019
files cos/include/ctype.h cos/include/kernel.h cos/kernel/kernel.h cos/kernel/snprintf.c
diffstat 4 files changed, 157 insertions(+), 165 deletions(-) [+]
line wrap: on
line diff
--- a/cos/include/ctype.h	Mon Nov 14 21:31:27 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#ifndef _LINUX_CTYPE_H
-#define _LINUX_CTYPE_H
-
-/*
- * NOTE! This ctype does not handle EOF like the standard C
- * library is required to.
- */
-
-#define _U	0x01	/* upper */
-#define _L	0x02	/* lower */
-#define _D	0x04	/* digit */
-#define _C	0x08	/* cntrl */
-#define _P	0x10	/* punct */
-#define _S	0x20	/* white space (space/lf/tab) */
-#define _X	0x40	/* hex digit */
-#define _SP	0x80	/* hard space (0x20) */
-
-extern unsigned char _ctype[];
-
-#define __ismask(x) (_ctype[(int)(unsigned char)(x)])
-
-#define isalnum(c)	((__ismask(c)&(_U|_L|_D)) != 0)
-#define isalpha(c)	((__ismask(c)&(_U|_L)) != 0)
-#define iscntrl(c)	((__ismask(c)&(_C)) != 0)
-#define isdigit(c)	((__ismask(c)&(_D)) != 0)
-#define isgraph(c)	((__ismask(c)&(_P|_U|_L|_D)) != 0)
-#define islower(c)	((__ismask(c)&(_L)) != 0)
-#define isprint(c)	((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
-#define ispunct(c)	((__ismask(c)&(_P)) != 0)
-#define isspace(c)	((__ismask(c)&(_S)) != 0)
-#define isupper(c)	((__ismask(c)&(_U)) != 0)
-#define isxdigit(c)	((__ismask(c)&(_D|_X)) != 0)
-
-#define isascii(c) (((unsigned char)(c))<=0x7f)
-#define toascii(c) (((unsigned char)(c))&0x7f)
-
-static inline unsigned char tolower(unsigned char c)
-{
-	if (isupper(c))
-		c -= 'A'-'a';
-	return c;
-}
-
-static inline unsigned char toupper(unsigned char c)
-{
-	if (islower(c))
-		c -= 'a'-'A';
-	return c;
-}
-
-#endif
--- a/cos/include/kernel.h	Mon Nov 14 21:31:27 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-#ifndef KERNEL_H
-#define KERNEL_H
-
-// Include common functions, available to all!
-#define NULL ((void*)0)
-
-// Type defs:
-typedef unsigned int        uint32_t;
-typedef unsigned long long  uint64_t;
-typedef unsigned short      ushort_t;
-typedef unsigned char       uchar_t;
-typedef unsigned int        uint_t;
-typedef unsigned long       ulong_t;
-typedef unsigned long long  ulonglong_t;
-typedef unsigned long       off_t;
-typedef unsigned long       size_t;
-
-void printf(const char* fmt, ... );
-void memset(void* ptr, uint32_t value, uint32_t num);
-void memcpy(void* dst, void* src, uint32_t num);
-
-// memory alloc functions:
-void* malloc(size_t size);
-void free(void* ptr);
-
-void clear_screen();
-void init_screen();
-void print_string(const char *);
-
-// For IO ports:
-unsigned char inb(unsigned short);
-void outb(unsigned short, unsigned char);
-
-void setupIDT(void);
-void PICremap(void);
-// Assembler util functions:
-void enableinterrupts(void);
-void callint49(void);
-void doCPUID(int eax, int *ebx, int *ecx, int *edx);
-
-// Keyboard driver:
-void keyboardDriverUpdate(unsigned char scancode);
-void timerDriverUpdate(void);
-
-// Memory functions:
-void mappage(uint32_t address);
-
-int querymode(void);
-int getcs(void);
-void loadPageTable(void* tableAddress);
-void enablePaging(void);
-
-// Variable argument list things:
-#define va_start(v,l)	__builtin_va_start(v,l)
-#define va_end(v)	__builtin_va_end(v)
-#define va_arg(v,l)	__builtin_va_arg(v,l)
-typedef __builtin_va_list va_list;
-
-struct multiboot_aout_symbol_table {
-  uint32_t tabsize;
-  uint32_t strsize, addr, reserved;
-};
-
-struct multiboot_info {
-  uint32_t flags; // Multiboot flags / version
-  uint32_t mem_lower; // available memory from BIOS
-  uint32_t mem_upper;
-  uint32_t boot_device; 
-  uint32_t cmdline; // COmmand line
-  uint32_t mods_count;
-  uint32_t mods_addr;
-  union {
-   struct multiboot_aout_symbol_table aout_sym;
-  } u;
-
-  uint32_t mmap_length;
-  uint32_t mmap_addr;
-};
-
-struct memory_map {
-  uint32_t size;
-  uint32_t baselow, basehigh;
-  uint32_t lenlow, lenhigh;
-  uint32_t type;
-};
-
-typedef struct {
-  char name[32]; // Name of the console
-  unsigned char screendata[80*25]; // All chars in the console!
-} console_t;
-
-typedef struct {
-  uint32_t esp;
-  uint32_t ss;
-  uint32_t kstack;
-  uint32_t ustack;
-  uint32_t cr3;
-
-  uint32_t number;
-  uint32_t parent;
-  uint32_t owner;
-  uint32_t groups;
-  uint32_t timetorun;
-  uint32_t sleep;
-  uint32_t priority;
-  uint32_t filehandle;
-  char naam[32];
-
-  console_t *console;
-} programma_t;
-
-#endif
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cos/kernel/kernel.h	Mon Nov 14 21:44:35 2011 +0100
@@ -0,0 +1,113 @@
+#ifndef KERNEL_H
+#define KERNEL_H
+
+// Include common functions, available to all!
+#define NULL ((void*)0)
+
+// Type defs:
+typedef unsigned int        uint32_t;
+typedef unsigned long long  uint64_t;
+typedef unsigned short      ushort_t;
+typedef unsigned char       uchar_t;
+typedef unsigned int        uint_t;
+typedef unsigned long       ulong_t;
+typedef unsigned long long  ulonglong_t;
+typedef unsigned long       off_t;
+typedef unsigned long       size_t;
+
+void printf(const char* fmt, ... );
+void memset(void* ptr, uint32_t value, uint32_t num);
+void memcpy(void* dst, void* src, uint32_t num);
+
+// memory alloc functions:
+void* malloc(size_t size);
+void free(void* ptr);
+
+void clear_screen();
+void init_screen();
+void print_string(const char *);
+
+// For IO ports:
+unsigned char inb(unsigned short);
+void outb(unsigned short, unsigned char);
+
+void setupIDT(void);
+void PICremap(void);
+// Assembler util functions:
+void enableinterrupts(void);
+void callint49(void);
+void doCPUID(int eax, int *ebx, int *ecx, int *edx);
+
+// Keyboard driver:
+void keyboardDriverUpdate(unsigned char scancode);
+void timerDriverUpdate(void);
+
+// Memory functions:
+void mappage(uint32_t address);
+
+int querymode(void);
+int getcs(void);
+void loadPageTable(void* tableAddress);
+void enablePaging(void);
+
+// Variable argument list things:
+#define va_start(v,l)	__builtin_va_start(v,l)
+#define va_end(v)	__builtin_va_end(v)
+#define va_arg(v,l)	__builtin_va_arg(v,l)
+typedef __builtin_va_list va_list;
+
+struct multiboot_aout_symbol_table {
+  uint32_t tabsize;
+  uint32_t strsize, addr, reserved;
+};
+
+struct multiboot_info {
+  uint32_t flags; // Multiboot flags / version
+  uint32_t mem_lower; // available memory from BIOS
+  uint32_t mem_upper;
+  uint32_t boot_device; 
+  uint32_t cmdline; // COmmand line
+  uint32_t mods_count;
+  uint32_t mods_addr;
+  union {
+   struct multiboot_aout_symbol_table aout_sym;
+  } u;
+
+  uint32_t mmap_length;
+  uint32_t mmap_addr;
+};
+
+struct memory_map {
+  uint32_t size;
+  uint32_t baselow, basehigh;
+  uint32_t lenlow, lenhigh;
+  uint32_t type;
+};
+
+typedef struct {
+  char name[32]; // Name of the console
+  unsigned char screendata[80*25]; // All chars in the console!
+} console_t;
+
+typedef struct {
+  uint32_t esp;
+  uint32_t ss;
+  uint32_t kstack;
+  uint32_t ustack;
+  uint32_t cr3;
+
+  uint32_t number;
+  uint32_t parent;
+  uint32_t owner;
+  uint32_t groups;
+  uint32_t timetorun;
+  uint32_t sleep;
+  uint32_t priority;
+  uint32_t filehandle;
+  char naam[32];
+
+  console_t *console;
+} programma_t;
+
+#endif
+
--- a/cos/kernel/snprintf.c	Mon Nov 14 21:31:27 2011 +0100
+++ b/cos/kernel/snprintf.c	Mon Nov 14 21:44:35 2011 +0100
@@ -3,7 +3,20 @@
  */
 #include "kernel.h"
 
-#include "ctype.h"
+/*
+ * NOTE! This ctype does not handle EOF like the standard C
+ * library is required to.
+ */
+
+#define _U	0x01	/* upper */
+#define _L	0x02	/* lower */
+#define _D	0x04	/* digit */
+#define _C	0x08	/* cntrl */
+#define _P	0x10	/* punct */
+#define _S	0x20	/* white space (space/lf/tab) */
+#define _X	0x40	/* hex digit */
+#define _SP	0x80	/* hard space (0x20) */
+
 
 unsigned char _ctype[] = {
 _C,_C,_C,_C,_C,_C,_C,_C,			/* 0-7 */
@@ -31,6 +44,36 @@
 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
 _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
 
+#define __ismask(x) (_ctype[(int)(unsigned char)(x)])
+
+#define isalnum(c)	((__ismask(c)&(_U|_L|_D)) != 0)
+#define isalpha(c)	((__ismask(c)&(_U|_L)) != 0)
+#define iscntrl(c)	((__ismask(c)&(_C)) != 0)
+#define isdigit(c)	((__ismask(c)&(_D)) != 0)
+#define isgraph(c)	((__ismask(c)&(_P|_U|_L|_D)) != 0)
+#define islower(c)	((__ismask(c)&(_L)) != 0)
+#define isprint(c)	((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
+#define ispunct(c)	((__ismask(c)&(_P)) != 0)
+#define isspace(c)	((__ismask(c)&(_S)) != 0)
+#define isupper(c)	((__ismask(c)&(_U)) != 0)
+#define isxdigit(c)	((__ismask(c)&(_D|_X)) != 0)
+
+#define isascii(c) (((unsigned char)(c))<=0x7f)
+#define toascii(c) (((unsigned char)(c))&0x7f)
+
+static inline unsigned char tolower(unsigned char c)
+{
+	if (isupper(c))
+		c -= 'A'-'a';
+	return c;
+}
+
+static inline unsigned char toupper(unsigned char c)
+{
+	if (islower(c))
+		c -= 'a'-'A';
+	return c;
+}
 
 #define MORE_THAN_YOU_WANT	1<<30
 #define MAX_STDOUT_CHARS	255