build system refresh
This commit is contained in:
1
programs/rockterm/.gitignore
vendored
Normal file
1
programs/rockterm/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
rockterm
|
||||
21
programs/rockterm/crt0.S
Normal file
21
programs/rockterm/crt0.S
Normal file
@@ -0,0 +1,21 @@
|
||||
.global _start
|
||||
.extern exit
|
||||
.section .text
|
||||
_start:
|
||||
xor %ebp, %ebp
|
||||
|
||||
mov (%esp), %eax
|
||||
lea 4(%esp), %ebx
|
||||
lea 8(%esp,%eax,4), %ecx
|
||||
|
||||
and $-16, %esp
|
||||
|
||||
push %ecx
|
||||
push %ebx
|
||||
push %eax
|
||||
|
||||
call main
|
||||
|
||||
push %eax
|
||||
call exit
|
||||
|
||||
31
programs/rockterm/linker.ld
Normal file
31
programs/rockterm/linker.ld
Normal file
@@ -0,0 +1,31 @@
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x40000000;
|
||||
|
||||
.text ALIGN(4K) :
|
||||
{
|
||||
/* Force the crt0.o entry code to be placed FIRST in memory */
|
||||
KEEP(*crt0.o(.text))
|
||||
*(.text .text.*)
|
||||
}
|
||||
|
||||
.rodata ALIGN(4K) :
|
||||
{
|
||||
*(.rodata .rodata.*)
|
||||
}
|
||||
|
||||
.data ALIGN(4K) :
|
||||
{
|
||||
*(.data .data.*)
|
||||
}
|
||||
|
||||
.bss ALIGN(4K) :
|
||||
{
|
||||
_bss_start = .;
|
||||
*(.bss .bss.*)
|
||||
*(COMMON)
|
||||
_bss_end = .;
|
||||
}
|
||||
}
|
||||
74
programs/rockterm/main.c
Normal file
74
programs/rockterm/main.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/video.h>
|
||||
|
||||
typedef struct {
|
||||
|
||||
} font_t;
|
||||
|
||||
void term_write_char(char c);
|
||||
void render_char_at(char c, int x, int y);
|
||||
|
||||
int spawn_shell();
|
||||
|
||||
int ptys;
|
||||
int ptym;
|
||||
|
||||
void* fb;
|
||||
fb_info_t fb_info;
|
||||
|
||||
int terminal_col = 0;
|
||||
int terminal_row = 0;
|
||||
|
||||
font_t* terminal_font = NULL;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
int vga_fd = open("/dev/vga");
|
||||
if (vga_fd == -1) return 1;
|
||||
|
||||
int kbd_fd = open("/dev/kbd");
|
||||
if (kbd_fd == -1) return 1;
|
||||
|
||||
int res = ioctl(vga_fd, FBIOGET_INFO, &fb_info);
|
||||
if (!res) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
mmap(vga_fd);
|
||||
|
||||
// if (!spawn_shell()) {
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void render_char_at(char c, int x, int y) {
|
||||
if (!terminal_font) return;
|
||||
}
|
||||
|
||||
void term_write_char(char c) {
|
||||
|
||||
}
|
||||
|
||||
int spawn_shell() {
|
||||
ptym = pty(&ptys);
|
||||
|
||||
if (fork() == 0) {
|
||||
close(ptym);
|
||||
dup2(ptys, 0);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
|
||||
if (!exec("/usr/bin/rocksh")) return 0;
|
||||
}
|
||||
|
||||
close(ptys);
|
||||
dup2(ptym, 0);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
return 1;
|
||||
}
|
||||
29
programs/rockterm/makefile
Normal file
29
programs/rockterm/makefile
Normal file
@@ -0,0 +1,29 @@
|
||||
CC = i686-elf-gcc
|
||||
LD = i686-elf-ld
|
||||
|
||||
SYSROOT = ../sysroot
|
||||
USR_INCLUDE = $(SYSROOT)/usr/include
|
||||
USR_LIB = $(SYSROOT)/usr/lib
|
||||
|
||||
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I$(USR_INCLUDE)
|
||||
LDFLAGS = -m elf_i386 -nostdlib
|
||||
|
||||
TARGET = rockterm
|
||||
|
||||
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 $(USR_LIB)/*
|
||||
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o $(USR_LIB)/* -o $(TARGET)
|
||||
cp $(TARGET) $(SYSROOT)/usr/bin
|
||||
|
||||
clean:
|
||||
rm -f *.o $(TARGET) compile_commands.json
|
||||
rm -rf .cache
|
||||
|
||||
.PHONY: all clean test
|
||||
Reference in New Issue
Block a user