Update system to minimum working status

This commit is contained in:
Jenny Curle 2019-04-01 12:46:40 +01:00
parent da9283ebd1
commit 96ed9e6785
6 changed files with 67 additions and 18 deletions

View File

@ -42,7 +42,16 @@ void term_putentryat (char c, uint8_t color, size_t x, size_t y) {
void term_putchar(char c) {
unsigned char uc = c;
term_putentryat(uc, current_color, terminal_column, terminal_row);
switch (uc) {
case '\n':
terminal_column = 0;
terminal_row += 1;
break;
default:
term_putentryat(uc, current_color, terminal_column, terminal_row);
break;
}
if(++terminal_column == TERM_WIDTH)
{
@ -59,6 +68,10 @@ void term_write(const char* data, size_t size) {
term_putchar(data[i]);
}
void term_writes(const char* data) {
term_write(data, strlen(data));
}
void puts(const char* string) {
term_write(string, strlen(string));
term_putchar('\n');
@ -68,7 +81,7 @@ void term_scroll() {
int current_pos = 160; //Start of the second line.
unsigned char* term_buffer = (unsigned char*) vga_buffer;
while (current_pos <= 4000) {
term_buffer[current_pos - 160 /*The character immediately below it*/] = vga_buffer[current_pos]; //Move each character up a line
term_buffer[current_pos - 159 /*The color of the character below*/] = vga_buffer[current_pos + 1]; //As well as its color

34
include/arch/i386/vga.h Executable file
View File

@ -0,0 +1,34 @@
#ifndef ARCH_I386_VGA_H
#define ARCH_I386_VGA_H
#include <stdint.h>
enum vga_colors {
BLACK = 0,
BLUE = 1,
GREEN = 2,
CYAN = 3,
RED = 4,
MAGENTA = 5,
BROWN = 6,
LIGHT_GREY = 7,
DARK_GREY = 8,
LIGHT_BLUE = 9,
LIGHT_GREEN = 10,
LIGHT_CYAN = 11,
LIGHT_RED = 12,
LIGHT_MAGENTA = 13,
LIGHT_BROWN = 14,
WHITE = 15
};
static inline uint8_t vga_color_set(enum vga_colors fg, enum vga_colors bg) {
return fg | bg << 4;
}
static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
return (uint16_t) uc | (uint16_t) color << 8;
}
#endif

View File

@ -9,6 +9,7 @@ void screen_initialize(void);
void term_putentryat(char, uint8_t, size_t, size_t);
void term_putchar(char);
void term_write(const char*, size_t);
void term_writes(const char*);
void puts(const char*);
void set_cursor(int, int);
void term_scroll(void);

View File

@ -7,13 +7,13 @@ int kernel_main(void) {
screen_initialize();
//Print a copyright message.
puts("(c)");
term_writes("(c)");
term_setcolor(GREEN);
puts(" Project");
term_writes(" Project");
term_setcolor(RED);
puts("RED");
term_writes("RED");
term_setcolor(WHITE);
puts(", 2019\n");
term_writes(", 2019\n");
for(;;) {}
return 0;

View File

@ -1,4 +1,4 @@
#include <sys/stat.h>
/*#include <sys/stat.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/times.h>
@ -44,4 +44,5 @@ int unlink(char* name);
int wait(int file, char* ptr, int len);
int gettimeofday(struct timeval* p, struct timezone* z);
int gettimeofday(struct timeval* p, struct timezone* z);
*/

View File

@ -80,16 +80,16 @@ install-kernel: red.kernel
cp red.kernel $(DESTDIR)$(BOOTDIR)
gen-iso:
rm -f red.iso \
cp red.kernel iso/boot/kernel.elf \
genisoimage -R\
-b boot/grub/stage2_eltorito\
-no-emul-boot\
-A ProjectRED\
-input-charset utf8\
-quiet
-boot-info-table\
-o red.iso\
rm -f red.iso
cp red.kernel iso/boot/kernel.elf
genisoimage -R \
-b boot/grub/stage2_eltorito \
-no-emul-boot \
-A ProjectRED \
-input-charset utf8 \
-quiet \
-boot-info-table \
-o red.iso \
iso
-include $(OBJS:.o=.d)