// VBE Function 09h static u8 vbe_set_color(u16 color_number, u32 color_value) { vbe_prepare(); // call VBE function 09h (Set/Get Palette Data Function) M.x86.R_EAX = 0x4f09; M.x86.R_BL = 0x00; // set color M.x86.R_CX = 0x01; // set only one entry M.x86.R_DX = color_number; // ES:DI is address where color_value is stored, we store it at 2000:0000 M.x86.R_ES = 0x2000; M.x86.R_DI = 0x0; // store color value at ES:DI out32le(biosmem + (M.x86.R_ES << 4) + M.x86.R_DI, color_value); DEBUG_PRINTF_VBE("%s: setting color #%x: 0x%04x\n", __func__, color_number, color_value); // enable trace CHECK_DBG(DEBUG_TRACE_X86EMU) { X86EMU_trace_on(); } // run VESA Interrupt runInt10(); if (M.x86.R_AL != 0x4f) { DEBUG_PRINTF_VBE ("%s: VBE Set Palette Function NOT supported! AL=%x\n", __func__, M.x86.R_AL); return -1; } if (M.x86.R_AH != 0x0) { DEBUG_PRINTF_VBE ("%s: VBE Set Palette Function Return Code NOT OK! AH=%x\n", __func__, M.x86.R_AH); return M.x86.R_AH; } return 0; }
/* This function is used to setup the PMM struct in virtual memory * at a certain offset, the length of the PMM struct is returned */ u8 pmm_setup(u16 segment, u16 offset) { /* setup the PMM structure */ pmm_information_t *pis = (pmm_information_t *) (M.mem_base + (((u32) segment) << 4) + offset); memset(pis, 0, sizeof(pmm_information_t)); /* set signature to $PMM */ pis->signature[0] = '$'; pis->signature[1] = 'P'; pis->signature[2] = 'M'; pis->signature[3] = 'M'; /* revision as specified */ pis->struct_rev = 0x01; /* internal length, excluding code */ pis->length = ((void *)&(pis->code) - (void *)&(pis->signature)); /* the code to be executed, pointed to by entry_point_offset */ pis->code[0] = 0xCD; /* INT */ pis->code[1] = PMM_INT_NUM; /* my selfdefined PMM INT number */ pis->code[2] = 0xCB; /* RETF */ /* set the entry_point_offset, it should point to pis->code, segment is the segment of * this struct. Since pis->length is the length of the struct excluding code, offset+pis->length * points to the code... it's that simple ;-) */ out32le(&(pis->entry_point_offset), (u32) segment << 16 | (u32) (offset + pis->length)); /* checksum calculation */ u8 i; u8 checksum = 0; for (i = 0; i < pis->length; i++) { checksum += *(((u8 *) pis) + i); } pis->checksum = ((u8) 0) - checksum; CHECK_DBG(DEBUG_PMM) { DEBUG_PRINTF_PMM("PMM Structure:\n"); dump((void *)pis, sizeof(pmm_information_t)); } return sizeof(pmm_information_t); }