VBE graphics mode successfully initialized by grub, can use iso with qemu now
This commit is contained in:
parent
23ede25ed6
commit
2eca761edc
6
Makefile
6
Makefile
@ -36,7 +36,9 @@ iso: clean_iso clean build
|
|||||||
grub-mkrescue -o build/barinkOS.iso root
|
grub-mkrescue -o build/barinkOS.iso root
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio -vga std -monitor stdio -display gtk -m 2G -cpu core2duo
|
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial mon:stdio -vga std -display gtk -m 2G -cpu core2duo # -monitor stdio
|
||||||
|
test_iso:
|
||||||
|
$(EMULATOR) -cdrom build/barinkOS.iso -serial mon:stdio -vga std -display gtk -m 2G -cpu core2duo
|
||||||
|
|
||||||
build_kernel: $(OBJ_LINK_LIST)
|
build_kernel: $(OBJ_LINK_LIST)
|
||||||
$(CC) -T $(SRC_DIR)/kernel//linker.ld -o $(BUILD_DIR)/myos.bin \
|
$(CC) -T $(SRC_DIR)/kernel//linker.ld -o $(BUILD_DIR)/myos.bin \
|
||||||
@ -50,7 +52,7 @@ clean:
|
|||||||
rm -f $(BUILD_DIR)/myos.bin $(INTERNAL_OBJS)
|
rm -f $(BUILD_DIR)/myos.bin $(INTERNAL_OBJS)
|
||||||
|
|
||||||
$(BUILD_DIR)/kernel.o:
|
$(BUILD_DIR)/kernel.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti -fpermissive
|
||||||
|
|
||||||
$(BUILD_DIR)/kterm.o:
|
$(BUILD_DIR)/kterm.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
________________________
|
________________________
|
||||||
### Screenshot(s)
|
### Screenshot(s)
|
||||||
|
![Graphics mode](screenshots/BarinkOS_VBE_GRAPHICS.png) \
|
||||||
|
It may not look like much but I am proud of it! We are in graphics mode.
|
||||||
|
|
||||||
![Scrolling the terminal](screenshots/Screenshot1.png) \
|
![Scrolling the terminal](screenshots/Screenshot1.png) \
|
||||||
The first scrolling boot screen. 😲
|
The first scrolling boot screen. 😲
|
||||||
|
|
||||||
|
BIN
screenshots/BarinkOS_VBE_GRAPHICS.png
(Stored with Git LFS)
Normal file
BIN
screenshots/BarinkOS_VBE_GRAPHICS.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,18 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Multiboot
|
* Multiboot
|
||||||
*/
|
*/
|
||||||
.set ALIGN, 1<<0 /* align loaded modules on page boundaries */
|
.set ALIGN, 1<<0 /* align loaded modules on page boundaries */
|
||||||
.set MEMINFO, 1<<1 /* provide memory map */
|
.set MEMINFO, 1<<1 /* provide memory map */
|
||||||
.set FLAGS, ALIGN | MEMINFO /* this is the Multiboot 'flag' field */
|
.set VIDEO, 1<<2 /* provide video mode */
|
||||||
.set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
|
.set FLAGS, ALIGN | MEMINFO | VIDEO /* this is the Multiboot 'flag' field */
|
||||||
.set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */
|
.set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
|
||||||
|
.set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */
|
||||||
|
|
||||||
.section .multiboot
|
.section .multiboot
|
||||||
.align 4
|
.align 4
|
||||||
.long MAGIC
|
.long MAGIC
|
||||||
.long FLAGS
|
.long FLAGS
|
||||||
.long CHECKSUM
|
.long CHECKSUM
|
||||||
|
.long 0 # unused
|
||||||
|
.long 0 # .
|
||||||
|
.long 0 # .
|
||||||
|
.long 0 # .
|
||||||
|
.long 0 # unused
|
||||||
|
.long 0 # set graphics mode
|
||||||
|
.long 1280 # screen witdh
|
||||||
|
.long 720 # screen height
|
||||||
|
.long 32 # bpp
|
||||||
|
|
||||||
.section .bss
|
.section .bss
|
||||||
.align 16
|
.align 16
|
||||||
|
@ -11,7 +11,7 @@ void CheckMBT ( multiboot_info_t* mbt ){
|
|||||||
multiboot_info_t * mbi = (multiboot_info_t *) mbt;
|
multiboot_info_t * mbi = (multiboot_info_t *) mbt;
|
||||||
|
|
||||||
/* Print out the flags */
|
/* Print out the flags */
|
||||||
printf("flags = 0x%x\n", (unsigned) mbi->flags);
|
printf("flags = 0x%8x\n", (unsigned) mbi->flags);
|
||||||
|
|
||||||
/* Are mem_* valid? */
|
/* Are mem_* valid? */
|
||||||
if ( CHECK_FLAG(mbi->flags,0)){
|
if ( CHECK_FLAG(mbi->flags,0)){
|
||||||
@ -68,9 +68,88 @@ void CheckMBT ( multiboot_info_t* mbt ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Draw diagonal blue line */
|
/* Draw diagonal blue line */
|
||||||
if (CHECK_FLAG (mbt->flags, 12)){
|
if (CHECK_FLAG (mbt->flags, 11)){
|
||||||
printf("Can draw!");
|
printf("Can draw!");
|
||||||
}
|
|
||||||
|
multiboot_uint32_t color;
|
||||||
|
unsigned i;
|
||||||
|
void *fb = (void *) (unsigned long) mbt->framebuffer_addr;
|
||||||
|
|
||||||
|
switch (mbt->framebuffer_type)
|
||||||
|
{
|
||||||
|
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
|
||||||
|
{
|
||||||
|
unsigned best_distance, distance;
|
||||||
|
struct multiboot_color *palette;
|
||||||
|
|
||||||
|
palette = (struct multiboot_color *) mbt->framebuffer_palette_addr;
|
||||||
|
|
||||||
|
color = 0;
|
||||||
|
best_distance = 4*256*256;
|
||||||
|
|
||||||
|
for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
|
||||||
|
{
|
||||||
|
distance = (0xff - palette[i].blue) * (0xff - palette[i].blue)
|
||||||
|
+ palette[i].red * palette[i].red
|
||||||
|
+ palette[i].green * palette[i].green;
|
||||||
|
if (distance < best_distance)
|
||||||
|
{
|
||||||
|
color = i;
|
||||||
|
best_distance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
|
||||||
|
color = ((1 << mbt->framebuffer_blue_mask_size) - 1)
|
||||||
|
<< mbt->framebuffer_blue_field_position;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
|
||||||
|
color = '\\' | 0x0100;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
color = 0xffffffff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = 0; i < mbt->framebuffer_width
|
||||||
|
&& i < mbt->framebuffer_height; i++)
|
||||||
|
{
|
||||||
|
switch (mbt->framebuffer_bpp)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
multiboot_uint8_t *pixel = fb + mbt->framebuffer_pitch * i + i;
|
||||||
|
*pixel = color;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
case 16:
|
||||||
|
{
|
||||||
|
multiboot_uint16_t *pixel
|
||||||
|
= fb + mbt->framebuffer_pitch * i + 2 * i;
|
||||||
|
*pixel = color;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
|
{
|
||||||
|
multiboot_uint32_t *pixel
|
||||||
|
= fb + mbt->framebuffer_pitch * i + 3 * i;
|
||||||
|
*pixel = (color & 0xffffff) | (*pixel & 0xff000000);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 32:
|
||||||
|
{
|
||||||
|
multiboot_uint32_t *pixel
|
||||||
|
= fb + mbt->framebuffer_pitch * i + 4 * i;
|
||||||
|
*pixel = color;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -48,12 +48,13 @@ void initGDT(){
|
|||||||
gdtDescriptor.limit = ((sizeof(SegmentDescriptor ) * 5 ) - 1);
|
gdtDescriptor.limit = ((sizeof(SegmentDescriptor ) * 5 ) - 1);
|
||||||
gdtDescriptor.base = (unsigned int) &GlobalDescriptorTable;
|
gdtDescriptor.base = (unsigned int) &GlobalDescriptorTable;
|
||||||
|
|
||||||
|
printf("Hello GDT!\n");
|
||||||
|
|
||||||
|
|
||||||
LoadGlobalDescriptorTable();
|
LoadGlobalDescriptorTable();
|
||||||
|
|
||||||
while (true)
|
// while (true)
|
||||||
asm volatile("hlt");
|
// asm volatile("hlt");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#define GB4 524288
|
#define GB4 524288
|
||||||
#define GB2 262144
|
#define GB2 262144
|
||||||
|
extern "C" void kernel_main (void);
|
||||||
|
extern "C" void putPixel(int pos_x, int pos_y, unsigned char VGA_COLOR , unsigned char addr , unsigned char pixelWidth, unsigned pitch );
|
||||||
|
|
||||||
|
|
||||||
extern "C" void early_main(unsigned long magic, unsigned long addr){
|
extern "C" void early_main(unsigned long magic, unsigned long addr){
|
||||||
/** initialize terminal interface */
|
/** initialize terminal interface */
|
||||||
kterm_init();
|
// kterm_init();
|
||||||
|
|
||||||
|
printf("Magic flag 0x%8x\n", magic);
|
||||||
|
printf("Magic must be 0x%8x\n", MULTIBOOT_BOOTLOADER_MAGIC);
|
||||||
if (magic != MULTIBOOT_BOOTLOADER_MAGIC){
|
if (magic != MULTIBOOT_BOOTLOADER_MAGIC){
|
||||||
printf("Invalid magic number: 0x%x\n", magic);
|
printf("Invalid magic number: 0x%8x\n", magic);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +34,14 @@
|
|||||||
|
|
||||||
initGDT();
|
initGDT();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print_serial("Video mode enabled!\n");
|
||||||
|
printf_serial("VBE mode: 0x%x\n", mbt->vbe_mode);
|
||||||
|
printf_serial("width: %d height: %d bpp: %d\n" , mbt->framebuffer_width, mbt->framebuffer_height, mbt->framebuffer_bpp);
|
||||||
|
|
||||||
|
kernel_main();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +50,7 @@
|
|||||||
printf("call to init serial\n");
|
printf("call to init serial\n");
|
||||||
init_serial();
|
init_serial();
|
||||||
|
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
//Read time indefinetely
|
//Read time indefinetely
|
||||||
read_rtc();
|
read_rtc();
|
||||||
|
@ -51,6 +51,68 @@ void print_serial(const char* string ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void printf_serial ( const char *format, ...) {
|
||||||
|
|
||||||
|
char **arg = (char **)&format;
|
||||||
|
int c;
|
||||||
|
char buf[20];
|
||||||
|
|
||||||
|
arg++;
|
||||||
|
|
||||||
|
while ((c = *format++) != 0){
|
||||||
|
if( c != '%')
|
||||||
|
write_serial(c);
|
||||||
|
else{
|
||||||
|
char *p, *p2;
|
||||||
|
int pad0 = 0, pad = 0;
|
||||||
|
|
||||||
|
c = *format++;
|
||||||
|
if(c =='0'){
|
||||||
|
pad0 = 1;
|
||||||
|
c = *format++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( c >= '0' && c <= '9'){
|
||||||
|
pad = c - '0';
|
||||||
|
c = *format++;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
|
||||||
|
case 'u':
|
||||||
|
case 'x':
|
||||||
|
itoa(buf, c, *((int *) arg++));
|
||||||
|
|
||||||
|
p = buf;
|
||||||
|
goto string;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
p = *arg++;
|
||||||
|
if(!p)
|
||||||
|
p = "(null)";
|
||||||
|
|
||||||
|
string:
|
||||||
|
for (p2 = p; *p2; p2++);
|
||||||
|
for (; p2 < p + pad; p2++)
|
||||||
|
write_serial(pad0 ? '0': ' ');
|
||||||
|
while (*p)
|
||||||
|
write_serial(*p++);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
write_serial(*((int *)arg++));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_serial(){
|
void test_serial(){
|
||||||
/** Serial test **/
|
/** Serial test **/
|
||||||
kterm_writestring("Writing to COM1 serial port:");
|
kterm_writestring("Writing to COM1 serial port:");
|
||||||
|
@ -137,7 +137,7 @@ void kterm_writestring(const char* data ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void itoa (char *buf, int base, int d) {
|
void itoa (char *buf, int base, int d) {
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
char *p1, *p2;
|
char *p1, *p2;
|
||||||
unsigned long ud = d;
|
unsigned long ud = d;
|
||||||
@ -174,7 +174,7 @@ static void itoa (char *buf, int base, int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printf ( const char *format, ...) {
|
void printf ( const char *format, ...) {
|
||||||
|
return;
|
||||||
char **arg = (char **)&format;
|
char **arg = (char **)&format;
|
||||||
int c;
|
int c;
|
||||||
char buf[20];
|
char buf[20];
|
||||||
|
@ -33,10 +33,9 @@ uint16_t get_cursor_position();
|
|||||||
int get_cursor_x (uint16_t cursor_pos);
|
int get_cursor_x (uint16_t cursor_pos);
|
||||||
int get_cursor_y (uint16_t cursor_pos);
|
int get_cursor_y (uint16_t cursor_pos);
|
||||||
|
|
||||||
|
extern "C" void itoa (char *buf, int base, int d);
|
||||||
void printf ( const char *format, ...);
|
void printf ( const char *format, ...);
|
||||||
|
|
||||||
//static void itoa (char *buf, int base, int d);
|
|
||||||
|
|
||||||
#define KernelTag "[Kernel]: "
|
#define KernelTag "[Kernel]: "
|
||||||
#define AS_KERNEL() ( kterm_setcolor(VGA_COLOR_LIGHT_BLUE),\
|
#define AS_KERNEL() ( kterm_setcolor(VGA_COLOR_LIGHT_BLUE),\
|
||||||
|
Loading…
Reference in New Issue
Block a user