Project

General

Profile

Revision 103

changed vbe_mode_info to static

View differences:

lab5.c
37 37
int(video_test_init)(uint16_t mode, uint8_t delay) {
38 38
    int r;
39 39
    if ((r = get_permissions_first_mbyte()))
40
    panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
40
        panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
41 41

  
42 42
    if (set_graphics_mode(mode)) {
43 43
        printf("%s: failed to set graphic mode %x.\n", __func__, mode);
44 44
        if (vg_exit())
45
        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
45
            printf("%s: vg_exit failed to exit to text mode.\n", __func__);
46 46
        return 1;
47 47
    };
48 48

  
49
    vbe_mode_info_t vbe_mem_info;
50

  
51
    if (vbe_get_mode_information(mode, &vbe_mem_info)) {
49
    if (vbe_get_mode_information(mode)) {
52 50
        printf("%s: failed to get information for mode %x.\n", __func__, mode);
53 51
        if (vg_exit())
54
        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
52
            printf("%s: vg_exit failed to exit to text mode.\n", __func__);
55 53
        return 1;
56 54
    }
57 55

  
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);
56
    map_vram(); // if function fails it aborts program
60 57

  
61
    map_vram(vram_base, vram_size); // if function fails it aborts program
62

  
63 58
    tickdelay(micros_to_ticks(delay*1e6));
64 59

  
65 60
    if (vg_exit()) {
66 61
        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
67 62
        if (free_memory())
68
        printf("%s: lm_free failed\n", __func__);
63
            printf("%s: lm_free failed\n", __func__);
69 64
        return 1;
70 65
    }
71 66

  
......
73 68
        printf("%s: lm_free failed\n", __func__);
74 69
        return 1;
75 70
    }
71

  
76 72
    return 0;
77 73
}
78 74

  
......
98 94
}
99 95

  
100 96
int(video_test_pattern)(uint16_t mode, uint8_t no_rectangles, uint32_t first, uint8_t step) {
101
    return 0;
97
  /* To be completed */
98
  printf("%s(0x%03x, %u, 0x%08x, %d): under construction\n", __func__,
99
         mode, no_rectangles, first, step);
100

  
101
  return 1;
102 102
}
103 103

  
104 104
int(video_test_xpm)(xpm_map_t xpm, uint16_t x, uint16_t y) {

Also available in: Unified diff