Skip to content

Commit ab29477

Browse files
committed
Rough skeleton for VGA graphics driver
1 parent 05b9473 commit ab29477

File tree

6 files changed

+49
-1
lines changed

6 files changed

+49
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ include $(SRC_KERNEL)/process/Makefile.mk
135135
include $(SRC_KERNEL)/syscall/Makefile.mk
136136

137137
include $(SRC_DRIVERS)/disk/Makefile.mk
138-
include $(SRC_DRIVERS)/display/Makefile.mk
139138
include $(SRC_DRIVERS)/keyboard/Makefile.mk
140139
include $(SRC_DRIVERS)/pic/Makefile.mk
140+
include $(SRC_DRIVERS)/display/Makefile.mk
141+
include $(SRC_DRIVERS)/display/vga/Makefile.mk
141142

142143
include $(SRC_DIR)/fs/Makefile.mk
143144
include $(SRC_DIR)/memmgr/tables/Makefile.mk
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#define GRAPHICS_HEIGHT 640
4+
#define GRAPHICS_WIDTH 480
5+
6+
// following functions doesn't verify arguments
7+
inline void draw_pixel(int x, int y, int color);
8+
inline void draw_char(int x, int y, int fnt_size, int color);
9+
// x1<=x2, y1<=y2
10+
inline void draw_rectangle(int x1, int y1, int x2, int y2, int color);
11+
inline void draw_ellipse(int x1, int y1, int x2, int y2, int color);
12+
13+
void graphics_flush();

include/fuzzy/memmgr/layout.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#define STACKINIT_APP (MEMORY_APP_SIZE-4)
66
#define MEMORY_REALLIBRARY_DATA_ADDRESS 0x70000
77
#define MEMORY_REALLIBRARY_DATA_SIZE 0x10000
8+
#define MEMORY_VGA_GRAPHICS_ADDRESS 0xA0000
9+
#define MEMORY_VGA_GRAPHICS_SIZE 0x10000
810

911
// END_ENSURE_SAME_layout_asm
1012

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
$(SELF_BUILD_DIR)/%.o: $(SELF_SRC_DIR)/%.c $(BUILD_USR_INCLUDE_ALL)
3+
mkdir -p $(dir $@)
4+
$(KERNEL_CC) -c -o $@ \
5+
$<
6+
7+
$(SELF_BUILD_DIR)/%_asm.o: $(SELF_SRC_DIR)/%.asm
8+
mkdir -p $(dir $@)
9+
nasm -o $@ -f elf32 $<
10+
11+
$(SELF_BUILD_DIR)/libvga_graphics: $(SELF_BUILD_ALL_C) $(SELF_BUILD_ALL_ASM)
12+
ar rc $@ $^
13+

src/drivers/display/vga/graphics.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<fuzzy/drivers/display/vga/graphics.h>
2+
#include<fuzzy/kernel/process/process.h>
3+
#include<fuzzy/memmgr/tables/gdt.h>
4+
#include<fuzzy/memmgr/layout.h>
5+
6+
#include <stddef.h>
7+
8+
// FIX: large buffer size, looks like we need to move kernel.
9+
static uint16_t buffer[GRAPHICS_HEIGHT][GRAPHICS_WIDTH] = {0};
10+
11+
void graphics_flush() {
12+
kernel_memncpy_absolute(
13+
GDT_ABS32_DS, // dst ds
14+
MEMORY_VGA_GRAPHICS_ADDRESS, // dst address
15+
GDT_KERNEL_DS, // src ds
16+
buffer, // src address
17+
MEMORY_VGA_GRAPHICS_SIZE); // FIX: doesn't match
18+
}

src/kernel/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $(kernel_core).elf: $(SELF_BUILD_DIR)/core_asm.o \
2525
$(BUILD_DRIVERS)/pic/libpic \
2626
$(BUILD_LIB_UTILS)/libutils \
2727
$(BUILD_DRIVERS)/display/libtm_vga \
28+
$(BUILD_DRIVERS)/display/vga/libvga_graphics \
2829
$(BUILD_LIB_DS)/libds \
2930
$(BUILD_DRIVERS)/disk/libdisk \
3031
$(BUILD_DIR)/real_mode/librealmodeclient \

0 commit comments

Comments
 (0)