New directory structure
This commit is contained in:
@ -32,7 +32,9 @@ _start:
|
||||
|
||||
|
||||
|
||||
call _init
|
||||
call kernel_main
|
||||
|
||||
|
||||
cli
|
||||
1: hlt
|
14
src/kernel/arch/i386/crti.s
Normal file
14
src/kernel/arch/i386/crti.s
Normal file
@ -0,0 +1,14 @@
|
||||
.section .init
|
||||
.global _init
|
||||
.type _init, @function
|
||||
_init:
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
/* gcc will nicely put the contents of crtbegin.o's .init section here. */
|
||||
|
||||
.section .fini
|
||||
.global _fini
|
||||
.type _fini, @function
|
||||
_fini:
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
7
src/kernel/arch/i386/crtn.s
Normal file
7
src/kernel/arch/i386/crtn.s
Normal file
@ -0,0 +1,7 @@
|
||||
.section .init
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
.section .fini
|
||||
popl %ebp
|
||||
ret
|
@ -1,39 +1,14 @@
|
||||
#include "kernel.h"
|
||||
#include "kterm.h"
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
|
||||
size_t kterm_row;
|
||||
size_t kterm_column;
|
||||
uint8_t kterm_color;
|
||||
uint16_t* kterm_buffer;
|
||||
|
||||
|
||||
/**
|
||||
* simple delay function
|
||||
**/
|
||||
void delay(int t){
|
||||
volatile int i,j;
|
||||
for(i=0;i<t;i++)
|
||||
for(j=0;j<25000;j++)
|
||||
asm("NOP");
|
||||
}
|
||||
|
||||
void kernel_main (void) {
|
||||
/** initialize terminal interface */
|
||||
kterm_init();
|
||||
|
||||
/** Wrtite stuff to the screen to test the terminal**/
|
||||
kterm_writestring("Hello world!\n");
|
||||
kterm_writestring("We got newline support!\n");
|
||||
|
||||
for(;;){
|
||||
delay(500);
|
||||
kterm_writestring("We have implemented terminal scrolling!\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* KTerm stuff
|
||||
**/
|
||||
|
||||
static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
|
||||
static inline uint8_t vga_entry_color( enum vga_color fg, enum vga_color bg) {
|
||||
return fg | bg << 4;
|
||||
}
|
||||
|
||||
@ -110,7 +85,6 @@ void kterm_write(const char* data, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void kterm_writestring(const char* data ){
|
||||
AS_KERNEL();
|
||||
kterm_write(data, strlen(data));
|
@ -1,13 +1,9 @@
|
||||
#include <stdbool.h>
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#define KernelTag "[Kernel]: "
|
||||
#define AS_KERNEL() ( kterm_setcolor(VGA_COLOR_LIGHT_BLUE),\
|
||||
kterm_write(KernelTag, strlen(KernelTag)), \
|
||||
kterm_resetcolor())
|
||||
#include <stdbool.h>
|
||||
#include "../vga/colors.h"
|
||||
|
||||
void kterm_init();
|
||||
|
||||
@ -20,5 +16,7 @@ void kterm_write(const char*, size_t);
|
||||
void kterm_writestring(const char*);
|
||||
void kterm_scrollup();
|
||||
|
||||
|
||||
|
||||
#define KernelTag "[Kernel]: "
|
||||
#define AS_KERNEL() ( kterm_setcolor(VGA_COLOR_LIGHT_BLUE),\
|
||||
kterm_write(KernelTag, 10 ), \
|
||||
kterm_resetcolor())
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
enum vga_color {
|
||||
VGA_COLOR_BLACK = 0,
|
||||
VGA_COLOR_BLUE = 1,
|
27
src/kernel/kernel.c
Normal file
27
src/kernel/kernel.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include "kernel.h"
|
||||
/**
|
||||
* simple delay function
|
||||
**/
|
||||
void delay(int t){
|
||||
volatile int i,j;
|
||||
for(i=0;i<t;i++)
|
||||
for(j=0;j<25000;j++)
|
||||
asm("NOP");
|
||||
}
|
||||
|
||||
void kernel_main (void) {
|
||||
/** initialize terminal interface */
|
||||
kterm_init();
|
||||
|
||||
/** Wrtite stuff to the screen to test the terminal**/
|
||||
kterm_writestring("Hello world!\n");
|
||||
kterm_writestring("We got newline support!\n");
|
||||
|
||||
for(;;){
|
||||
delay(500);
|
||||
kterm_writestring("We have implemented terminal scrolling!\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
3
src/kernel/kernel.h
Normal file
3
src/kernel/kernel.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
#include "../libc/include/string.h"
|
||||
#include "arch/i386/tty/kterm.h"
|
11
src/kterm.h
11
src/kterm.h
@ -1,11 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "vga_colors.h"
|
||||
|
||||
static const size_t VGA_WIDTH = 80;
|
||||
static const size_t VGA_HEIGHT = 25;
|
||||
|
||||
size_t kterm_row;
|
||||
size_t kterm_column;
|
||||
uint8_t kterm_color;
|
||||
uint16_t* kterm_buffer;
|
Reference in New Issue
Block a user