Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xxx baremetal #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions xxx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.PHONY: build debug gdb

NASHURL = "https://github.com/NeowayLabs/nash/releases/download/v0.2.1/nash"
NASHPATH = ./scripts/.nash
NASHBIN = ./scripts/bin/nash
NASHEXEC := NASHPATH=$(NASHPATH) $(NASHBIN)

all: clean deps build build-baremetal

clean:
$(NASHEXEC) ./make.sh clean

deps: $(NASHBIN) scripts/BootProg/mkimg144 scripts/BootProg/flp144.bin

scripts/BootProg/flp144.bin: scripts/BootProg
cd scripts/BootProg && nasm -f bin flp144.asm -o flp144.bin

scripts/BootProg/mkimg144: scripts/BootProg
cd scripts/BootProg && smlrcc mkimg144.c -o mkimg144

scripts/BootProg:
mkdir -p scripts
cd scripts && git clone [email protected]:alexfru/BootProg.git

$(NASHBIN):
mkdir -p ./scripts/bin
wget -c $(NASHURL) -O $(NASHBIN)
chmod +x $(NASHBIN)
$(NASHBIN) -version
mkdir -p $(NASHPATH)/lib
cd $(NASHPATH)/lib && git clone [email protected]:NeowayLabs/nashlib.git

build: $(NASHBIN)
$(NASHEXEC) ./make.sh build

baremetal: deps
$(NASHEXEC) ./make.sh baremetal

test:
$(NASHEXEC) ./make.sh test

gdb:
$(NASHEXEC) ./make.sh debug-gdb

debug:
gdb -ex "set architecture 386:386" \
-ex "set disassembly-flavor intel" \
-ex "layout asm" -ex "layout regs" \
-ex "br *0x80490b0" \
-ex "set startup-with-shell off" \
./xxx
23 changes: 23 additions & 0 deletions xxx/dat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* common data types
*/

#include <stdint.h>

/* basic types */
typedef int32_t i32;
typedef int16_t i16;
typedef int8_t i8;

typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;

/* Reg hold processor registers */
typedef struct {
i32 eax, ebx, ecx, edx;
i32 eip, ebp, esi, edi;
i32 esp;

i16 cs, ds, es, fs, gs;
} Reg;
5 changes: 5 additions & 0 deletions xxx/fns.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** function definitions */

void printRegs32(Reg*);
void printRegs16(Reg*);
void init();
1 change: 1 addition & 0 deletions xxx/kernel/include/xxx/stdio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uint16 printf(char *fmt, ...);
6 changes: 6 additions & 0 deletions xxx/kernel/include/xxx/term.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
typedef struct {
uint8 x;
uint8 y;

uint8 color;
} Term;
2 changes: 2 additions & 0 deletions xxx/kernel/include/xxx/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
typedef unsigned char uint8;
typedef unsigned short uint16;
33 changes: 33 additions & 0 deletions xxx/kernel/include/xxx/vesa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// video mode, video buffer segment and dimensions
#define VMODE 3 // 80x25 color text mode
#define VSEG 0xB800
#define VWIDTH 80
#define VHEIGHT 25

// foreground and background colors
#define FORE_BLACK 0x00
#define FORE_BLUE 0x01
#define FORE_GREEN 0x02
#define FORE_CYAN 0x03
#define FORE_RED 0x04
#define FORE_MAGENTA 0x05
#define FORE_BROWN 0x06
#define FORE_WHITE 0x07
#define FORE_GRAY 0x08
#define FORE_BRIGHT_BLUE 0x09
#define FORE_BRIGHT_GREEN 0x0A
#define FORE_BRIGHT_CYAN 0x0B
#define FORE_BRIGHT_RED 0x0C
#define FORE_BRIGHT_MAGENTA 0x0D
#define FORE_YELLOW 0x0E
#define FORE_BRIGHT_WHITE 0x0F
#define BACK_BLACK 0x00
#define BACK_BLUE 0x10
#define BACK_GREEN 0x20
#define BACK_CYAN 0x30
#define BACK_RED 0x40
#define BACK_MAGENTA 0x50
#define BACK_BROWN 0x60
#define BACK_WHITE 0x70

#define TERMCOLOR (BACK_BLACK | FORE_BRIGHT_WHITE)
Loading