From 30ea392529451ae347a5da3a692e252f8c8637de Mon Sep 17 00:00:00 2001 From: Agnosto Dvonik Date: Sun, 18 Feb 2024 07:38:08 -0500 Subject: [PATCH] add strlen, unused---- --- Makescript | 2 +- sys/Makescript | 1 + sys/include/fcntl.h | 9 +++++++++ sys/include/memory.h | 5 ++++- sys/include/param.h | 2 ++ sys/lib.c | 12 ++++++++++++ sys/sysinit.c | 10 +++------- sys/video.c | 2 ++ 8 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 sys/include/fcntl.h create mode 100644 sys/include/param.h create mode 100644 sys/lib.c diff --git a/Makescript b/Makescript index a2c1356..d472ea8 100755 --- a/Makescript +++ b/Makescript @@ -2,7 +2,7 @@ OBJ="obj" INCLUDE="-Isys/include" -CFLAGS="-g -m32 -ffreestanding -Wall -Wextra -pedantic -nostdlib $INCLUDE" +CFLAGS="-m32 -ffreestanding -Wall -Wextra -pedantic -nostdlib $INCLUDE" ASFLAGS="-felf32" LDFLAGS="-m elf_i386" diff --git a/sys/Makescript b/sys/Makescript index 40aab9d..c2fd5c4 100644 --- a/sys/Makescript +++ b/sys/Makescript @@ -1,4 +1,5 @@ echo "Kernel Build" +cc $CFLAGS -c sys/lib.c -o $OBJ/lib.o cc $CFLAGS -c sys/video.c -o $OBJ/video.o cc $CFLAGS -c sys/sysinit.c -o $OBJ/sysinit.o diff --git a/sys/include/fcntl.h b/sys/include/fcntl.h new file mode 100644 index 0000000..14faf56 --- /dev/null +++ b/sys/include/fcntl.h @@ -0,0 +1,9 @@ +#ifndef FCNTL_H +#define FCNTL_H + +#define O_RDONLY 0x0000 +#define O_WRONLY 0x0010 +#define O_RDWR 0x0020 +#define O_CREAT 0x0200 + +#endif diff --git a/sys/include/memory.h b/sys/include/memory.h index 715c7fd..205bfaf 100644 --- a/sys/include/memory.h +++ b/sys/include/memory.h @@ -1,8 +1,11 @@ -8 ifndef MEMORY_H +#ifndef MEMORY_H #define MEMORY_H #include +#define EXTMEMBOT 0x100000 +#define PHYSMEMTOP 0x0e000000 + /* * Each allocated memory is stored internally like this: diff --git a/sys/include/param.h b/sys/include/param.h new file mode 100644 index 0000000..4df5117 --- /dev/null +++ b/sys/include/param.h @@ -0,0 +1,2 @@ +#define NDEV 10 +#define ROOTDEV 0 diff --git a/sys/lib.c b/sys/lib.c new file mode 100644 index 0000000..9b61b4d --- /dev/null +++ b/sys/lib.c @@ -0,0 +1,12 @@ +#include + +u32 +strlen(const char *str) +{ + size_t i; + + for (i = 0; str[i] != NULL; i++) + ; + + return i; +} diff --git a/sys/sysinit.c b/sys/sysinit.c index ae5b3f0..07842e9 100644 --- a/sys/sysinit.c +++ b/sys/sysinit.c @@ -3,12 +3,8 @@ void sysinit(void) { + char *howdy = "Om Smart"; + vga_clearscreen(); - vga_write("Om Smert.", 9, 0x0F); - vga_write("Om Smarter.", 11, 0x0F); - for (s16 i = 0; i < 99; i++) { - vga_write("Om Smart.", 9, 0x0F); - vga_write("Om Smarter.", 11, 0x0F); - } - vga_write("fish stick", 10, 0x07); + vga_write(howdy, strlen(howdy), 0x1f); } diff --git a/sys/video.c b/sys/video.c index 71d57b5..93de120 100644 --- a/sys/video.c +++ b/sys/video.c @@ -21,6 +21,8 @@ vga_write(s8 *sequence, s16 size, s8 flags) for (s16 i = 0; i <= (unused = VGA_SIZE - needed_space); i++) { vga_vidmem[i] = vga_vidmem[needed_space + i]; } + unused--; + unused--; } for (s16 i = 0; i < size; i++) {