removed pdclib, strange things were happening..., user shell kinda works now
This commit is contained in:
BIN
programs/lib/rlibc.a
Normal file
BIN
programs/lib/rlibc.a
Normal file
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
printf("RockOS booting...\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
CC = i686-elf-gcc
|
||||
LD = i686-elf-ld
|
||||
|
||||
CFLAGS = -ffreestanding -O2 -Wall -Wextra -ffunction-sections -fdata-sections -I../rocklibc/include
|
||||
LDFLAGS = -m elf_i386 -nostdlib --gc-sections
|
||||
|
||||
TARGET = origin.elf
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
crt0.o: crt0.S
|
||||
$(CC) $(CFLAGS) -c crt0.S -o crt0.o
|
||||
|
||||
main.o: main.c
|
||||
$(CC) $(CFLAGS) -c main.c -o main.o
|
||||
|
||||
$(TARGET): crt0.o main.o ../rocklibc/rlibc.a
|
||||
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o ../rocklibc/rlibc.a $(shell $(CC) -print-libgcc-file-name) -o $(TARGET)
|
||||
cp $(TARGET) ../initrd
|
||||
|
||||
clean:
|
||||
rm -f *.o $(TARGET)
|
||||
|
||||
.PHONY: all clean test
|
||||
36
programs/rocksh/compile_commands.json
Normal file
36
programs/rocksh/compile_commands.json
Normal file
@@ -0,0 +1,36 @@
|
||||
[
|
||||
{
|
||||
"arguments": [
|
||||
"/home/slinky/opt/cross/bin/i686-elf-gcc",
|
||||
"-ffreestanding",
|
||||
"-O2",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-I../../rocklibc/include",
|
||||
"-c",
|
||||
"-o",
|
||||
"crt0.o",
|
||||
"crt0.S"
|
||||
],
|
||||
"directory": "/home/slinky/source/RockOS/programs/rocksh",
|
||||
"file": "/home/slinky/source/RockOS/programs/rocksh/crt0.S",
|
||||
"output": "/home/slinky/source/RockOS/programs/rocksh/crt0.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
"/home/slinky/opt/cross/bin/i686-elf-gcc",
|
||||
"-ffreestanding",
|
||||
"-O2",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-I../../rocklibc/include",
|
||||
"-c",
|
||||
"-o",
|
||||
"main.o",
|
||||
"main.c"
|
||||
],
|
||||
"directory": "/home/slinky/source/RockOS/programs/rocksh",
|
||||
"file": "/home/slinky/source/RockOS/programs/rocksh/main.c",
|
||||
"output": "/home/slinky/source/RockOS/programs/rocksh/main.o"
|
||||
}
|
||||
]
|
||||
@@ -1,14 +1,14 @@
|
||||
.global _start
|
||||
|
||||
.extern exit
|
||||
.section .text
|
||||
_start:
|
||||
xor %ebp, %ebp
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
|
||||
mov (%esp), %eax
|
||||
lea 4(%esp), %ebx
|
||||
lea 8(%esp, %eax, 4), %ecx
|
||||
lea 8(%esp,%eax,4), %ecx
|
||||
|
||||
and $-16, %esp
|
||||
|
||||
push %ecx
|
||||
push %ebx
|
||||
@@ -17,6 +17,5 @@ _start:
|
||||
call main
|
||||
|
||||
push %eax
|
||||
1: jmp 1b
|
||||
call exit
|
||||
|
||||
46
programs/rocksh/main.c
Normal file
46
programs/rocksh/main.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* shell_prompt = "rocksh> ";
|
||||
|
||||
static void process_cmd(const char* cmd) {
|
||||
size_t cmd_len = strlen(cmd);
|
||||
if (cmd_len < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "exit") == 0) {
|
||||
printf("bye!\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("command not recognized: %s\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
char cmd[128];
|
||||
size_t p = 0;
|
||||
|
||||
printf("%s", shell_prompt);
|
||||
|
||||
while (1) {
|
||||
char c = getchar();
|
||||
printf("%c", c);
|
||||
if (c != '\n') {
|
||||
cmd[p++] = c;
|
||||
continue;
|
||||
}
|
||||
|
||||
cmd[p] = 0;
|
||||
process_cmd(cmd);
|
||||
memset(cmd, 0, 128);
|
||||
p = 0;
|
||||
printf("%s", shell_prompt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
programs/rocksh/makefile
Normal file
23
programs/rocksh/makefile
Normal file
@@ -0,0 +1,23 @@
|
||||
CC = i686-elf-gcc
|
||||
LD = i686-elf-ld
|
||||
|
||||
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I../../rocklibc/include
|
||||
LDFLAGS = -m elf_i386 -nostdlib
|
||||
|
||||
TARGET = rocksh.elf
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
crt0.o: crt0.S
|
||||
$(CC) $(CFLAGS) -c crt0.S -o crt0.o
|
||||
|
||||
main.o: main.c
|
||||
$(CC) $(CFLAGS) -c main.c -o main.o
|
||||
|
||||
$(TARGET): crt0.o main.o ../lib/rlibc.a
|
||||
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o ../lib/rlibc.a -o $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f *.o $(TARGET)
|
||||
|
||||
.PHONY: all clean test
|
||||
Reference in New Issue
Block a user