Revision 103
changed vbe_mode_info to static
graphics.c | ||
---|---|---|
7 | 7 |
#include <stdio.h> |
8 | 8 |
|
9 | 9 |
static void *video_mem; /** @brief Frame-buffer VM address */ |
10 |
//static vbe_mode_info_t vbe_mem_info;
|
|
10 |
static vbe_mode_info_t vbe_mem_info; |
|
11 | 11 |
static mmap_t mem_map; |
12 | 12 |
|
13 | 13 |
int (get_permission)(unsigned int base_addr, unsigned int size) { |
... | ... | |
21 | 21 |
return get_permission(MBYTE_BASE, MBYTE_SIZE); |
22 | 22 |
} |
23 | 23 |
|
24 |
int (vbe_get_mode_information)(uint16_t mode, vbe_mode_info_t *vmi_p) {
|
|
25 |
memset(vmi_p, 0, sizeof(vbe_mode_info_t)); // reset values
|
|
24 |
int (vbe_get_mode_information)(uint16_t mode) { |
|
25 |
memset(&vbe_mem_info, 0, sizeof(vbe_mode_info_t)); // reset values
|
|
26 | 26 |
|
27 | 27 |
struct reg86 reg_86; |
28 |
memset(®_86, 0, sizeof(reg_86)); // reset struct
|
|
28 |
memset(®_86, 0, sizeof(struct reg86)); // reset struct
|
|
29 | 29 |
|
30 | 30 |
vbe_mode_info_t *virtual_addr = lm_alloc(sizeof(vbe_mode_info_t), &mem_map); |
31 | 31 |
|
... | ... | |
45 | 45 |
return BIOS_CALL_ERROR; |
46 | 46 |
} |
47 | 47 |
|
48 |
vmi_p = memcpy((void*)vmi_p, (void*)virtual_addr, mem_map.size);
|
|
48 |
memcpy((void*)&vbe_mem_info, (void*)virtual_addr, mem_map.size);
|
|
49 | 49 |
return SUCCESS; |
50 | 50 |
} |
51 | 51 |
|
52 |
int (map_vram)(unsigned int vram_base, unsigned int vram_size) { |
|
52 |
phys_bytes get_phys_addr(void) { |
|
53 |
return vbe_mem_info.PhysBasePtr; |
|
54 |
} |
|
55 |
|
|
56 |
unsigned int get_vram_size(void) { |
|
57 |
return vbe_mem_info.XResolution * vbe_mem_info.YResolution * ((vbe_mem_info.BitsPerPixel + 7) >> 3); |
|
58 |
} |
|
59 |
|
|
60 |
uint16_t get_XRes(void) { |
|
61 |
return vbe_mem_info.XResolution; |
|
62 |
} |
|
63 |
|
|
64 |
uint16_t get_YRes(void) { |
|
65 |
return vbe_mem_info.YResolution; |
|
66 |
} |
|
67 |
|
|
68 |
uint16_t get_bits_pixel(void) { |
|
69 |
return vbe_mem_info.BitsPerPixel; |
|
70 |
} |
|
71 |
|
|
72 |
int (map_vram)(void) { |
|
53 | 73 |
int r; |
74 |
unsigned int vram_base = get_phys_addr(); |
|
75 |
unsigned int vram_size = get_vram_size(); |
|
54 | 76 |
if ((r = get_permission(vram_base, vram_size))) |
55 | 77 |
panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
56 | 78 |
|
... | ... | |
63 | 85 |
} |
64 | 86 |
|
65 | 87 |
int (free_memory)(void) { |
66 |
return lm_free(&mem_map); |
|
88 |
return !lm_free(&mem_map);
|
|
67 | 89 |
} |
68 | 90 |
|
69 | 91 |
int (set_graphics_mode)(uint16_t mode) { |
70 | 92 |
struct reg86 reg_86; |
71 | 93 |
|
72 |
memset(®_86, 0, sizeof(reg_86)); // reset struct
|
|
94 |
memset(®_86, 0, sizeof(struct reg86)); // reset struct
|
|
73 | 95 |
|
74 | 96 |
// Set Reg86 |
75 | 97 |
reg_86.intno = VC_BIOS_SERV; |
Also available in: Unified diff