Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22916e6284 | ||
|
|
570134c7ba | ||
|
|
a029f4e13b | ||
|
|
ae435cb4cc | ||
|
|
f8a0d1c0b8 | ||
|
|
f0b1025503 | ||
|
|
c832580f19 | ||
|
|
9a118322a0 | ||
|
|
2689a6e776 |
@@ -290,38 +290,29 @@ static const char *bios_ansi_input = "";
|
|||||||
struct bios_key {
|
struct bios_key {
|
||||||
/** Scancode */
|
/** Scancode */
|
||||||
uint8_t scancode;
|
uint8_t scancode;
|
||||||
/** Relative key value */
|
/** Key code */
|
||||||
uint16_t rkey;
|
uint16_t key;
|
||||||
} __attribute__ (( packed ));
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
/**
|
|
||||||
* Define a BIOS key mapping
|
|
||||||
*
|
|
||||||
* @v scancode Scancode
|
|
||||||
* @v key iPXE key code
|
|
||||||
* @v bioskey BIOS key mapping
|
|
||||||
*/
|
|
||||||
#define BIOS_KEY( scancode, key ) { scancode, KEY_REL ( key ) }
|
|
||||||
|
|
||||||
/** Mapping from BIOS scan codes to iPXE key codes */
|
/** Mapping from BIOS scan codes to iPXE key codes */
|
||||||
static const struct bios_key bios_keys[] = {
|
static const struct bios_key bios_keys[] = {
|
||||||
BIOS_KEY ( 0x53, KEY_DC ),
|
{ 0x53, KEY_DC },
|
||||||
BIOS_KEY ( 0x48, KEY_UP ),
|
{ 0x48, KEY_UP },
|
||||||
BIOS_KEY ( 0x50, KEY_DOWN ),
|
{ 0x50, KEY_DOWN },
|
||||||
BIOS_KEY ( 0x4b, KEY_LEFT ),
|
{ 0x4b, KEY_LEFT },
|
||||||
BIOS_KEY ( 0x4d, KEY_RIGHT ),
|
{ 0x4d, KEY_RIGHT },
|
||||||
BIOS_KEY ( 0x47, KEY_HOME ),
|
{ 0x47, KEY_HOME },
|
||||||
BIOS_KEY ( 0x4f, KEY_END ),
|
{ 0x4f, KEY_END },
|
||||||
BIOS_KEY ( 0x49, KEY_PPAGE ),
|
{ 0x49, KEY_PPAGE },
|
||||||
BIOS_KEY ( 0x51, KEY_NPAGE ),
|
{ 0x51, KEY_NPAGE },
|
||||||
BIOS_KEY ( 0x3f, KEY_F5 ),
|
{ 0x3f, KEY_F5 },
|
||||||
BIOS_KEY ( 0x40, KEY_F6 ),
|
{ 0x40, KEY_F6 },
|
||||||
BIOS_KEY ( 0x41, KEY_F7 ),
|
{ 0x41, KEY_F7 },
|
||||||
BIOS_KEY ( 0x42, KEY_F8 ),
|
{ 0x42, KEY_F8 },
|
||||||
BIOS_KEY ( 0x43, KEY_F9 ),
|
{ 0x43, KEY_F9 },
|
||||||
BIOS_KEY ( 0x44, KEY_F10 ),
|
{ 0x44, KEY_F10 },
|
||||||
BIOS_KEY ( 0x85, KEY_F11 ),
|
{ 0x85, KEY_F11 },
|
||||||
BIOS_KEY ( 0x86, KEY_F12 ),
|
{ 0x86, KEY_F12 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -332,7 +323,7 @@ static const struct bios_key bios_keys[] = {
|
|||||||
*/
|
*/
|
||||||
static const char * bios_ansi_seq ( unsigned int scancode ) {
|
static const char * bios_ansi_seq ( unsigned int scancode ) {
|
||||||
static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
|
static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
|
||||||
unsigned int rkey;
|
unsigned int key;
|
||||||
unsigned int terminator;
|
unsigned int terminator;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -347,9 +338,9 @@ static const char * bios_ansi_seq ( unsigned int scancode ) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Construct escape sequence */
|
/* Construct escape sequence */
|
||||||
rkey = bios_keys[i].rkey;
|
key = bios_keys[i].key;
|
||||||
n = KEY_ANSI_N ( rkey );
|
n = KEY_ANSI_N ( key );
|
||||||
terminator = KEY_ANSI_TERMINATOR ( rkey );
|
terminator = KEY_ANSI_TERMINATOR ( key );
|
||||||
*(tmp++) = '[';
|
*(tmp++) = '[';
|
||||||
if ( n )
|
if ( n )
|
||||||
tmp += sprintf ( tmp, "%d", n );
|
tmp += sprintf ( tmp, "%d", n );
|
||||||
@@ -488,7 +479,6 @@ struct console_driver bios_console __console_driver = {
|
|||||||
static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
||||||
unsigned int discard_a;
|
unsigned int discard_a;
|
||||||
unsigned int scancode;
|
unsigned int scancode;
|
||||||
unsigned int rkey;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
uint16_t keypress;
|
uint16_t keypress;
|
||||||
int key;
|
int key;
|
||||||
@@ -531,10 +521,9 @@ static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
|
|||||||
|
|
||||||
/* Handle special keys */
|
/* Handle special keys */
|
||||||
if ( key >= KEY_MIN ) {
|
if ( key >= KEY_MIN ) {
|
||||||
rkey = KEY_REL ( key );
|
|
||||||
for ( i = 0 ; i < ( sizeof ( bios_keys ) /
|
for ( i = 0 ; i < ( sizeof ( bios_keys ) /
|
||||||
sizeof ( bios_keys[0] ) ) ; i++ ) {
|
sizeof ( bios_keys[0] ) ) ; i++ ) {
|
||||||
if ( bios_keys[i].rkey == rkey ) {
|
if ( bios_keys[i].key == key ) {
|
||||||
scancode = bios_keys[i].scancode;
|
scancode = bios_keys[i].scancode;
|
||||||
keypress = ( scancode << 8 );
|
keypress = ( scancode << 8 );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1032,8 +1032,9 @@ static void nii_poll_tx ( struct net_device *netdev, unsigned int stat ) {
|
|||||||
if ( stat & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN )
|
if ( stat & PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Ignore spurious completions reported by some devices */
|
||||||
assert ( nii->txbuf != NULL );
|
if ( ! nii->txbuf )
|
||||||
|
return;
|
||||||
|
|
||||||
/* Complete transmission */
|
/* Complete transmission */
|
||||||
iobuf = nii->txbuf;
|
iobuf = nii->txbuf;
|
||||||
@@ -1131,7 +1132,7 @@ static void nii_poll ( struct net_device *netdev ) {
|
|||||||
/* Get status */
|
/* Get status */
|
||||||
op = NII_OP ( PXE_OPCODE_GET_STATUS,
|
op = NII_OP ( PXE_OPCODE_GET_STATUS,
|
||||||
( PXE_OPFLAGS_GET_INTERRUPT_STATUS |
|
( PXE_OPFLAGS_GET_INTERRUPT_STATUS |
|
||||||
( nii->txbuf ? PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS : 0)|
|
PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS |
|
||||||
( nii->media ? PXE_OPFLAGS_GET_MEDIA_STATUS : 0 ) ) );
|
( nii->media ? PXE_OPFLAGS_GET_MEDIA_STATUS : 0 ) ) );
|
||||||
if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
|
if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
|
||||||
rc = -EIO_STAT ( stat );
|
rc = -EIO_STAT ( stat );
|
||||||
@@ -1141,8 +1142,7 @@ static void nii_poll ( struct net_device *netdev ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Process any TX completions */
|
/* Process any TX completions */
|
||||||
if ( nii->txbuf )
|
nii_poll_tx ( netdev, stat );
|
||||||
nii_poll_tx ( netdev, stat );
|
|
||||||
|
|
||||||
/* Process any RX completions */
|
/* Process any RX completions */
|
||||||
nii_poll_rx ( netdev );
|
nii_poll_rx ( netdev );
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
|||||||
}
|
}
|
||||||
} else if ( keycode <= USBKBD_KEY_UP ) {
|
} else if ( keycode <= USBKBD_KEY_UP ) {
|
||||||
/* Special keys */
|
/* Special keys */
|
||||||
static const unsigned int special[] = {
|
static const uint16_t special[] = {
|
||||||
0, 0, 0, 0, 0, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9,
|
0, 0, 0, 0, 0, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9,
|
||||||
KEY_F10, KEY_F11, KEY_F12, 0, 0, 0, KEY_IC, KEY_HOME,
|
KEY_F10, KEY_F11, KEY_F12, 0, 0, 0, KEY_IC, KEY_HOME,
|
||||||
KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
|
KEY_PPAGE, KEY_DC, KEY_END, KEY_NPAGE, KEY_RIGHT,
|
||||||
@@ -110,7 +110,7 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers,
|
|||||||
if ( leds & USBKBD_LED_NUM_LOCK ) {
|
if ( leds & USBKBD_LED_NUM_LOCK ) {
|
||||||
key = "1234567890." [ keycode - USBKBD_KEY_PAD_1 ];
|
key = "1234567890." [ keycode - USBKBD_KEY_PAD_1 ];
|
||||||
} else {
|
} else {
|
||||||
static const unsigned int keypad[] = {
|
static const uint16_t keypad[] = {
|
||||||
KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, 0,
|
KEY_END, KEY_DOWN, KEY_NPAGE, KEY_LEFT, 0,
|
||||||
KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PPAGE,
|
KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PPAGE,
|
||||||
KEY_IC, KEY_DC
|
KEY_IC, KEY_DC
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ struct keymap {
|
|||||||
#define KEYMAP_PSEUDO 0x80
|
#define KEYMAP_PSEUDO 0x80
|
||||||
|
|
||||||
/** Ctrl key flag */
|
/** Ctrl key flag */
|
||||||
#define KEYMAP_CTRL 0x01000000
|
#define KEYMAP_CTRL 0x0100
|
||||||
|
|
||||||
/** CapsLock key flag */
|
/** CapsLock key flag */
|
||||||
#define KEYMAP_CAPSLOCK 0x02000000
|
#define KEYMAP_CAPSLOCK 0x0200
|
||||||
|
|
||||||
/** Undo CapsLock key flag
|
/** Undo CapsLock key flag
|
||||||
*
|
*
|
||||||
@@ -64,13 +64,13 @@ struct keymap {
|
|||||||
* in order to correctly handle keyboard mappings that swap alphabetic
|
* in order to correctly handle keyboard mappings that swap alphabetic
|
||||||
* and non-alphabetic keys.
|
* and non-alphabetic keys.
|
||||||
*/
|
*/
|
||||||
#define KEYMAP_CAPSLOCK_UNDO 0x04000000
|
#define KEYMAP_CAPSLOCK_UNDO 0x0400
|
||||||
|
|
||||||
/** Undo and redo CapsLock key flags */
|
/** Undo and redo CapsLock key flags */
|
||||||
#define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO )
|
#define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO )
|
||||||
|
|
||||||
/** AltGr key flag */
|
/** AltGr key flag */
|
||||||
#define KEYMAP_ALTGR 0x08000000
|
#define KEYMAP_ALTGR 0x0800
|
||||||
|
|
||||||
extern unsigned int key_remap ( unsigned int character );
|
extern unsigned int key_remap ( unsigned int character );
|
||||||
extern struct keymap * keymap_find ( const char *name );
|
extern struct keymap * keymap_find ( const char *name );
|
||||||
|
|||||||
+5
-40
@@ -49,54 +49,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#define ESC 0x1b
|
#define ESC 0x1b
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special keys outside the normal Unicode range
|
* Special keys outside the normal ASCII range
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* The names are chosen to match those used by curses. The values are
|
* The names are chosen to match those used by curses. The values are
|
||||||
* chosen to facilitate easy conversion from a received ANSI escape
|
* chosen to facilitate easy conversion from a received ANSI escape
|
||||||
* sequence to a KEY_XXX constant.
|
* sequence to a KEY_XXX constant.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
#define KEY_ANSI( n, terminator ) ( 0x100 * ( (n) + 1 ) + (terminator) )
|
||||||
* Minimum value for special keypresses
|
#define KEY_ANSI_N( key ) ( ( (key) / 0x100 ) - 1 )
|
||||||
*
|
|
||||||
* This value is chosen to lie above the maximum Unicode code point
|
|
||||||
* value 0x10ffff.
|
|
||||||
*/
|
|
||||||
#define KEY_MIN 0x110000
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct relative key value
|
|
||||||
*
|
|
||||||
* @v key Key value
|
|
||||||
* @ret rkey Relative key value
|
|
||||||
*/
|
|
||||||
#define KEY_REL( key ) ( (key) - KEY_MIN )
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct ANSI escape sequence key value
|
|
||||||
*
|
|
||||||
* @v n ANSI escape sequence numeric portion, or 0 for none
|
|
||||||
* @v terminator ANSI escape sequence terminating character
|
|
||||||
* @ret key Key value
|
|
||||||
*/
|
|
||||||
#define KEY_ANSI( n, terminator ) ( KEY_MIN + ( (n) << 8 ) + (terminator) )
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract ANSI escape sequence numeric portion
|
|
||||||
*
|
|
||||||
* @v key Key value (or relative key value)
|
|
||||||
* @ret n ANSI escape sequence numeric portion, or 0 for none
|
|
||||||
*/
|
|
||||||
#define KEY_ANSI_N( key ) ( ( (key) >> 8 ) & 0xff )
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract ANSI escape sequence terminating character
|
|
||||||
*
|
|
||||||
* @v key Key value (or relative key value)
|
|
||||||
* @ret terminator ANSI escape sequence terminating character
|
|
||||||
*/
|
|
||||||
#define KEY_ANSI_TERMINATOR( key ) ( (key) & 0xff )
|
#define KEY_ANSI_TERMINATOR( key ) ( (key) & 0xff )
|
||||||
|
|
||||||
|
#define KEY_MIN 0x101
|
||||||
#define KEY_UP KEY_ANSI ( 0, 'A' ) /**< Up arrow */
|
#define KEY_UP KEY_ANSI ( 0, 'A' ) /**< Up arrow */
|
||||||
#define KEY_DOWN KEY_ANSI ( 0, 'B' ) /**< Down arrow */
|
#define KEY_DOWN KEY_ANSI ( 0, 'B' ) /**< Down arrow */
|
||||||
#define KEY_RIGHT KEY_ANSI ( 0, 'C' ) /**< Right arrow */
|
#define KEY_RIGHT KEY_ANSI ( 0, 'C' ) /**< Right arrow */
|
||||||
|
|||||||
+269
-168
@@ -44,39 +44,65 @@ struct efi_veto {
|
|||||||
/**
|
/**
|
||||||
* Check if driver is vetoed
|
* Check if driver is vetoed
|
||||||
*
|
*
|
||||||
* @v binding Driver binding protocol
|
|
||||||
* @v loaded Loaded image protocol
|
|
||||||
* @v wtf Component name protocol, if present
|
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name (in "eng" language), if present
|
* @v name Driver name (in "eng" language), if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
int ( * veto ) ( EFI_DRIVER_BINDING_PROTOCOL *binding,
|
int ( * veto ) ( const char *manufacturer, const CHAR16 *name );
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded,
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *wtf,
|
|
||||||
const char *manufacturer, const CHAR16 *name );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload an EFI driver
|
* Unload an EFI driver
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v driver Driver binding handle
|
||||||
|
* @v image Image handle to fill in on failure
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_unload ( EFI_HANDLE driver ) {
|
static int efi_veto_unload ( EFI_HANDLE driver, EFI_HANDLE *image ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
union {
|
||||||
|
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
||||||
|
void *interface;
|
||||||
|
} binding;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Unload the driver */
|
/* Clear image handle */
|
||||||
if ( ( efirc = bs->UnloadImage ( driver ) ) != 0 ) {
|
*image = NULL;
|
||||||
|
|
||||||
|
/* Open driver binding protocol */
|
||||||
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
|
driver, &efi_driver_binding_protocol_guid,
|
||||||
|
&binding.interface, efi_image_handle, driver,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not unload: %s\n",
|
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
||||||
efi_handle_name ( driver ), strerror ( rc ) );
|
"protocol: %s\n", efi_handle_name ( driver ),
|
||||||
return rc;
|
strerror ( rc ) );
|
||||||
|
goto err_binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
/* Identify image handle */
|
||||||
|
*image = binding.binding->ImageHandle;
|
||||||
|
|
||||||
|
/* Unload the driver */
|
||||||
|
if ( ( efirc = bs->UnloadImage ( *image ) ) != 0 ) {
|
||||||
|
rc = -EEFI ( efirc );
|
||||||
|
DBGC ( driver, "EFIVETO %s could not unload",
|
||||||
|
efi_handle_name ( driver ) );
|
||||||
|
DBGC ( driver, " %s: %s\n",
|
||||||
|
efi_handle_name ( *image ), strerror ( rc ) );
|
||||||
|
goto err_unload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invalidate now-unloaded image handle */
|
||||||
|
*image = NULL;
|
||||||
|
|
||||||
|
err_unload:
|
||||||
|
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
||||||
|
efi_image_handle, driver );
|
||||||
|
err_binding:
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,62 +155,78 @@ static int efi_veto_disconnect ( EFI_HANDLE driver ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstall an EFI driver binding protocol
|
* Uninstall an EFI protocol
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v agent Agent handle
|
||||||
|
* @v loaded Loaded image protocol filter, or NULL
|
||||||
|
* @v handle Potentially opened handle
|
||||||
|
* @v protocol Installed protocol
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_uninstall ( EFI_HANDLE driver ) {
|
static int efi_veto_uninstall ( EFI_HANDLE agent,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded,
|
||||||
|
EFI_HANDLE handle, EFI_GUID *protocol ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
union {
|
void *interface;
|
||||||
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
void *method;
|
||||||
void *interface;
|
size_t offset;
|
||||||
} binding;
|
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Open driver binding protocol */
|
/* Open protocol */
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
driver, &efi_driver_binding_protocol_guid,
|
handle, protocol, &interface, efi_image_handle, agent,
|
||||||
&binding.interface, efi_image_handle, driver,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
DBGC ( agent, "EFIVETO %s could not open %s",
|
||||||
"protocol: %s\n", efi_handle_name ( driver ),
|
efi_handle_name ( agent ), efi_guid_ntoa ( protocol ) );
|
||||||
strerror ( rc ) );
|
DBGC ( agent, " on %s: %s\n",
|
||||||
|
efi_handle_name ( handle ), strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close driver binding protocol */
|
/* Get representative method pointer, if known */
|
||||||
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
method = efi_veto_method ( protocol, interface );
|
||||||
efi_image_handle, driver );
|
|
||||||
|
|
||||||
/* Uninstall driver binding protocol */
|
/* Close protocol */
|
||||||
|
bs->CloseProtocol ( handle, protocol, efi_image_handle, agent );
|
||||||
|
|
||||||
|
/* Do nothing if method does not match filter */
|
||||||
|
if ( loaded ) {
|
||||||
|
offset = ( method - loaded->ImageBase );
|
||||||
|
if ( offset > loaded->ImageSize )
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print debug message before potential invalidation of handle */
|
||||||
|
DBGC2 ( agent, "EFIVETO %s uninstalling %s",
|
||||||
|
efi_handle_name ( agent ), efi_guid_ntoa ( protocol ) );
|
||||||
|
DBGC2 ( agent, " from %s\n", efi_handle_name ( handle ) );
|
||||||
|
|
||||||
|
/* Uninstall protocol */
|
||||||
if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
|
if ( ( efirc = bs->UninstallMultipleProtocolInterfaces (
|
||||||
driver, &efi_driver_binding_protocol_guid,
|
handle, protocol, interface, NULL ) ) != 0 ) {
|
||||||
binding.binding, NULL ) ) != 0 ) {
|
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not uninstall driver "
|
DBGC ( agent, "EFIVETO %s could not uninstall %s",
|
||||||
"binding protocol: %s\n",
|
efi_handle_name ( agent ), efi_guid_ntoa ( protocol ) );
|
||||||
efi_handle_name ( driver ), strerror ( rc ) );
|
DBGC ( agent, " from %s: %s\n",
|
||||||
|
efi_handle_name ( handle ), strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGC2 ( driver, "EFIVETO %s uninstalled driver binding protocol\n",
|
|
||||||
efi_handle_name ( driver ) );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close protocol on handle potentially opened by an EFI driver
|
* Close protocol on handle potentially opened by an EFI driver
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v agent Agent handle
|
||||||
* @v handle Potentially opened handle
|
* @v handle Potentially opened handle
|
||||||
* @v protocol Opened protocol
|
* @v protocol Opened protocol
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_close_protocol ( EFI_HANDLE driver, EFI_HANDLE handle,
|
static int efi_veto_close ( EFI_HANDLE agent, EFI_HANDLE handle,
|
||||||
EFI_GUID *protocol ) {
|
EFI_GUID *protocol ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
|
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
|
||||||
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
|
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
|
||||||
@@ -198,27 +240,28 @@ static int efi_veto_close_protocol ( EFI_HANDLE driver, EFI_HANDLE handle,
|
|||||||
if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
|
if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
|
||||||
&count ) ) != 0 ) {
|
&count ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not retrieve openers",
|
DBGC ( agent, "EFIVETO %s could not retrieve openers",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( agent ) );
|
||||||
DBGC ( driver, " of %s %s: %s", efi_handle_name ( handle ),
|
DBGC ( agent, " of %s %s: %s", efi_handle_name ( handle ),
|
||||||
efi_guid_ntoa ( protocol ), strerror ( rc ) );
|
efi_guid_ntoa ( protocol ), strerror ( rc ) );
|
||||||
goto err_list;
|
goto err_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close anything opened by this driver */
|
/* Close anything opened by this driver */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
opener = &openers[i];
|
opener = &openers[ count - i - 1 ];
|
||||||
if ( opener->AgentHandle != driver )
|
if ( opener->AgentHandle != agent )
|
||||||
continue;
|
continue;
|
||||||
controller = opener->ControllerHandle;
|
controller = opener->ControllerHandle;
|
||||||
DBGC_EFI_OPENER ( driver, handle, protocol, opener );
|
DBGC_EFI_OPENER ( agent, handle, protocol, opener );
|
||||||
if ( ( efirc = bs->CloseProtocol ( handle, protocol, driver,
|
if ( ( efirc = bs->CloseProtocol ( handle, protocol, agent,
|
||||||
controller ) ) != 0 ) {
|
controller ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not close stray open",
|
DBGC ( agent, "EFIVETO %s could not close stray open",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( agent ) );
|
||||||
DBGC ( driver, " of %s: %s\n",
|
DBGC ( agent, " of %s %s: %s\n",
|
||||||
efi_handle_name ( handle ), strerror ( rc ) );
|
efi_handle_name ( handle ),
|
||||||
|
efi_guid_ntoa ( protocol ), strerror ( rc ) );
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,15 +276,19 @@ static int efi_veto_close_protocol ( EFI_HANDLE driver, EFI_HANDLE handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close handle potentially opened by an EFI driver
|
* Close/uninstall handle potentially used by an EFI driver
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v agent Agent handle
|
||||||
|
* @v loaded Loaded image protocol for uninstallation, or NULL
|
||||||
* @v handle Potentially opened handle
|
* @v handle Potentially opened handle
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_close_handle ( EFI_HANDLE driver, EFI_HANDLE handle ) {
|
static int efi_veto_handle ( EFI_HANDLE agent,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded,
|
||||||
|
EFI_HANDLE handle ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
EFI_GUID **protocols;
|
EFI_GUID **protocols;
|
||||||
|
EFI_GUID *protocol;
|
||||||
UINTN count;
|
UINTN count;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
@@ -251,23 +298,34 @@ static int efi_veto_close_handle ( EFI_HANDLE driver, EFI_HANDLE handle ) {
|
|||||||
if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
|
if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
|
||||||
&count ) ) != 0 ) {
|
&count ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not retrieve protocols",
|
DBGC ( agent, "EFIVETO %s could not retrieve protocols",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( agent ) );
|
||||||
DBGC ( driver, " for %s: %s\n",
|
DBGC ( agent, " for %s: %s\n",
|
||||||
efi_handle_name ( handle ), strerror ( rc ) );
|
efi_handle_name ( handle ), strerror ( rc ) );
|
||||||
goto err_list;
|
goto err_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close each protocol */
|
/* Close each protocol */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
if ( ( rc = efi_veto_close_protocol ( driver, handle,
|
protocol = protocols[ count - i - 1];
|
||||||
protocols[i] ) ) != 0 )
|
if ( ( rc = efi_veto_close ( agent, handle, protocol ) ) != 0 )
|
||||||
goto err_close;
|
goto err_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Uninstall each protocol, if applicable */
|
||||||
|
if ( loaded ) {
|
||||||
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
|
protocol = protocols[ count - i - 1];
|
||||||
|
if ( ( rc = efi_veto_uninstall ( agent, loaded, handle,
|
||||||
|
protocol ) ) != 0 )
|
||||||
|
goto err_uninstall;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
|
err_uninstall:
|
||||||
err_close:
|
err_close:
|
||||||
bs->FreePool ( protocols );
|
bs->FreePool ( protocols );
|
||||||
err_list:
|
err_list:
|
||||||
@@ -275,14 +333,17 @@ static int efi_veto_close_handle ( EFI_HANDLE driver, EFI_HANDLE handle ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close all remaining handles opened by an EFI driver
|
* Close/uninstall all remaining handles used by an EFI driver
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v agent Agent handle
|
||||||
|
* @v loaded Loaded image protocol for uninstallation, or NULL
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_close ( EFI_HANDLE driver ) {
|
static int efi_veto_handles ( EFI_HANDLE agent,
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
EFI_HANDLE *handles;
|
EFI_HANDLE *handles;
|
||||||
|
EFI_HANDLE handle;
|
||||||
UINTN count;
|
UINTN count;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
@@ -292,24 +353,25 @@ static int efi_veto_close ( EFI_HANDLE driver ) {
|
|||||||
if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
|
if ( ( efirc = bs->LocateHandleBuffer ( AllHandles, NULL, NULL,
|
||||||
&count, &handles ) ) != 0 ) {
|
&count, &handles ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( driver, "EFIVETO %s could not enumerate handles: %s\n",
|
DBGC ( agent, "EFIVETO %s could not enumerate handles: %s\n",
|
||||||
efi_handle_name ( driver ), strerror ( rc ) );
|
efi_handle_name ( agent ), strerror ( rc ) );
|
||||||
goto err_list;
|
goto err_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close each handle */
|
/* Close and/or uninstall each handle */
|
||||||
for ( i = 0 ; i < count ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
if ( ( rc = efi_veto_close_handle ( driver,
|
handle = handles[ count - i - 1 ];
|
||||||
handles[i] ) ) != 0 )
|
if ( ( rc = efi_veto_handle ( agent, loaded, handle ) ) != 0 )
|
||||||
goto err_close;
|
goto err_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
rc = 0;
|
rc = 0;
|
||||||
DBGC2 ( driver, "EFIVETO %s closed all remaining handles\n",
|
DBGC2 ( agent, "EFIVETO %s closed%s all remaining handles\n",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( agent ),
|
||||||
|
( loaded ? " and uninstalled" : "" ) );
|
||||||
|
|
||||||
err_close:
|
err_handle:
|
||||||
bs->FreePool ( handles );
|
bs->FreePool ( handles );
|
||||||
err_list:
|
err_list:
|
||||||
return rc;
|
return rc;
|
||||||
@@ -318,10 +380,11 @@ static int efi_veto_close ( EFI_HANDLE driver ) {
|
|||||||
/**
|
/**
|
||||||
* Terminate an EFI driver with extreme prejudice
|
* Terminate an EFI driver with extreme prejudice
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v driver Driver handle
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_destroy ( EFI_HANDLE driver ) {
|
static int efi_veto_destroy ( EFI_HANDLE driver ) {
|
||||||
|
EFI_GUID *binding = &efi_driver_binding_protocol_guid;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Disconnect driver from all handles */
|
/* Disconnect driver from all handles */
|
||||||
@@ -329,53 +392,91 @@ static int efi_veto_destroy ( EFI_HANDLE driver ) {
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Uninstall driver binding protocol */
|
/* Uninstall driver binding protocol */
|
||||||
if ( ( rc = efi_veto_uninstall ( driver ) ) != 0 )
|
if ( ( rc = efi_veto_uninstall ( driver, NULL, driver,
|
||||||
|
binding ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Close any remaining opened handles */
|
/* Close any remaining opened handles */
|
||||||
if ( ( rc = efi_veto_close ( driver ) ) != 0 )
|
if ( ( rc = efi_veto_handles ( driver, NULL ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
DBGC ( driver, "EFIVETO %s forcibly removed\n",
|
DBGC ( driver, "EFIVETO %s forcibly removed driver\n",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( driver ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Veto an EFI driver
|
* Veto an EFI driver handle
|
||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v driver Driver handle
|
||||||
|
* @ret image Image handle, if still present after veto attempt
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_driver ( EFI_HANDLE driver ) {
|
static int efi_veto_driver ( EFI_HANDLE driver, EFI_HANDLE *image ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Try gracefully unloading the driver */
|
/* Try gracefully unloading the underlying image */
|
||||||
if ( ( rc = efi_veto_unload ( driver ) ) == 0 )
|
if ( ( rc = efi_veto_unload ( driver, image ) ) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If that fails, use a hammer */
|
/* If that fails, use a hammer */
|
||||||
if ( ( rc = efi_veto_destroy ( driver ) ) == 0 )
|
if ( ( rc = efi_veto_destroy ( driver ) ) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
DBGC ( driver, "EFIVETO %s could not veto driver: %s\n",
|
||||||
|
efi_handle_name ( driver ), strerror ( rc ) );
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Veto an EFI image handle
|
||||||
|
*
|
||||||
|
* @v image Image handle
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
static int efi_veto_image ( EFI_HANDLE image ) {
|
||||||
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
|
union {
|
||||||
|
EFI_LOADED_IMAGE_PROTOCOL *loaded;
|
||||||
|
void *interface;
|
||||||
|
} loaded;
|
||||||
|
EFI_STATUS efirc;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
/* Open loaded image protocol */
|
||||||
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
|
image, &efi_loaded_image_protocol_guid,
|
||||||
|
&loaded.interface, efi_image_handle, image,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
||||||
|
rc = -EEFI ( efirc );
|
||||||
|
DBGC ( image, "EFIVETO %s could not open loaded image "
|
||||||
|
"protocol: %s\n", efi_handle_name ( image ),
|
||||||
|
strerror ( rc ) );
|
||||||
|
goto err_loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close and uninstall any remaining handles */
|
||||||
|
if ( ( rc = efi_veto_handles ( image, loaded.loaded ) ) != 0 )
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
DBGC ( image, "EFIVETO %s forcibly removed image\n",
|
||||||
|
efi_handle_name ( image ) );
|
||||||
|
|
||||||
|
bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid,
|
||||||
|
efi_image_handle, image );
|
||||||
|
err_loaded:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Veto Ip4ConfigDxe driver on some platforms
|
* Veto Ip4ConfigDxe driver on some platforms
|
||||||
*
|
*
|
||||||
* @v binding Driver binding protocol
|
|
||||||
* @v loaded Loaded image protocol
|
|
||||||
* @v wtf Component name protocol, if present
|
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name, if present
|
* @v name Driver name, if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
static int
|
static int efi_veto_ip4config ( const char *manufacturer,
|
||||||
efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
const CHAR16 *name ) {
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *wtf __unused,
|
|
||||||
const char *manufacturer, const CHAR16 *name ) {
|
|
||||||
static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
|
static const CHAR16 ip4cfg[] = L"IP4 CONFIG Network Service Driver";
|
||||||
static const char *dell = "Dell Inc.";
|
static const char *dell = "Dell Inc.";
|
||||||
static const char *itautec = "Itautec S.A.";
|
static const char *itautec = "Itautec S.A.";
|
||||||
@@ -397,18 +498,11 @@ efi_veto_ip4config ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
|||||||
/**
|
/**
|
||||||
* Veto HP XhciDxe driver
|
* Veto HP XhciDxe driver
|
||||||
*
|
*
|
||||||
* @v binding Driver binding protocol
|
|
||||||
* @v loaded Loaded image protocol
|
|
||||||
* @v wtf Component name protocol, if present
|
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name, if present
|
* @v name Driver name, if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
static int
|
static int efi_veto_hp_xhci ( const char *manufacturer, const CHAR16 *name ) {
|
||||||
efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *wtf __unused,
|
|
||||||
const char *manufacturer, const CHAR16 *name ) {
|
|
||||||
static const CHAR16 xhci[] = L"Usb Xhci Driver";
|
static const CHAR16 xhci[] = L"Usb Xhci Driver";
|
||||||
static const char *hp = "HP";
|
static const char *hp = "HP";
|
||||||
struct pci_driver *driver;
|
struct pci_driver *driver;
|
||||||
@@ -439,17 +533,13 @@ efi_veto_hp_xhci ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
|||||||
* Veto VMware UefiPxeBcDxe driver
|
* Veto VMware UefiPxeBcDxe driver
|
||||||
*
|
*
|
||||||
* @v binding Driver binding protocol
|
* @v binding Driver binding protocol
|
||||||
* @v loaded Loaded image protocol
|
|
||||||
* @v wtf Component name protocol, if present
|
* @v wtf Component name protocol, if present
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @v name Driver name, if present
|
* @v name Driver name, if present
|
||||||
* @ret vetoed Driver is to be vetoed
|
* @ret vetoed Driver is to be vetoed
|
||||||
*/
|
*/
|
||||||
static int
|
static int efi_veto_vmware_uefipxebc ( const char *manufacturer,
|
||||||
efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
const CHAR16 *name ) {
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded __unused,
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *wtf __unused,
|
|
||||||
const char *manufacturer, const CHAR16 *name ) {
|
|
||||||
static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
|
static const CHAR16 uefipxebc[] = L"UEFI PXE Base Code Driver";
|
||||||
static const char *vmware = "VMware, Inc.";
|
static const char *vmware = "VMware, Inc.";
|
||||||
|
|
||||||
@@ -466,6 +556,31 @@ efi_veto_vmware_uefipxebc ( EFI_DRIVER_BINDING_PROTOCOL *binding __unused,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Veto VirtualBox E1kNetDxe driver
|
||||||
|
*
|
||||||
|
* @v manufacturer Manufacturer name, if present
|
||||||
|
* @v name Driver name, if present
|
||||||
|
* @ret vetoed Driver is to be vetoed
|
||||||
|
*/
|
||||||
|
static int efi_veto_vbox_e1knet ( const char *manufacturer,
|
||||||
|
const CHAR16 *name ) {
|
||||||
|
static const CHAR16 e1knet[] = L"E1000 network interface card Driver";
|
||||||
|
static const char *vbox = "innotek GmbH";
|
||||||
|
|
||||||
|
/* Check manufacturer and driver name */
|
||||||
|
if ( ! manufacturer )
|
||||||
|
return 0;
|
||||||
|
if ( ! name )
|
||||||
|
return 0;
|
||||||
|
if ( strcmp ( manufacturer, vbox ) != 0 )
|
||||||
|
return 0;
|
||||||
|
if ( memcmp ( name, e1knet, sizeof ( e1knet ) ) != 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/** Driver vetoes */
|
/** Driver vetoes */
|
||||||
static struct efi_veto efi_vetoes[] = {
|
static struct efi_veto efi_vetoes[] = {
|
||||||
{
|
{
|
||||||
@@ -480,6 +595,10 @@ static struct efi_veto efi_vetoes[] = {
|
|||||||
.name = "VMware UefiPxeBc",
|
.name = "VMware UefiPxeBc",
|
||||||
.veto = efi_veto_vmware_uefipxebc,
|
.veto = efi_veto_vmware_uefipxebc,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "VirtualBox E1kNetDxe",
|
||||||
|
.veto = efi_veto_vbox_e1knet,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,29 +606,19 @@ static struct efi_veto efi_vetoes[] = {
|
|||||||
*
|
*
|
||||||
* @v driver Driver binding handle
|
* @v driver Driver binding handle
|
||||||
* @v manufacturer Manufacturer name, if present
|
* @v manufacturer Manufacturer name, if present
|
||||||
* @ret veto Driver veto, or NULL
|
* @ret veto Driver veto to fill in
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
||||||
struct efi_veto **veto ) {
|
struct efi_veto **veto ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
union {
|
|
||||||
EFI_DRIVER_BINDING_PROTOCOL *binding;
|
|
||||||
void *interface;
|
|
||||||
} binding;
|
|
||||||
union {
|
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *loaded;
|
|
||||||
void *interface;
|
|
||||||
} loaded;
|
|
||||||
union {
|
union {
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *wtf;
|
EFI_COMPONENT_NAME_PROTOCOL *wtf;
|
||||||
void *interface;
|
void *interface;
|
||||||
} wtf;
|
} wtf;
|
||||||
CHAR16 *name;
|
CHAR16 *name;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
EFI_HANDLE image;
|
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
|
||||||
|
|
||||||
DBGC2 ( &efi_vetoes, "EFIVETO checking %s\n",
|
DBGC2 ( &efi_vetoes, "EFIVETO checking %s\n",
|
||||||
efi_handle_name ( driver ) );
|
efi_handle_name ( driver ) );
|
||||||
@@ -517,32 +626,6 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||||||
/* Mark as not vetoed */
|
/* Mark as not vetoed */
|
||||||
*veto = NULL;
|
*veto = NULL;
|
||||||
|
|
||||||
/* Open driver binding protocol */
|
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
|
||||||
driver, &efi_driver_binding_protocol_guid,
|
|
||||||
&binding.interface, efi_image_handle, driver,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
|
||||||
rc = -EEFI ( efirc );
|
|
||||||
DBGC ( driver, "EFIVETO %s could not open driver binding "
|
|
||||||
"protocol: %s\n", efi_handle_name ( driver ),
|
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_binding;
|
|
||||||
}
|
|
||||||
image = binding.binding->ImageHandle;
|
|
||||||
|
|
||||||
/* Open loaded image protocol */
|
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
|
||||||
image, &efi_loaded_image_protocol_guid,
|
|
||||||
&loaded.interface, efi_image_handle, image,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
|
|
||||||
rc = -EEFI ( efirc );
|
|
||||||
DBGC ( driver, "EFIVETO %s could not open",
|
|
||||||
efi_handle_name ( driver ) );
|
|
||||||
DBGC ( driver, " %s loaded image protocol: %s\n",
|
|
||||||
efi_handle_name ( image ), strerror ( rc ) );
|
|
||||||
goto err_loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open component name protocol, if present*/
|
/* Open component name protocol, if present*/
|
||||||
if ( ( efirc = bs->OpenProtocol (
|
if ( ( efirc = bs->OpenProtocol (
|
||||||
driver, &efi_component_name_protocol_guid,
|
driver, &efi_component_name_protocol_guid,
|
||||||
@@ -565,28 +648,25 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||||||
/* Check vetoes */
|
/* Check vetoes */
|
||||||
for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
|
for ( i = 0 ; i < ( sizeof ( efi_vetoes ) /
|
||||||
sizeof ( efi_vetoes[0] ) ) ; i++ ) {
|
sizeof ( efi_vetoes[0] ) ) ; i++ ) {
|
||||||
if ( efi_vetoes[i].veto ( binding.binding, loaded.loaded,
|
|
||||||
wtf.wtf, manufacturer, name ) ) {
|
|
||||||
*veto = &efi_vetoes[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success */
|
/* Check if this veto applies */
|
||||||
rc = 0;
|
if ( ! efi_vetoes[i].veto ( manufacturer, name ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
|
||||||
|
efi_handle_name ( driver ), efi_vetoes[i].name );
|
||||||
|
*veto = &efi_vetoes[i];
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Close protocols */
|
/* Close protocols */
|
||||||
if ( wtf.wtf ) {
|
if ( wtf.wtf ) {
|
||||||
bs->CloseProtocol ( driver, &efi_component_name_protocol_guid,
|
bs->CloseProtocol ( driver, &efi_component_name_protocol_guid,
|
||||||
efi_image_handle, driver );
|
efi_image_handle, driver );
|
||||||
}
|
}
|
||||||
bs->CloseProtocol ( image, &efi_loaded_image_protocol_guid,
|
|
||||||
efi_image_handle, image );
|
return 0;
|
||||||
err_loaded:
|
|
||||||
bs->CloseProtocol ( driver, &efi_driver_binding_protocol_guid,
|
|
||||||
efi_image_handle, driver );
|
|
||||||
err_binding:
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -596,9 +676,10 @@ static int efi_veto_find ( EFI_HANDLE driver, const char *manufacturer,
|
|||||||
void efi_veto ( void ) {
|
void efi_veto ( void ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
struct efi_veto *veto;
|
struct efi_veto *veto;
|
||||||
EFI_HANDLE *drivers;
|
EFI_HANDLE *targets;
|
||||||
EFI_HANDLE driver;
|
EFI_HANDLE driver;
|
||||||
UINTN num_drivers;
|
EFI_HANDLE image;
|
||||||
|
UINTN count;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *manufacturer;
|
char *manufacturer;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
@@ -607,7 +688,7 @@ void efi_veto ( void ) {
|
|||||||
/* Locate all driver binding protocol handles */
|
/* Locate all driver binding protocol handles */
|
||||||
if ( ( efirc = bs->LocateHandleBuffer (
|
if ( ( efirc = bs->LocateHandleBuffer (
|
||||||
ByProtocol, &efi_driver_binding_protocol_guid,
|
ByProtocol, &efi_driver_binding_protocol_guid,
|
||||||
NULL, &num_drivers, &drivers ) ) != 0 ) {
|
NULL, &count, &targets ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
|
DBGC ( &efi_vetoes, "EFIVETO could not list all drivers: "
|
||||||
"%s\n", strerror ( rc ) );
|
"%s\n", strerror ( rc ) );
|
||||||
@@ -617,10 +698,16 @@ void efi_veto ( void ) {
|
|||||||
/* Get manufacturer name */
|
/* Get manufacturer name */
|
||||||
fetch_string_setting_copy ( NULL, &manufacturer_setting,
|
fetch_string_setting_copy ( NULL, &manufacturer_setting,
|
||||||
&manufacturer );
|
&manufacturer );
|
||||||
|
DBGC ( &efi_vetoes, "EFIVETO manufacturer is \"%s\"\n", manufacturer );
|
||||||
|
|
||||||
/* Unload any vetoed drivers */
|
/* Identify any vetoed drivers and veto the driver handles */
|
||||||
for ( i = 0 ; i < num_drivers ; i++ ) {
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
driver = drivers[i];
|
|
||||||
|
/* Consume driver handle from target list */
|
||||||
|
driver = targets[ count - i - 1 ];
|
||||||
|
targets[ count - i - 1 ] = NULL;
|
||||||
|
|
||||||
|
/* Check if this driver is vetoed */
|
||||||
if ( ( rc = efi_veto_find ( driver, manufacturer,
|
if ( ( rc = efi_veto_find ( driver, manufacturer,
|
||||||
&veto ) ) != 0 ) {
|
&veto ) ) != 0 ) {
|
||||||
DBGC ( driver, "EFIVETO %s could not determine "
|
DBGC ( driver, "EFIVETO %s could not determine "
|
||||||
@@ -630,17 +717,31 @@ void efi_veto ( void ) {
|
|||||||
}
|
}
|
||||||
if ( ! veto )
|
if ( ! veto )
|
||||||
continue;
|
continue;
|
||||||
DBGC ( driver, "EFIVETO %s is vetoed (%s)\n",
|
|
||||||
efi_handle_name ( driver ), veto->name );
|
/* Veto driver handle */
|
||||||
if ( ( rc = efi_veto_driver ( driver ) ) != 0 ) {
|
if ( ( rc = efi_veto_driver ( driver, &image ) ) != 0 )
|
||||||
DBGC ( driver, "EFIVETO %s could not veto: %s\n",
|
continue;
|
||||||
efi_handle_name ( driver ), strerror ( rc ) );
|
|
||||||
}
|
/* Record image handle (if still present) as a target */
|
||||||
|
targets[ count - i - 1 ] = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Veto any remaining image handles */
|
||||||
|
for ( i = 0 ; i < count ; i++ ) {
|
||||||
|
|
||||||
|
/* Consume image handle from target list */
|
||||||
|
image = targets[ count - i - 1 ];
|
||||||
|
if ( ! image )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Veto image handle */
|
||||||
|
if ( ( rc = efi_veto_image ( image ) ) != 0 )
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free manufacturer name */
|
/* Free manufacturer name */
|
||||||
free ( manufacturer );
|
free ( manufacturer );
|
||||||
|
|
||||||
/* Free handle list */
|
/* Free handle list */
|
||||||
bs->FreePool ( drivers );
|
bs->FreePool ( targets );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user