Permalink
Browse files

stage1,vga: fix the vga clear and provide a real vga initialization

Fix the VGA screen clear function to a simpler way of doing it. Add a
real way to initialize the ga display by starting to display where the
previous display stop.
  • Loading branch information...
1 parent a24859d commit 14a896d2969c19c10dd59c8a6a7870be5c34f1a9 @ddejean committed Feb 22, 2012
Showing with 45 additions and 23 deletions.
  1. +1 −2 kernel/boot/stage1.c
  2. +34 −16 kernel/boot/vga.c
  3. +10 −5 kernel/boot/vga.h
View
@@ -21,10 +21,9 @@ void stage1_main(unsigned int multiboot_magic, void *multiboot_info)
#ifdef QEMU_DEBUG
putbytes_callback(qemu_putbytes);
#else
+ vga_start(0, 0);
putbytes_callback(vga_putbytes);
#endif
- printf("vga_clear");
- vga_clear();
/* Display a stage1 message */
printf("%s\n", "Welcome on Simple Object Kernel !");
View
@@ -130,33 +130,51 @@ static inline void vga_putchar(char c)
}
}
-/*
- * Public interaface implementation.
- * @see vga.h
+/**
+ * Blank the screen with whitespaces and put the cursor
+ * at the beginning of the screen.
*/
-void vga_putbytes(const char *str, int len)
+static void vga_clear(void)
{
int i;
- for (i = 0; i < len; i++) {
- vga_putchar(*str);
- str++;
- }
-}
-void vga_clear(void)
-{
/* Reset screen parameters */
x = 0;
y = 0;
/* Clear is */
- for (screen = (char*)VGA_BUFFER;
- screen < (char*)(VGA_BUFFER + VGA_BUFFER_SIZE);
- ) {
- *(screen++) = ' ';
- *(screen++) = color;
+ for (i = 0; i < VGA_WIDTH * VGA_HEIGHT; i++) {
+ vga_putchar(' ');
}
screen = (char*)VGA_BUFFER;
+ x = 0;
+ y = 0;
/* Reset the cursor */
vga_set_cursor(x, y);
}
+/*
+ * Public interaface implementation.
+ * @see vga.h
+ */
+
+void vga_start(uint8_t cursor_x, uint8_t cursor_y)
+{
+ if (x > VGA_WIDTH || y > VGA_HEIGHT || (x == 0 && y == 0)) {
+ vga_clear();
+ } else {
+ x = cursor_x;
+ y = cursor_y;
+ }
+
+}
+
+void vga_putbytes(const char *str, int len)
+{
+ int i;
+ for (i = 0; i < len; i++) {
+ vga_putchar(*str);
+ str++;
+ }
+ vga_set_cursor(x, y);
+}
+
View
@@ -10,6 +10,16 @@
#ifndef _VGA_H_
#define _VGA_H_
+#include "stdint.h"
+
+/**
+ * Initiliaze the bootstrap vga screen starting at the specified position.
+ *
+ * @param x the start offset from the left border of the screen
+ * @param y the start offset from the top brder of the screen
+ */
+void vga_start(uint8_t cursor_x, uint8_t cursor_y);
+
/**
* Writes the string <str> on VGA screen following the current cursor
* position. Moves the cursor forward.
@@ -19,10 +29,5 @@
*/
void vga_putbytes(const char *str, int len);
-/**
- * Wipes the screen.
- */
-void vga_clear(void);
-
#endif

0 comments on commit 14a896d

Please sign in to comment.