Revision 99
complete restructure
lab5.c | ||
---|---|---|
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
int(video_test_init)(uint16_t mode, uint8_t delay) { |
38 |
int r; |
|
39 |
if ((r = get_permissions_first_mbyte())) |
|
40 |
panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
38 | 41 |
|
39 |
set_graphics_mode(mode); |
|
42 |
if (set_graphics_mode(mode)) { |
|
43 |
printf("%s: failed to set graphic mode %x.\n", __func__, mode); |
|
44 |
if (vg_exit()) |
|
45 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
46 |
return 1; |
|
47 |
}; |
|
40 | 48 |
|
49 |
vbe_mode_info_t vbe_mem_info; |
|
50 |
|
|
51 |
if (vbe_get_mode_information(mode, &vbe_mem_info)) { |
|
52 |
printf("%s: failed to get information for mode %x.\n", __func__, mode); |
|
53 |
if (vg_exit()) |
|
54 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
55 |
return 1; |
|
56 |
} |
|
57 |
|
|
58 |
unsigned int vram_base = vbe_mem_info.PhysBasePtr; |
|
59 |
unsigned int vram_size = vbe_mem_info.XResolution * vbe_mem_info.YResolution * ((vbe_mem_info.BitsPerPixel + 7) >> 3); |
|
60 |
|
|
61 |
map_vram(vram_base, vram_size); // if function fails it aborts program |
|
62 |
|
|
41 | 63 |
tickdelay(micros_to_ticks(delay*1e6)); |
42 | 64 |
|
43 |
vg_exit(); |
|
65 |
if (vg_exit()) { |
|
66 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
67 |
if (free_memory()) |
|
68 |
printf("%s: lm_free failed\n", __func__); |
|
69 |
return 1; |
|
70 |
} |
|
71 |
|
|
72 |
if (free_memory()) { |
|
73 |
printf("%s: lm_free failed\n", __func__); |
|
74 |
return 1; |
|
75 |
} |
|
76 |
|
|
44 | 77 |
return 0; |
45 | 78 |
} |
46 | 79 |
|
Also available in: Unified diff