add strlen, unused----

This commit is contained in:
Agnosto Dvonik 2024-02-18 07:38:08 -05:00
parent 6c72923c9e
commit 30ea392529
8 changed files with 34 additions and 9 deletions

View File

@ -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"

View File

@ -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

9
sys/include/fcntl.h Normal file
View File

@ -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

View File

@ -1,8 +1,11 @@
8 ifndef MEMORY_H
#ifndef MEMORY_H
#define MEMORY_H
#include <types.h>
#define EXTMEMBOT 0x100000
#define PHYSMEMTOP 0x0e000000
/*
* Each allocated memory is stored internally like this:

2
sys/include/param.h Normal file
View File

@ -0,0 +1,2 @@
#define NDEV 10
#define ROOTDEV 0

12
sys/lib.c Normal file
View File

@ -0,0 +1,12 @@
#include <types.h>
u32
strlen(const char *str)
{
size_t i;
for (i = 0; str[i] != NULL; i++)
;
return i;
}

View File

@ -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);
}

View File

@ -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++) {