summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Makefile8
-rw-r--r--src/common/include/errno.h42
-rw-r--r--src/common/include/sched.h24
-rw-r--r--src/common/include/stdlib_common.h22
-rw-r--r--src/common/include/string.h22
-rw-r--r--src/common/include/tce/syscalls.h38
-rw-r--r--src/common/include/tce/vfs.h42
-rw-r--r--src/common/include/types.h17
-rw-r--r--src/common/sched.c26
-rw-r--r--src/common/string.c81
10 files changed, 0 insertions, 322 deletions
diff --git a/src/common/Makefile b/src/common/Makefile
deleted file mode 100644
index 8698100..0000000
--- a/src/common/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-Out = _common.o
-Obj = string.o sched.o
-ExtObj =
-
-include $(SrcPath)/common.make
-
-LDFLAGS += -r
-CFLAGS += -I $(SrcPath)/common/include
diff --git a/src/common/include/errno.h b/src/common/include/errno.h
deleted file mode 100644
index fe60d81..0000000
--- a/src/common/include/errno.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef _DEF_ERRNO_H
-#define _DEF_ERRNO_H
-
-// Copied from /usr/include/asm-generic/errno-base.h on a standard Linux system
-// Most of these will NOT be used here.
-
-#define EPERM 1 /* Operation not permitted */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Argument list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No child processes */
-#define EAGAIN 11 /* Try again */
-#define ENOMEM 12 /* Out of memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#define ENOTBLK 15 /* Block device required */
-#define EBUSY 16 /* Device or resource busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* File table overflow */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math argument out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-
-#endif
diff --git a/src/common/include/sched.h b/src/common/include/sched.h
deleted file mode 100644
index 1fe148d..0000000
--- a/src/common/include/sched.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef DEF_MUTEX_H
-#define DEF_MUTEX_H
-
-#include <types.h>
-
-#define MUTEX_LOCKED 1
-#define MUTEX_UNLOCKED 0
-
-//A mutex is just an uint32_t
-typedef uint32_t mutex_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int mutex_lock(mutex_t* mutex); //wait for mutex to be free
-int mutex_lockE(mutex_t* mutex); //lock mutex only if free, returns !0 if locked, 0 if was busy
-void mutex_unlock(mutex_t* mutex);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/common/include/stdlib_common.h b/src/common/include/stdlib_common.h
deleted file mode 100644
index dc40b96..0000000
--- a/src/common/include/stdlib_common.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _DEF_STDLIB_H
-#define _DEF_STDLIB_H
-
-#include <types.h>
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void *memcpy(void *dest, const void *src, int count);
-void *memset(void *dest, int val, int count);
-uint16_t *memsetw(uint16_t *dest, uint16_t val, int count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/src/common/include/string.h b/src/common/include/string.h
deleted file mode 100644
index 19e87c1..0000000
--- a/src/common/include/string.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _DEF_STRING_H
-#define _DEF_STRING_H
-
-// #include <stdlib.h>
-#include <types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int strlen(const char *str);
-char *strcpy(char *dest, const char *src);
-char *strdup(const char *src); // uses malloc, that's bad
-char *strchr(const char *str, char c);
-char *strcat(char *dest, const char *src);
-int strcmp(const char *s1, const char *s2);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/common/include/tce/syscalls.h b/src/common/include/tce/syscalls.h
deleted file mode 100644
index 6c67523..0000000
--- a/src/common/include/tce/syscalls.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef DEF_TCE_SYSCALLS_H
-#define DEF_TCE_SYSCALLS_H
-
-#define SC_THREAD_EXIT 1
-#define SC_SCHEDULE 2
-#define SC_THREAD_SLEEP 3
-#define SC_PROCESS_EXIT 4
-#define SC_PRINTK 5
-#define SC_THREAD_NEW 6
-#define SC_IRQ_WAIT 7
-#define SC_PROC_PRIV 8
-
-#define SC_SBRK 10
-#define SC_BRK 11
-// NOT YET IMPLEMENTED
-#define SC_MMAP 12
-#define SC_MUNMAP 13
-
-#define SC_OPEN 20
-#define SC_OPEN_RELATIVE 21
-#define SC_STAT 22
-#define SC_STAT_RELATIVE 23
-#define SC_STATF 24
-#define SC_CLOSE 25
-#define SC_READ 26
-#define SC_WRITE 27
-#define SC_LINK 28
-
-
-// ERRORS
-#define E_NOT_IMPLEMENTED -1
-#define E_NOT_FOUND -2
-#define E_INVALID_FD -3
-#define E_TOO_SHORT -4 // not enough space for data to be copied to
-#define E_INVALID_RANGE -5
-#define E_INVALID -6 // anything went wrong - invalid parameter, usually
-
-#endif
diff --git a/src/common/include/tce/vfs.h b/src/common/include/tce/vfs.h
deleted file mode 100644
index 20ea03b..0000000
--- a/src/common/include/tce/vfs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef DEF_TCE_VFS_H
-#define DEF_TCE_VFS_H
-
-#include <types.h>
-
-typedef size_t FILE;
-
-typedef struct _file_info {
- uint32_t type;
- uint32_t dev_type;
- uint32_t mode;
- uint32_t uid, gid;
- size_t size;
-} file_info;
-
-// file open flags
-#define FM_READ 0x00000001
-#define FM_WRITE 0x00000002
-#define FM_APPEND 0x00000004
-#define FM_TRUNC 0x00000008
-#define FM_CREATE 0x00000010
-#define FM_DELETE 0x00000020
-
-// link modes
-#define LM_SYMLINK 1
-#define LM_HARDLINK 2
-#define LM_MOUNT 3
-#define LM_OUTPUT_TO 4
-
-// file type flags
-#define FT_FILE 0x00000001
-#define FT_DIR 0x00000002
-#define FT_SYMLINK 0x00000004
-#define FT_DEV 0x00000008
-#define FT_TERMINAL 0x00000010
-
-// device types
-#define DT_BLOCK 1
-#define DT_KEYBOARD 2
-#define DT_DISPLAY 3
-
-#endif
diff --git a/src/common/include/types.h b/src/common/include/types.h
deleted file mode 100644
index e7c1a35..0000000
--- a/src/common/include/types.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef DEF_TYPES_H
-#define DEF_TYPES_H
-
-typedef unsigned long long uint64_t;
-typedef unsigned long int uint32_t;
-typedef unsigned short uint16_t;
-typedef unsigned char uint8_t;
-typedef long long int64_t;
-typedef int int32_t;
-typedef short int16_t;
-typedef char int8_t;
-
-typedef long unsigned int size_t;
-
-#define NULL 0
-
-#endif
diff --git a/src/common/sched.c b/src/common/sched.c
deleted file mode 100644
index 29ea8a8..0000000
--- a/src/common/sched.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <sched.h>
-
-/* Internal use only. This function is atomic, meaning it cannot be interrupted by a system task switch. */
-static uint32_t atomic_exchange(uint32_t* ptr, uint32_t newval) {
- uint32_t r;
- asm volatile("xchg (%%ecx), %%eax" : "=a"(r) : "c"(ptr), "a"(newval));
- return r;
-}
-
-int mutex_lock(uint32_t* mutex) {
- while (atomic_exchange(mutex, MUTEX_LOCKED) == MUTEX_LOCKED) {
- schedule();
- }
- return 0;
-}
-
-int mutex_lockE(uint32_t* mutex) {
- if (atomic_exchange(mutex, MUTEX_LOCKED) == MUTEX_LOCKED) {
- return 0;
- }
- return 1;
-}
-
-void mutex_unlock(uint32_t* mutex) {
- *mutex = MUTEX_UNLOCKED;
-}
diff --git a/src/common/string.c b/src/common/string.c
deleted file mode 100644
index 3825e47..0000000
--- a/src/common/string.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <string.h>
-#include <stdlib_common.h>
-
-int strlen(const char *str) {
- int i = 0;
- while (str[i++]);
- return i;
-}
-
-char *strchr(const char *str, char c) {
- while (*str) {
- if (*str == c) return (char*)str;
- str++;
- }
- return NULL;
-}
-
-char *strcpy(char *dest, const char *src) {
- memcpy(dest, src, strlen(src) + 1);
- return (char*)src;
-}
-
-char *strdup(const char *src) {
- char* ret = malloc(strlen(src) + 1);
- if (ret == NULL) return ret;
- strcpy(ret, src);
- return ret;
-}
-
-char *strcat(char *dest, const char *src) {
- char *dest2 = dest;
- dest2 += strlen(dest) - 1;
- while (*src) {
- *dest2 = *src;
- src++;
- dest2++;
- }
- *dest2 = 0;
- return dest;
-}
-
-int strcmp(const char *s1, const char *s2) {
- while ((*s1) && (*s1 == *s2)) {
- s1++;
- s2++;
- }
- return (* (unsigned char*)s1 - *(unsigned char*)s2);
-}
-
-void *memcpy(void *vd, const void *vs, int count) {
- uint8_t *dest = (uint8_t*)vd, *src = (uint8_t*)vs;
- uint32_t f = count % 4, n = count / 4, i;
- const uint32_t* s = (uint32_t*)src;
- uint32_t* d = (uint32_t*)dest;
- for (i = 0; i < n; i++) {
- d[i] = s[i];
- }
- if (f != 0) {
- for (i = count - f; i < count; i++) {
- dest[i] = src[i];
- }
- }
- return vd;
-}
-
-void *memset(void *dest, int val, int count) {
- uint8_t *dest_c = (uint8_t*)dest;
- int i;
- for (i = 0; i < count; i++) {
- dest_c[i] = val;
- }
- return dest;
-}
-
-uint16_t *memsetw(uint16_t *dest, uint16_t val, int count) {
- int i;
- for (i = 0; i < count; i++) {
- dest[i] = val;
- }
- return dest;
-}