Skip to content

Commit 392c8ad

Browse files
committed
VBE support
We now boot into 1024x768 and draw a background image, and overlay the boot log. Adds a font in unifont.c, and a bg image in ayame.c tty.c is now the skeleton of a shared buffer for either text or graphical modes to pull from and render. At the moment, nothing is driving the screen to redraw, so graphical output will 'hang' after the bg draws for the first time.
1 parent 698e470 commit 392c8ad

File tree

10 files changed

+253341
-72
lines changed

10 files changed

+253341
-72
lines changed

ayame.c

+196,610
Large diffs are not rendered by default.

boros.bochs

-49
This file was deleted.

include/tty.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _TTY_H
2+
#define _TTY_H
3+
void tty_write_str(const char *);
4+
void tty_putchar(unsigned char c);
5+
unsigned short *tty_get_line(int);
6+
#endif

include/vbe.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef VBE_H
2+
#define VBE_H
3+
#include "types.h"
4+
#include "device.h"
5+
void vbe_init(struct device *dev);
6+
#endif

main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void kmain(void *mem)
1818

1919
gdt_install();
2020
int_install();
21-
/* acpi_init(); - PCI-E not delivering interrupts yet */
22-
pci_init();
21+
acpi_init();
22+
//pci_init();
2323
syscall_install();
2424

2525
/* No infrastructure for this exists yet, hardcoded here */

pci.c

+7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#include <pci.h>
44
#include <device.h>
55
#include <cpu.h>
6+
67
#include <e1000.h>
78
#include <virtio.h>
9+
#include <vbe.h>
810

911
#define PCI_CONFIG_ADDRESS 0xCF8
1012
#define PCI_DATA_ADDRESS 0xCFC
@@ -68,6 +70,9 @@ static void pci_dump(struct device d)
6870

6971
if(vendor_id == 0x1af4 && device_id == 0x1000)
7072
virtio_init(&d);
73+
74+
if(vendor_id == 0x1234 && device_id == 0x1111)
75+
vbe_init(&d);
7176
}
7277

7378
struct pcie_config
@@ -115,6 +120,8 @@ static void pcie_handle_device(struct pcie_config *cfg)
115120
virtio_init(&d);
116121
if(cfg->vendor_id == 0x8086 && cfg->device_id == 0x100E)
117122
e1000_init(&d);
123+
if(cfg->vendor_id == 0x1234 && cfg->device_id == 0x1111)
124+
vbe_init(&d);
118125
}
119126

120127
static void pcie_parse_device(u64 addr)

print.c

+3-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdarg.h>
22
#include "print.h"
33
#include "stdlib.h"
4+
#include "tty.h"
45

56
#define BUF_SIZ 64
67

@@ -41,25 +42,7 @@ static void newline(void)
4142

4243
static void putchar(unsigned char c)
4344
{
44-
if(c == '\n')
45-
return newline();
46-
if(c == '\t')
47-
{
48-
putchar(' ');
49-
putchar(' ');
50-
putchar(' ');
51-
putchar(' ');
52-
return;
53-
}
54-
55-
if(vmem >= (unsigned short *)(0xB8000 + (80 * 25 * 2)))
56-
{
57-
vmem -= 80; /* Short *, not an offset */
58-
memmove((void *)0xB8000, (void *)0xB8000 + 160, 80 * 24 * 2);
59-
memset((void *)0xB8000+80*24*2, 0, 160);
60-
}
61-
62-
*vmem++ = 0xF00 | c;
45+
tty_putchar(c);
6346
}
6447

6548
static void put_number(unsigned long n, int islong, int base, char pad_char, int width)
@@ -91,8 +74,7 @@ static void put_number(unsigned long n, int islong, int base, char pad_char, int
9174

9275
static void puts(const char *str)
9376
{
94-
while(*str)
95-
putchar(*str++);
77+
tty_write_str(str);
9678
}
9779

9880
static void vprint(const char *fmt, va_list ap)

tty.c

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <tty.h>
2+
#include <cpu.h>
3+
4+
struct line
5+
{
6+
unsigned short text[80];
7+
};
8+
9+
static struct line buffer[40];
10+
static int buf_line;
11+
static int buf_pos;
12+
13+
void tty_write_str(const char *str)
14+
{
15+
char c;
16+
17+
do
18+
{
19+
c = *str++;
20+
tty_putchar(c);
21+
} while(c);
22+
}
23+
24+
void tty_putchar(unsigned char c)
25+
{
26+
if(c == '\t')
27+
{
28+
buffer[buf_line].text[buf_pos+0] = ' ';
29+
buffer[buf_line].text[buf_pos+1] = ' ';
30+
buffer[buf_line].text[buf_pos+2] = ' ';
31+
buffer[buf_line].text[buf_pos+3] = ' ';
32+
buf_pos += 4;
33+
}
34+
35+
if(c == '\n' || buf_pos >= 80)
36+
{
37+
buf_pos = 0;
38+
buf_line++;
39+
buffer[buf_line].text[0] = 0;
40+
if(buf_line >= 40)
41+
buf_line = 0;
42+
}
43+
44+
if(c != '\n' && c != '\t')
45+
buffer[buf_line].text[buf_pos++] = c;
46+
}
47+
48+
unsigned short *tty_get_line(int n)
49+
{
50+
int line;
51+
52+
line = buf_line + n;
53+
if(line > 40)
54+
line -= 40;
55+
if(line < 0)
56+
line += 40;
57+
58+
return buffer[line].text;
59+
}

0 commit comments

Comments
 (0)