-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b299df4
commit 7384d0c
Showing
18 changed files
with
1,355 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ mkfs | |
kernel/kernel | ||
user/usys.S | ||
.gdbinit | ||
compile_commands.json | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#ifndef _UCC_ASSERT_H | ||
#define _UCC_ASSERT_H | ||
|
||
#ifdef NDEBUG | ||
|
||
#define assert(expr) ((void) 0) | ||
|
||
#else | ||
|
||
void __assert_fail(const char *, const char *, int); | ||
#define assert(expr) \ | ||
((expr) ? (void) 0 : __assert_fail(#expr, __FILE__, __LINE__)) | ||
|
||
#endif | ||
|
||
#endif /* assert.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _UCC_CTYPE_H | ||
#define _UCC_CTYPE_H | ||
|
||
int isalnum(int); | ||
int isalpha(int); | ||
int isdigit(int); | ||
int islower(int); | ||
int isspace(int); | ||
int isupper(int); | ||
int tolower(int); | ||
int toupper(int); | ||
|
||
#endif /* ctype.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef _UCC_LIMITS_H | ||
#define _UCC_LIMITS_H | ||
|
||
#define CHAR_BIT 8 | ||
#define SCHAR_MAX 127 | ||
#define SCHAR_MIN (-128) | ||
#define UCHAR_MAX 255 | ||
#define CHAR_MAX 127 | ||
#define CHAR_MIN (-128) | ||
#define SHRT_MAX 32767 | ||
#define SHRT_MIN (-32768) | ||
#define USHRT_MAX 65535 | ||
#define INT_MAX 2147483647 | ||
#define INT_MIN (-2147483648) | ||
#define UINT_MAX 4294967295 | ||
#define LONG_MAX INT_MAX | ||
#define LONG_MIN INT_MIN | ||
#define ULONG_MAX UINT_MAX | ||
|
||
#endif /* limits.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _UCC_STDARG_H | ||
#define _UCC_STDARG_H | ||
|
||
#define va_arg(ap, type) (*((type *)(ap = (type *)ap + 1) - 1)) | ||
#define va_start(ap, arg) (ap = &(arg) + 1) | ||
#define va_end(ap) ((void) 0) | ||
typedef void *va_list; | ||
|
||
#endif /* stdarg.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _UCC_STDBOOL_H | ||
#define _UCC_STDBOOL_H | ||
|
||
#define bool int | ||
#define true 1 | ||
#define false 0 | ||
#define __bool_true_false_are_defined 1 | ||
|
||
#endif /* stdbool.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _UCC_STDDEF_H | ||
#define _UCC_STDDEF_H | ||
|
||
#define NULL 0 | ||
typedef unsigned size_tt; | ||
typedef int ssize_t; | ||
typedef int ptrdiff_tt; | ||
|
||
#endif /* stddef.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#ifndef _UCC_STDIO_H | ||
#define _UCC_STDIO_H | ||
|
||
#include <stdarg.h> | ||
#include "include/stddef.h" | ||
|
||
#ifdef NULL | ||
#undef NULL | ||
#endif | ||
|
||
#define NULL 0 | ||
#define EOF (-1) | ||
#define BUFSIZ 1024 | ||
#define OPEN_MAX 10 | ||
|
||
typedef struct _iobuf { | ||
int cnt; /* characters left */ | ||
char *ptr; /* next character position */ | ||
char *base; /* location of the buffer */ | ||
int flag; /* mode of the file access */ | ||
int fd; /* file descriptor */ | ||
} FILE; | ||
|
||
extern FILE _iob[OPEN_MAX]; | ||
|
||
#define stdin (&_iob[0]) | ||
#define stdout (&_iob[1]) | ||
#define stderr (&_iob[2]) | ||
|
||
enum _flags { | ||
_READ = 01, | ||
_WRITE = 02, | ||
_UNBUF = 04, | ||
_EOF = 010, | ||
_ERR = 020, | ||
_LNBUF = 040 | ||
}; | ||
|
||
int _fillbuf(FILE *); | ||
int _flushbuf(int, FILE *); | ||
int fflush(FILE *); | ||
|
||
#define feof(p) (((p)->flag & _EOF) != 0) | ||
#define ferror(p) (((p)->flag & _ERR) != 0) | ||
#define fileno(p) ((p)->fd) | ||
|
||
#define getc(p) fgetc(p) | ||
#define putc(x, p) fputc(x, p) | ||
#define getchar() getc(stdin) | ||
#define putchar(x) putc((x), stdout) | ||
|
||
|
||
int fputc(int, FILE *); | ||
int fgetc(FILE *); | ||
int puts(char *); | ||
int fputs(char *, FILE *); | ||
char *fgets(char *, int, FILE *); | ||
char *gets(char *); | ||
|
||
|
||
int printf(const char *, ...); | ||
int fprintf(FILE *, const char *, ...); | ||
int vprintf(const char *, va_list); | ||
int vfprintf(FILE *, const char *, va_list); | ||
|
||
#endif /* stdio.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _UCC_STDLIB_H | ||
#define _UCC_STDLIB_H | ||
|
||
#include "include/stddef.h" | ||
|
||
#define RAND_MAX 2147483647 | ||
|
||
void abort(void); | ||
int abs(int); | ||
long strtol(const char *, char **, int); | ||
int rand(void); | ||
void srand(unsigned); | ||
void *malloc(size_tt); | ||
void *realloc(void *, size_tt); | ||
void *calloc(size_tt, size_tt); | ||
void free(void *); | ||
void exit(int); | ||
|
||
#endif /* stdlib.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef _UCC_STRING_H | ||
#define _UCC_STRING_H | ||
|
||
#include <stddef.h> | ||
|
||
size_tt strlen(const char *); | ||
int strcmp(const char *, const char *); | ||
int strncmp(const char *, const char *, size_tt); | ||
char *strchr(const char *, int); | ||
char *strcpy(char *, const char *); | ||
char *strncpy(char *, const char *, size_tt); | ||
void *memset(void *, int, size_tt); | ||
void *memcpy(void *, const void *, size_tt); | ||
void *memmove(void*, const void*, size_tt); | ||
|
||
#endif /* string.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#ifndef _UCC_TERMIOS_H | ||
#define _UCC_TERMIOS_H | ||
|
||
typedef unsigned int tcflag_t; | ||
typedef unsigned char cc_t; | ||
|
||
#define NCCS 32 | ||
struct termios { | ||
tcflag_t c_iflag; /* input modes */ | ||
tcflag_t c_oflag; /* output modes */ | ||
tcflag_t c_cflag; /* control modes */ | ||
tcflag_t c_lflag; /* local modes */ | ||
cc_t c_cc[NCCS]; /* special characters */ | ||
}; | ||
|
||
int tcgetattr(int, struct termios *); | ||
void cfmakeraw(struct termios *); | ||
int tcsetattr(int, int, const struct termios *); | ||
|
||
/* c_lflag bits */ | ||
#define ECHO 0000010 | ||
#define ICANON 0000002 | ||
|
||
/* tcsetattr uses these */ | ||
#define TCSANOW 0 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef _XV6_UNISTD_H | ||
#define _XV6_UNISTD_H | ||
|
||
#include "include/stddef.h" | ||
|
||
struct stat; | ||
struct rtcdate; | ||
|
||
ssize_t write(int, const void *, size_tt); | ||
ssize_t read(int, void *, size_tt); | ||
int close(int); | ||
|
||
int fork(void); | ||
// int exit(void); | ||
int wait(void); | ||
int pipe(int*); | ||
int kill(int); | ||
int exec(char*, char**); | ||
#ifndef _UCC_FCNTL_H | ||
int open(char*, int); | ||
#endif | ||
int mknod(char*, short, short); | ||
int unlink(char*); | ||
int fstat(int fd, struct stat*); | ||
int link(char*, char*); | ||
int mkdir(char*); | ||
int chdir(char*); | ||
int dup(int); | ||
int getpid(void); | ||
char* sbrk(int); | ||
int sleep(int); | ||
int uptime(void); | ||
int halt(void); | ||
|
||
#endif /* unistd.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
struct rtcdate { | ||
uint second; | ||
uint minute; | ||
uint hour; | ||
uint day; | ||
uint month; | ||
uint year; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.