Skip to content
This repository
Browse code

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...
commit 14a896d2969c19c10dd59c8a6a7870be5c34f1a9 1 parent a24859d
Damien Dejean authored February 22, 2012
3  kernel/boot/stage1.c
@@ -21,10 +21,9 @@ void stage1_main(unsigned int multiboot_magic, void *multiboot_info)
21 21
 #ifdef QEMU_DEBUG
22 22
         putbytes_callback(qemu_putbytes);
23 23
 #else
  24
+        vga_start(0, 0);
24 25
         putbytes_callback(vga_putbytes);
25 26
 #endif
26  
-        printf("vga_clear");
27  
-        vga_clear();
28 27
 
29 28
         /* Display a stage1 message */
30 29
         printf("%s\n", "Welcome on Simple Object Kernel !");
50  kernel/boot/vga.c
@@ -130,33 +130,51 @@ static inline void vga_putchar(char c)
130 130
 	}
131 131
 }
132 132
 
133  
-/*
134  
- * Public interaface implementation.
135  
- * @see vga.h
  133
+/**
  134
+ * Blank the screen with whitespaces and put the cursor
  135
+ * at the beginning of the screen.
136 136
  */
137  
-void vga_putbytes(const char *str, int len)
  137
+static void vga_clear(void)
138 138
 {
139 139
         int i;
140  
-        for (i = 0; i < len; i++) {
141  
-                vga_putchar(*str);
142  
-                str++;
143  
-        }
144  
-}
145 140
 
146  
-void vga_clear(void)
147  
-{
148 141
         /* Reset screen parameters */
149 142
         x = 0;
150 143
         y = 0;
151 144
         /* Clear is */
152  
-        for (screen = (char*)VGA_BUFFER;
153  
-             screen < (char*)(VGA_BUFFER + VGA_BUFFER_SIZE);
154  
-             ) {
155  
-                *(screen++) = ' ';
156  
-                *(screen++) =  color;
  145
+        for (i = 0; i < VGA_WIDTH * VGA_HEIGHT; i++) {
  146
+                vga_putchar(' ');
157 147
         } 
158 148
         screen = (char*)VGA_BUFFER;
  149
+        x = 0;
  150
+        y = 0;
159 151
         /* Reset the cursor */
160 152
         vga_set_cursor(x, y);
161 153
 }
162 154
 
  155
+/*
  156
+ * Public interaface implementation.
  157
+ * @see vga.h
  158
+ */
  159
+
  160
+void vga_start(uint8_t cursor_x, uint8_t cursor_y)
  161
+{
  162
+        if (x > VGA_WIDTH || y > VGA_HEIGHT || (x == 0 && y == 0)) {
  163
+                vga_clear();
  164
+        } else {
  165
+                x = cursor_x;
  166
+                y = cursor_y;
  167
+        }
  168
+          
  169
+}
  170
+
  171
+void vga_putbytes(const char *str, int len)
  172
+{
  173
+        int i;
  174
+        for (i = 0; i < len; i++) {
  175
+                vga_putchar(*str);
  176
+                str++;
  177
+        }
  178
+        vga_set_cursor(x, y);
  179
+}
  180
+
15  kernel/boot/vga.h
@@ -10,6 +10,16 @@
10 10
 #ifndef _VGA_H_
11 11
 #define _VGA_H_
12 12
 
  13
+#include "stdint.h"
  14
+
  15
+/**
  16
+ * Initiliaze the bootstrap vga screen starting at the specified position.
  17
+ *
  18
+ * @param x the start offset from the left border of the screen
  19
+ * @param y the start offset from the top brder of the screen
  20
+ */
  21
+void vga_start(uint8_t cursor_x, uint8_t cursor_y);
  22
+
13 23
 /**
14 24
  * Writes the string <str> on VGA screen following the current cursor
15 25
  * position. Moves the cursor forward.
@@ -19,10 +29,5 @@
19 29
  */
20 30
 void vga_putbytes(const char *str, int len);
21 31
 
22  
-/**
23  
- * Wipes the screen.
24  
- */
25  
-void vga_clear(void);
26  
-
27 32
 #endif
28 33
 

0 notes on commit 14a896d

Please sign in to comment.
Something went wrong with that request. Please try again.