summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile4
-rw-r--r--src/boot/stage2_real_functions.asm2
-rw-r--r--src/drivers/video/vga.c65
-rw-r--r--src/drivers/video/vga.h1
4 files changed, 36 insertions, 36 deletions
diff --git a/src/Makefile b/src/Makefile
index c1dfd2b..d32d3c1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,13 +15,13 @@ all: image.bin kernel.sym
# + 1 * 512 = 512 for magic.bin
# (M + N + 1 is the number of sectors to be read in stage 2, as stage 1
# loads only the first sector, and stage 1 loads 3 sectors of stage 2,
-# adapt NOF_LOAD_SECTORS to 41)
+# adapt NOF_LOAD_SECTORS to 44)
# then we make sure the image has the size of a 1.44 MB floppy
# (emulators like qemu do some guess work for CHS resolution based
# on the size of the image)
image.bin: boot.bin kernel.bin magic.bin
cat boot.bin kernel.bin > image.tmp
- truncate -s 22528 image.tmp
+ truncate -s 24064 image.tmp
cat image.tmp magic.bin > image.bin
truncate -s 1474560 image.bin
diff --git a/src/boot/stage2_real_functions.asm b/src/boot/stage2_real_functions.asm
index 8a0ab8d..87642c2 100644
--- a/src/boot/stage2_real_functions.asm
+++ b/src/boot/stage2_real_functions.asm
@@ -2,7 +2,7 @@
; (note: the first sector gets loaded by the BIOS, the
; next 3 sectors are read by the simple stage 1 loader,
; so subtract 3 here!)
-NOF_LOAD_SECTORS equ 41
+NOF_LOAD_SECTORS equ 44
; data sections used for reading the kernel from disk
SECTORS_PER_CYLINDER:
diff --git a/src/drivers/video/vga.c b/src/drivers/video/vga.c
index 75a47f4..e3427b4 100644
--- a/src/drivers/video/vga.c
+++ b/src/drivers/video/vga.c
@@ -131,7 +131,8 @@ static vga_mode_t modes[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00
- }
+ },
+ NULL
}
};
@@ -161,34 +162,6 @@ static int get_matching_mode_idx( const vga_mode_t mode )
return -1;
}
-bool vga_set_mode( vga_t *vga, const vga_mode_t mode )
-{
- // do not allow unknown timings!
- if( !vga_supports_mode( mode ) ) {
- return false;
- }
-
- vga_mode_t matching_mode = modes[get_matching_mode_idx( mode )];
-
- write_registers( vga, matching_mode.regs );
-
- vga->mode = mode;
-
- return true;
-}
-
-
-vga_color_t vga_make_RGB( int R, int G, int B )
-{
- vga_color_t c;
-
- c.R = R;
- c.G = G;
- c.B = B;
-
- return c;
-}
-
static uint8_t *get_frame_buffer_segment( vga_t *vga )
{
port8_write( &vga->graphics_controller_index_port, 0x06 );
@@ -220,6 +193,35 @@ static uint8_t *get_frame_buffer_segment( vga_t *vga )
return segment;
}
+bool vga_set_mode( vga_t *vga, const vga_mode_t mode )
+{
+ // do not allow unknown timings!
+ if( !vga_supports_mode( mode ) ) {
+ return false;
+ }
+
+ vga_mode_t matching_mode = modes[get_matching_mode_idx( mode )];
+
+ write_registers( vga, matching_mode.regs );
+
+ vga->mode = mode;
+ vga->mode.segment = get_frame_buffer_segment( vga );
+
+ return true;
+}
+
+
+vga_color_t vga_make_RGB( int R, int G, int B )
+{
+ vga_color_t c;
+
+ c.R = R;
+ c.G = G;
+ c.B = B;
+
+ return c;
+}
+
static uint8_t get_color_index( const vga_color_t c )
{
// TODO: for now white and black, standard VGA palette entries?
@@ -248,11 +250,8 @@ void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t colo
uint8_t color_idx = get_color_index( color );
- uint8_t *segment = get_frame_buffer_segment( vga );
-
- uint8_t *addr = segment + vga->mode.x * y + x;
+ uint8_t *addr = vga->mode.segment + vga->mode.x * y + x;
-// printf( "%d %d 0x%X, 0x%X 0x%X\n", x, y, segment, addr, color_idx );
*addr = color_idx;
}
diff --git a/src/drivers/video/vga.h b/src/drivers/video/vga.h
index 7c710c3..6f70afa 100644
--- a/src/drivers/video/vga.h
+++ b/src/drivers/video/vga.h
@@ -17,6 +17,7 @@ typedef struct {
int y;
int color_depth;
uint8_t regs[NOF_MODE_REGS];
+ uint8_t *segment;
} vga_mode_t;
typedef struct {