1 /* 2 * Copyright 2012, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BIOS_MODULE_H_ 6 #define _BIOS_MODULE_H_ 7 8 9 #include <OS.h> 10 #include <module.h> 11 12 13 /*! BIOS call interface. 14 15 This module provides a mechanism to call PC BIOS interrupts (e.g. to use 16 the VESA BIOS). 17 18 Basic usage is as follows: 19 - Call bios_module_info::prepare(). This sets up memory mappings and 20 obtains exclusive access to the BIOS (only 1 thread is able to use the 21 BIOS at a time). 22 - Allocate memory for data that will be passed to BIOS interrupts using 23 bios_module_info::allocate_mem(). This returns a virtual address, to 24 get the physical address to pass to the BIOS use 25 bios_module_info::physical_address(). 26 - Call the BIOS with bios_module_info::interrupt(). 27 - Get the virtual location of any physical addresses returned using 28 bios_module_info::virtual_address(). 29 - Release the BIOS and free created memory mappings with 30 bios_module_info::finish(). 31 32 */ 33 34 35 // Cookie for the BIOS module functions. 36 typedef struct BIOSState bios_state; 37 38 39 // Registers to pass to a BIOS interrupt. 40 struct bios_regs { 41 uint32 eax; 42 uint32 ebx; 43 uint32 ecx; 44 uint32 edx; 45 uint32 edi; 46 uint32 esi; 47 uint32 ebp; 48 uint32 eflags; 49 uint32 ds; 50 uint32 es; 51 uint32 fs; 52 uint32 gs; 53 }; 54 55 56 struct bios_module_info { 57 module_info info; 58 59 status_t (*prepare)(bios_state** _state); 60 status_t (*interrupt)(bios_state* state, uint8 vector, bios_regs* regs); 61 void (*finish)(bios_state* state); 62 63 // Memory management methods. 64 void* (*allocate_mem)(bios_state* state, size_t size); 65 uint32 (*physical_address)(bios_state* state, void* virtualAddress); 66 void* (*virtual_address)(bios_state* state, uint32 physicalAddress); 67 }; 68 69 70 #define B_BIOS_MODULE_NAME "generic/bios/v1" 71 72 73 #endif // _BIOS_MODULE_H_ 74