-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.c
52 lines (39 loc) · 1.13 KB
/
kernel.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "serial.h"
#include "fb.h"
#include "qemu_dma.h"
#include "image_rgb_map.h"
void kernel_main(void) {
extern uint64_t _stack_top;
uint64_t heap_start = (uint64_t)&_stack_top;
if (check_fw_cfg_dma()) {
kprint("guest fw_cfg dma-interface enabled \n");
} else {
kprint("guest fw_cfg dma-interface NOT enabled - abort \n");
return;
}
uint32_t fb_width = 1024;
uint32_t fb_height = 768;
uint32_t fb_bpp = 4;
uint32_t fb_stride = fb_bpp * fb_width;
fb_info fb = {
.fb_addr = heap_start,
.fb_width = fb_width,
.fb_height = fb_height,
.fb_bpp = fb_bpp,
.fb_stride = fb_stride,
.fb_size = fb_stride * fb_height,
};
/* since this is just a "proof of concept", the complete "heap" serves as framebuffer... */
if (ramfb_setup(&fb) != 0) {
kprint("error setting up ramfb \n");
}
kprint("setup ramfb successfull\n");
// uint8_t pixel[3] = {255, 255, 255};
// for (int i = 0; i < fb.fb_width; i++) {
// for (int j = 0; j < fb.fb_height; j++) {
// write_rgb256_pixel(&fb, i, j, pixel);
// }
// }
draw_rgb256_map(&fb, 500, 500, (uint8_t*)&img[0]);
while (1);
}