diff options
Diffstat (limited to '')
-rw-r--r-- | include/lib.h | 8 | ||||
-rw-r--r-- | include/limits.h | 12 | ||||
-rw-r--r-- | include/stdbool.h | 17 | ||||
-rw-r--r-- | include/time.h | 63 | ||||
-rw-r--r-- | user/include/ctype.h (renamed from include/ctype.h) | 0 | ||||
-rw-r--r-- | user/include/elf.h (renamed from include/elf.h) | 0 | ||||
-rw-r--r-- | user/include/error.h (renamed from include/error.h) | 0 | ||||
-rw-r--r-- | user/include/stdio.h (renamed from include/stdio.h) | 16 | ||||
-rw-r--r-- | user/include/stdlib.h (renamed from include/stdlib.h) | 32 | ||||
-rw-r--r-- | user/include/string.h (renamed from include/string.h) | 32 | ||||
-rw-r--r-- | user/include/unistd.h (renamed from include/unistd.h) | 92 |
11 files changed, 50 insertions, 222 deletions
diff --git a/include/lib.h b/include/lib.h deleted file mode 100644 index e8e921d..0000000 --- a/include/lib.h +++ /dev/null @@ -1,8 +0,0 @@ -#include <ctype.h> -#include <error.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string.h> -#include <limits.h> diff --git a/include/limits.h b/include/limits.h deleted file mode 100644 index d4a3190..0000000 --- a/include/limits.h +++ /dev/null @@ -1,12 +0,0 @@ -/** - * @file limits.h - * - * @author Freya Murphy <freya@freyacat.org> - * - * System limits - */ - -#define MAX_FILE_NAME_LEN 256 -#define MAX_OPEN_FILES 256 - -#define MAX_DISKS 8 diff --git a/include/stdbool.h b/include/stdbool.h deleted file mode 100644 index dddf1c9..0000000 --- a/include/stdbool.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file stdbool.h - * @author Freya Murphy <freya@freyacat.org> - * @author Warren R. Carithers - * - * Boolean definitions. - */ - -#ifndef _STDBOOL_H -#define _STDBOOL_H - -// Boolean values -typedef _Bool bool; -#define true 1 -#define false 0 - -#endif /* stdbool.h */ diff --git a/include/time.h b/include/time.h deleted file mode 100644 index 4d339a0..0000000 --- a/include/time.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file time.h - * - * @author Freya Murphy <freya@freyacat.org> - * - * System time structure - */ - -#ifndef TIME_H_ -#define TIME_H_ - -#include <stddef.h> - -typedef struct { - int sec; /// Seconds [0,59] - int min; /// Minutes [0,59] - int hour; /// Hour [0,23] - int mday; /// Day of month [1,31] - int mon; /// Month of year [0,11] - int year; /// Years since 1900 - int wday; /// Day of week [0,6] (Sunday = 0) - int yday; /// Day of year [0,365] - int yn; /// Year number [0,99] - int cen; /// Century [19,20] - int leap; /// If year is a leap year (True == 1) -} time_t; - -typedef enum { - TZ_UTC = 0, - TZ_EST = -5, - TZ_EDT = -4, -} timezone_t; - -/** - * Sets the current timezone - */ -extern void set_timezone(timezone_t tz); - -/** - * Returns current time in UTC - */ -extern time_t get_utctime(void); - -/** - * Returns current time from current Timezone - */ -extern time_t get_localtime(void); - -/** - * Return the time on the system clock - */ -extern size_t get_systemtime(void); - -/** - * Converts the time into a string format - * - * @param time - the current time - * @param format - see manpage for date - * @param buf - the buffer to store it in - */ -extern void timetostr(time_t *time, char *format, char *buf, size_t n); - -#endif /* time.h */ diff --git a/include/ctype.h b/user/include/ctype.h index c5f92b4..c5f92b4 100644 --- a/include/ctype.h +++ b/user/include/ctype.h diff --git a/include/elf.h b/user/include/elf.h index b7e6059..b7e6059 100644 --- a/include/elf.h +++ b/user/include/elf.h diff --git a/include/error.h b/user/include/error.h index b9265b4..b9265b4 100644 --- a/include/error.h +++ b/user/include/error.h diff --git a/include/stdio.h b/user/include/stdio.h index d335968..9e60f55 100644 --- a/include/stdio.h +++ b/user/include/stdio.h @@ -12,19 +12,13 @@ #include <stdarg.h> #include <stddef.h> +// TODO: implement typedef void FILE; -/// standard input -#define stdin ((FILE *)1) -/// standard output -#define stdout ((FILE *)2) -/// standard error -#define stderr ((FILE *)3) - -/// console output -#define stdcon ((FILE *)4) -/// serial output -#define stduart ((FILE *)5) +extern FILE *stdin; +extern FILE *stdout; +#define stdin stdin +#define stdout stdout /** * Prints out a char diff --git a/include/stdlib.h b/user/include/stdlib.h index 1455a1f..40bffde 100644 --- a/include/stdlib.h +++ b/user/include/stdlib.h @@ -11,8 +11,6 @@ #include <stddef.h> -#define PAGE_SIZE 4096 - /** * converts single digit int to base 36 * @param i - int @@ -221,34 +219,4 @@ extern void *realloc(void *ptr, size_t size); */ extern void free(void *ptr); -/** - * Allocate a single page of memory - * - * @returns the address allocated or NULL on failure - */ -extern void *alloc_page(void); - -/** - * Allocate size_t amount of contiguous virtual pages - * - * @param count - the number of pages to allocate - * @returns the address allocated or NULL on failure - */ -extern void *alloc_pages(size_t count); - -/** - * Free allocated pages. - * - * @param ptr - the pointer provided by alloc_page or alloc_pages - */ -extern void free_pages(void *ptr); - -/** - * Abort the current process with a given message. - * - * @param format - the format string - * @param ... - variable args for the format - */ -__attribute__((noreturn)) extern void panic(const char *format, ...); - #endif /* stlib.h */ diff --git a/include/string.h b/user/include/string.h index f966981..4d32f57 100644 --- a/include/string.h +++ b/user/include/string.h @@ -52,38 +52,6 @@ extern void *memmove(void *restrict dest, const void *restrict src, size_t n); extern void *memset(void *restrict dest, int c, size_t n); /** - * Copy the first n bytes from memory area src to memory area dest. The memory - * areas must not overlap. - * @param dest - the destination - * @param src - the source - * @param n - the byte count - * @returns a pointer to dest - */ -extern volatile void *memcpyv(volatile void *restrict dest, - const volatile void *restrict src, size_t n); - -/** - * Copy the first n bytes from memory area src to memory area dest. The memory - * areas may overlap; memmove behaves as though the bytes are first copied to a - * temporary array. - * @param dest - the destination - * @param src - the source - * @param n - the byte count - * @returns a pointer to dest - */ -extern volatile void *memmovev(volatile void *restrict dest, - const volatile void *restrict src, size_t n); - -/** - * Fill the first n bytes of the memory region dest with the constant byte c. - * @param dest - the destination - * @param c - the byte to write - * @param n - the byte count - * @returns a pointer to dest - */ -extern volatile void *memsetv(volatile void *restrict dest, int c, size_t n); - -/** * Calculates the length of the string pointed to by str, excluding * the terminating null byte * @param str - the string pointer diff --git a/include/unistd.h b/user/include/unistd.h index f9838f1..1f83abc 100644 --- a/include/unistd.h +++ b/user/include/unistd.h @@ -6,29 +6,29 @@ * Universial system definitions for userspace. */ -#ifndef _UNISTD_H -#define _UNISTD_H +#ifndef UNISTD_H_ +#define UNISTD_H_ #include <stdint.h> #include <stddef.h> /* System Call Definitions */ -typedef uint_t pid_t; +typedef unsigned short pid_t; /** - * Terminates the calling process and does not return. + * terminates the calling process and does not return. + * * @param status - the status code to exit with */ -__attribute__((noreturn)) extern void exit(int32_t status); +__attribute__((noreturn)) extern void exit(int status); /** - * Sleeps current process until a child process terminates + * sleeps current process until a child process terminates * * @param pid - pid of the desired child, or 0 for any child - * @param status - Pointer to int32_t into which the child's status is placed, + * @param status - pointer to int32_t into which the child's status is placed, * or NULL - * * @return The pid of the terminated child, or an error code * * If there are no children in the system, returns an error code (*status @@ -38,18 +38,18 @@ __attribute__((noreturn)) extern void exit(int32_t status); * terminated but hasn't yet been cleaned up, cleans up that process and * returns its information; otherwise, blocks until a child terminates. */ -extern int waitpid(pid_t pid, int32_t *status); +extern int waitpid(pid_t pid, int *status); /** - * Create a duplicate of the calling process + * create a duplicate of the calling process * - * @return parent - the pid of the new child, or an error code - * child - 0 + * @return parent - the pid of the new child, or an error code + * child - 0 */ extern int fork(void); /** - * Replace the memory image of the calling process + * replace the memory image of the calling process * * @param prog - program table index of the program to exec * @param args - the command-line argument vector @@ -57,126 +57,124 @@ extern int fork(void); * Does not return if it succeeds; if it returns, something has * gone wrong. */ -extern void exec(uint_t prog, char **args); +extern void exec(const char *filename, char **args); /** - * Open a stream with a given filename + * open a stream with a given filename * * @param filename - the name of the file to open * @return the file descriptior of the open file or a negative error code. - * TODO: fmurphy implement */ -extern int open(char *filename); +extern int open(const char *filename); /** - * Closes a stream with the given file descriptior + * closes a stream with the given file descriptior + * * @param fd - the file descriptior of the open stream - * TODO: fmurphy implement */ extern void close(int fd); /** - * Read into a buffer from a stream + * read into a buffer from a stream * * @param fd - file stream to read from * @param buf - buffer to read into * @param nbytes - maximum capacity of the buffer - * * @return - The count of bytes transferred, or an error code - * TODO: fmurphy FD */ extern int read(int fd, void *buffer, size_t nbytes); /** - * Write from a buffer to a stream + * write from a buffer to a stream * * @param fd - file stream to write to * @param buf - buffer to write from * @param nbytes - maximum capacity of the buffer - * * @return - The count of bytes transferred, or an error code - * TODO: fmurphy FD */ extern int write(int fd, const void *buffer, size_t nbytes); /** - * Gets the pid of the calling process + * gets the pid of the calling process * * @return the pid of this process */ extern pid_t getpid(void); /** - * Gets the parent pid of the current process + * gets the parent pid of the current process * * @return the parent pid of the current process, or 0 if init */ extern pid_t getppid(void); /** - * Gets the current system time + * gets the current system time * * @return the system time - * TODO: CHANGE TIME TO 64bits!! */ -extern ulong_t gettime(void); +extern unsigned long gettime(void); /** - * Gets the scheduling priority of the calling process + * gets the scheduling priority of the calling process * * @return the process' priority */ -extern uint_t getprio(void); +extern unsigned int getprio(void); /** - * Sets the scheduling priority of the calling process + * sets the scheduling priority of the calling process * * @param new - the desired new priority - * * @return the old priority value */ -extern uint_t setprio(uint_t new); +extern unsigned int setprio(unsigned int new); /** - * Terminates a process + * terminates a process * * @param pid - the pid of the process to kill - * * @return 0 on success, else an error code */ -extern int32_t kill(pid_t pid); +extern int kill(pid_t pid); /** - * Put the current process to sleep for some length of time + * put the current process to sleep for some length of time * * @param ms - desired sleep time (in ms), or 0 to yield the CPU - * * @return the time the process spent sleeping (in ms) */ -extern int sleep(uint32_t ms); +extern int sleep(unsigned long ms); /** * Wait for any child to exit * - * @param status - Pointer to int32_t into which the child's status is placed, + * @param status - pointer to int32_t into which the child's status is placed, * or NULL - * * @return The pid of the terminated child, or an error code * * Analogous to waitpid(0,status) */ -extern int wait(int32_t *status); +extern int wait(int *status); /** * Spawn a new process running a different program * * @param prog - program table index of the program to spawn * @param args - the command-line argument vector for the process - * - * @return The pid of the child, or an error code + * @return the pid of the child, or an error code * * Analogous to calling fork and exec */ -extern int spawn(uint_t prog, char **args); +extern int spawn(pid_t prog, char **args); + +/** + * Increment the program's data space by increment bytes. + * + * @param increment - the amount in bytes to increment the heap + * @return the previos program break on success, or NULL on failure + * + */ +extern void *sbrk(intptr_t increment); #endif /* unistd.h */ |