On Mo, 2016-07-04 at 11:11 +0200, Paolo Bonzini wrote:
On 04/07/2016 10:16, Gerd Hoffmann wrote:
- sercon_putchar('\x1b');
- sercon_putchar('c');
- /* clear screen */
- sercon_putchar('\x1b');
- sercon_putchar('[');
- sercon_putchar('2');
- sercon_putchar('J');
+}
+static void sercon_set_color(u8 fg, u8 bg, u8 bold) +{
- sercon_putchar('\x1b');
- sercon_putchar('[');
- sercon_putchar('0');
- if (fg != 7) {
sercon_putchar(';');
sercon_putchar('3');
sercon_putchar(GET_LOW(sercon_cmap[fg & 7]));
- }
- if (bg != 0) {
sercon_putchar(';');
sercon_putchar('4');
sercon_putchar(GET_LOW(sercon_cmap[bg & 7]));
- }
- if (bold) {
sercon_putchar(';');
sercon_putchar('1');
- }
- sercon_putchar('m');
Add a sercon_putstr perhaps?
We run in real mode, so passing around pointers isn't that easy. Given this would make sense for constant strings only (like the 4-byte clear-screen sequence) and not so much for variable stuff we might put all strings in the global segment.
Would this ...
void sercon_putchar(char *ptr) { char c = GET_GLOBAL(ptr[0]); [ ... ]
... work?
Maybe we can reuse the output buffer which we have anyway. Logic needs reworked a bit. We can't just clear characters after printing them out if we want be able to read them later, so we need a separate pending-updates bit. Also should be bigger I guess, maybe 80 chars so it can cover a complete line.
80x25 is just 2K... Perhaps it's simpler to just allocate the whole video buffer from the UMB or EBDA when serial console is in use?
4k, we need both character and attribute. But, yes, if we can allocate that somewhere in real mode address space without running into memory pressure this might be the best option.
cheers, Gerd