Project

General

Profile

Revision 126

controller in half

View differences:

lab5/graphics.c
49 49
    return SUCCESS;
50 50
}
51 51

  
52
int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p) {
53
    memset(info_p, 0, sizeof(vg_vbe_contr_info_t)); // reset values
54

  
55
    mmap_t controller_map;
56

  
57
    struct reg86 reg_86;
58
    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
59

  
60
    VbeInfoBlock *virtual_addr = lm_alloc(sizeof(VbeInfoBlock), &controller_map);
61

  
62
    virtual_addr->VbeSignature[0] = 'V';
63
    virtual_addr->VbeSignature[1] = 'B';
64
    virtual_addr->VbeSignature[2] = 'E';
65
    virtual_addr->VbeSignature[3] = '2';
66

  
67

  
68
    reg_86.intno = VC_BIOS_SERV;
69
    reg_86.ah = VBE_CALL;
70
    reg_86.al = VBE_CTRL_INFO;
71
    reg_86.es = PB2BASE(controller_map.phys);
72
    reg_86.di = PB2OFF(controller_map.phys);
73
    // BIOS CALL
74
    if (sys_int86(&reg_86)) {
75
        printf("%s: sys_int86 failed\n", __func__);
76
        if (free_memory()) {
77
            printf("%s: lm_free failed\n", __func__);
78
            return LCF_ERROR;
79
        }
80
        return BIOS_CALL_ERROR;
81
    }
82

  
83
    info_p->VBESignature[0] = virtual_addr->VbeSignature[0];
84
    info_p->VBESignature[1] = virtual_addr->VbeSignature[1];
85
    info_p->VBESignature[2] = virtual_addr->VbeSignature[2];
86
    info_p->VBESignature[3] = virtual_addr->VbeSignature[3];
87

  
88
    uint8_t lsb, msb;
89
    util_get_LSB(virtual_addr->VbeVersion, &lsb);
90
    util_get_MSB(virtual_addr->VbeVersion, &msb);
91
    info_p->VBEVersion[0] = lsb;
92
    info_p->VBEVersion[1] = msb;
93

  
94
    info_p->TotalMemory = (virtual_addr->TotalMemory << 6);
95

  
96
    // Convert Far Far Pointer to Virtual Address
97

  
98
    //uint32_t phys_ptr = FAR2PHYS(virtual_addr->OemStringPtr);
99

  
100

  
101

  
102

  
103

  
104

  
105

  
106
    return SUCCESS;
107
}
108

  
52 109
phys_bytes get_phys_addr(void) {
53 110
    return vbe_mem_info.PhysBasePtr;
54 111
}
lab5/graphics.h
12 12
#define SET_BLU(n)          (((n)&0xFF)      )
13 13
#define SET_COLOR(r,g,b)    (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
14 14
#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
15
#define PHYS2VIRT(n)
16 15

  
16
typedef struct __attribute__((packed)) {
17

  
18
    char        VbeSignature[4]     ;
19
    uint16_t    VbeVersion          ;
20
    uint32_t    OemStringPtr        ;
21
    uint8_t     Capabilities[4]     ;
22
    uint32_t    VideoModePtr        ;
23
    uint16_t    TotalMemory         ;
24

  
25
    uint16_t    OemSoftwareRev      ;
26
    uint32_t    OemVendorNamePtr    ;
27
    uint32_t    OemProductNamePtr   ;
28
    uint32_t    OemProductRevPtr    ;
29
    char        Reserved[222]       ;
30

  
31
    char        OemData[256]        ;
32
} VbeInfoBlock;
33

  
17 34
int (get_permission)(unsigned int base_addr, unsigned int size);
18 35

  
19 36
//int (get_permissions_first_mbyte)(void);
20 37

  
21 38
int (vbe_get_mode_information)(uint16_t mode);
22 39

  
40
int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p);
41

  
23 42
phys_bytes get_phys_addr(void);
24 43

  
25 44
unsigned int get_vram_size(void);

Also available in: Unified diff