Add keyboard layouts support.
* Makefile.util.def (grub-mklayout): New file. (grub-kbdcomp): New script. * grub-core/Makefile.am (KERNEL_HEADER_FILES) [COND_mips_yeeloong]: Add keyboard_layouts.h. * grub-core/Makefile.core.def (kernel): Add commands/keylayouts.c and commands/boot.c on yeeloong. (keylayouts): New module. * grub-core/bus/usb/ohci.c * grub-core/bus/usb/uhci.c * grub-core/bus/usb/usbhub.c (rescan): New variable. (grub_usb_add_hub): Poll interrupt pipe for device handling. (attach_root_port): Likewise. (poll_nonroot_hub): Likewise. (grub_usb_poll_devices): Likewise. (detach_device): Close transfer. * grub-core/bus/usb/usbtrans.c (grub_usb_execute_and_wait_transfer): New function. (grub_usb_bulk_setup_readwrite): Likewise. (grub_usb_bulk_finish_readwrite): Likewise. * grub-core/commands/keylayouts.c: New file. * grub-core/commands/keystatus.c (grub_getkeystatus): New function. * grub-core/commands/menuentry.c (hotkey_aliases): All several new aliases. * grub-core/term/at_keyboard.c: Restructured to use keylayouts and support scancode 2. * grub-core/term/usb_keyboard.c: Restructured to use keylayouts. * include/grub/keyboard_layouts.h: New file. * util/grub-mklayout.c: New file. * util/grub-kbdcomp.in: Likewise. Also-By: Aleš Nesrsta <starous@volny.cz> Also-By: Vladimir Serbinenko <phcoder@gmail.com>
This commit is contained in:
commit
1a9130dd3f
41 changed files with 3067 additions and 1459 deletions
|
@ -19,36 +19,20 @@
|
|||
#ifndef GRUB_AT_KEYBOARD_HEADER
|
||||
#define GRUB_AT_KEYBOARD_HEADER 1
|
||||
|
||||
#define SHIFT_L 0x2a
|
||||
#define SHIFT_R 0x36
|
||||
#define CTRL 0x1d
|
||||
#define ALT 0x38
|
||||
#define CAPS_LOCK 0x3a
|
||||
#define NUM_LOCK 0x45
|
||||
#define SCROLL_LOCK 0x46
|
||||
|
||||
/* Used for sending commands to the controller. */
|
||||
#define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02)
|
||||
#define KEYBOARD_COMMAND_READ 0x20
|
||||
#define KEYBOARD_COMMAND_WRITE 0x60
|
||||
#define KEYBOARD_COMMAND_REBOOT 0xfe
|
||||
|
||||
#define KEYBOARD_SCANCODE_SET1 0x40
|
||||
#define KEYBOARD_AT_TRANSLATE 0x40
|
||||
|
||||
#define GRUB_AT_ACK 0xfa
|
||||
#define GRUB_AT_NACK 0xfe
|
||||
#define GRUB_AT_TRIES 5
|
||||
|
||||
#define KEYBOARD_ISMAKE(x) !((x) & 0x80)
|
||||
#define KEYBOARD_ISREADY(x) ((x) & 0x01)
|
||||
#define KEYBOARD_SCANCODE(x) ((x) & 0x7f)
|
||||
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
#define OLPC_UP GRUB_TERM_UP
|
||||
#define OLPC_DOWN GRUB_TERM_DOWN
|
||||
#define OLPC_LEFT GRUB_TERM_LEFT
|
||||
#define OLPC_RIGHT GRUB_TERM_RIGHT
|
||||
#else
|
||||
#define OLPC_UP '\0'
|
||||
#define OLPC_DOWN '\0'
|
||||
#define OLPC_LEFT '\0'
|
||||
#define OLPC_RIGHT '\0'
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,19 +19,6 @@
|
|||
#ifndef GRUB_CONSOLE_MACHINE_HEADER
|
||||
#define GRUB_CONSOLE_MACHINE_HEADER 1
|
||||
|
||||
/* Define scan codes. */
|
||||
#define GRUB_CONSOLE_KEY_LEFT 0x4B00
|
||||
#define GRUB_CONSOLE_KEY_RIGHT 0x4D00
|
||||
#define GRUB_CONSOLE_KEY_UP 0x4800
|
||||
#define GRUB_CONSOLE_KEY_DOWN 0x5000
|
||||
#define GRUB_CONSOLE_KEY_IC 0x5200
|
||||
#define GRUB_CONSOLE_KEY_DC 0x5300
|
||||
#define GRUB_CONSOLE_KEY_BACKSPACE 0x0008
|
||||
#define GRUB_CONSOLE_KEY_HOME 0x4700
|
||||
#define GRUB_CONSOLE_KEY_END 0x4F00
|
||||
#define GRUB_CONSOLE_KEY_NPAGE 0x5100
|
||||
#define GRUB_CONSOLE_KEY_PPAGE 0x4900
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
#include <grub/types.h>
|
||||
|
@ -40,7 +27,6 @@
|
|||
#include <grub/i386/vga_common.h>
|
||||
|
||||
/* These are global to share code between C and asm. */
|
||||
int grub_console_checkkey (struct grub_term_input *term);
|
||||
int grub_console_getkey (struct grub_term_input *term);
|
||||
grub_uint16_t grub_console_getxy (struct grub_term_output *term);
|
||||
void grub_console_gotoxy (struct grub_term_output *term,
|
||||
|
|
142
include/grub/keyboard_layouts.h
Normal file
142
include/grub/keyboard_layouts.h
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_KEYBOARD_LAYOUTS_H
|
||||
#define GRUB_KEYBOARD_LAYOUTS_H 1
|
||||
|
||||
#define GRUB_KEYBOARD_LAYOUTS_FILEMAGIC "GRUBLAYO"
|
||||
#define GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE (sizeof(GRUB_KEYBOARD_LAYOUTS_FILEMAGIC) - 1)
|
||||
#define GRUB_KEYBOARD_LAYOUTS_VERSION 8
|
||||
|
||||
#define GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE 128
|
||||
|
||||
struct grub_keyboard_layout
|
||||
{
|
||||
grub_uint32_t keyboard_map[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
|
||||
grub_uint32_t keyboard_map_shift[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
|
||||
grub_uint32_t keyboard_map_l3[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
|
||||
grub_uint32_t keyboard_map_shift_l3[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
|
||||
};
|
||||
|
||||
typedef enum grub_keyboard_key
|
||||
{
|
||||
GRUB_KEYBOARD_KEY_A = 0x04,
|
||||
GRUB_KEYBOARD_KEY_B = 0x05,
|
||||
GRUB_KEYBOARD_KEY_C = 0x06,
|
||||
GRUB_KEYBOARD_KEY_D = 0x07,
|
||||
GRUB_KEYBOARD_KEY_E = 0x08,
|
||||
GRUB_KEYBOARD_KEY_F = 0x09,
|
||||
GRUB_KEYBOARD_KEY_G = 0x0a,
|
||||
GRUB_KEYBOARD_KEY_H = 0x0b,
|
||||
GRUB_KEYBOARD_KEY_I = 0x0c,
|
||||
GRUB_KEYBOARD_KEY_J = 0x0d,
|
||||
GRUB_KEYBOARD_KEY_K = 0x0e,
|
||||
GRUB_KEYBOARD_KEY_L = 0x0f,
|
||||
GRUB_KEYBOARD_KEY_M = 0x10,
|
||||
GRUB_KEYBOARD_KEY_N = 0x11,
|
||||
GRUB_KEYBOARD_KEY_O = 0x12,
|
||||
GRUB_KEYBOARD_KEY_P = 0x13,
|
||||
GRUB_KEYBOARD_KEY_Q = 0x14,
|
||||
GRUB_KEYBOARD_KEY_R = 0x15,
|
||||
GRUB_KEYBOARD_KEY_S = 0x16,
|
||||
GRUB_KEYBOARD_KEY_T = 0x17,
|
||||
GRUB_KEYBOARD_KEY_U = 0x18,
|
||||
GRUB_KEYBOARD_KEY_V = 0x19,
|
||||
GRUB_KEYBOARD_KEY_W = 0x1a,
|
||||
GRUB_KEYBOARD_KEY_X = 0x1b,
|
||||
GRUB_KEYBOARD_KEY_Y = 0x1c,
|
||||
GRUB_KEYBOARD_KEY_Z = 0x1d,
|
||||
GRUB_KEYBOARD_KEY_1 = 0x1e,
|
||||
GRUB_KEYBOARD_KEY_2 = 0x1f,
|
||||
GRUB_KEYBOARD_KEY_3 = 0x20,
|
||||
GRUB_KEYBOARD_KEY_4 = 0x21,
|
||||
GRUB_KEYBOARD_KEY_5 = 0x22,
|
||||
GRUB_KEYBOARD_KEY_6 = 0x23,
|
||||
GRUB_KEYBOARD_KEY_7 = 0x24,
|
||||
GRUB_KEYBOARD_KEY_8 = 0x25,
|
||||
GRUB_KEYBOARD_KEY_9 = 0x26,
|
||||
GRUB_KEYBOARD_KEY_0 = 0x27,
|
||||
GRUB_KEYBOARD_KEY_ENTER = 0x28,
|
||||
GRUB_KEYBOARD_KEY_ESCAPE = 0x29,
|
||||
GRUB_KEYBOARD_KEY_BACKSPACE = 0x2a,
|
||||
GRUB_KEYBOARD_KEY_TAB = 0x2b,
|
||||
GRUB_KEYBOARD_KEY_SPACE = 0x2c,
|
||||
GRUB_KEYBOARD_KEY_DASH = 0x2d,
|
||||
GRUB_KEYBOARD_KEY_EQUAL = 0x2e,
|
||||
GRUB_KEYBOARD_KEY_LBRACKET = 0x2f,
|
||||
GRUB_KEYBOARD_KEY_RBRACKET = 0x30,
|
||||
GRUB_KEYBOARD_KEY_BACKSLASH = 0x32,
|
||||
GRUB_KEYBOARD_KEY_SEMICOLON = 0x33,
|
||||
GRUB_KEYBOARD_KEY_DQUOTE = 0x34,
|
||||
GRUB_KEYBOARD_KEY_RQUOTE = 0x35,
|
||||
GRUB_KEYBOARD_KEY_COMMA = 0x36,
|
||||
GRUB_KEYBOARD_KEY_DOT = 0x37,
|
||||
GRUB_KEYBOARD_KEY_SLASH = 0x38,
|
||||
GRUB_KEYBOARD_KEY_CAPS_LOCK = 0x39,
|
||||
GRUB_KEYBOARD_KEY_F1 = 0x3a,
|
||||
GRUB_KEYBOARD_KEY_F2 = 0x3b,
|
||||
GRUB_KEYBOARD_KEY_F3 = 0x3c,
|
||||
GRUB_KEYBOARD_KEY_F4 = 0x3d,
|
||||
GRUB_KEYBOARD_KEY_F5 = 0x3e,
|
||||
GRUB_KEYBOARD_KEY_F6 = 0x3f,
|
||||
GRUB_KEYBOARD_KEY_F7 = 0x40,
|
||||
GRUB_KEYBOARD_KEY_F8 = 0x41,
|
||||
GRUB_KEYBOARD_KEY_F9 = 0x42,
|
||||
GRUB_KEYBOARD_KEY_F10 = 0x43,
|
||||
GRUB_KEYBOARD_KEY_F11 = 0x44,
|
||||
GRUB_KEYBOARD_KEY_F12 = 0x45,
|
||||
GRUB_KEYBOARD_KEY_SCROLL_LOCK = 0x47,
|
||||
GRUB_KEYBOARD_KEY_INSERT = 0x49,
|
||||
GRUB_KEYBOARD_KEY_HOME = 0x4a,
|
||||
GRUB_KEYBOARD_KEY_PPAGE = 0x4b,
|
||||
GRUB_KEYBOARD_KEY_DELETE = 0x4c,
|
||||
GRUB_KEYBOARD_KEY_END = 0x4d,
|
||||
GRUB_KEYBOARD_KEY_NPAGE = 0x4e,
|
||||
GRUB_KEYBOARD_KEY_RIGHT = 0x4f,
|
||||
GRUB_KEYBOARD_KEY_LEFT = 0x50,
|
||||
GRUB_KEYBOARD_KEY_DOWN = 0x51,
|
||||
GRUB_KEYBOARD_KEY_UP = 0x52,
|
||||
GRUB_KEYBOARD_KEY_NUM_LOCK = 0x53,
|
||||
GRUB_KEYBOARD_KEY_NUMSLASH = 0x54,
|
||||
GRUB_KEYBOARD_KEY_NUMMUL = 0x55,
|
||||
GRUB_KEYBOARD_KEY_NUMMINUS = 0x56,
|
||||
GRUB_KEYBOARD_KEY_NUMPLUS = 0x57,
|
||||
GRUB_KEYBOARD_KEY_NUMENTER = 0x58,
|
||||
GRUB_KEYBOARD_KEY_NUM1 = 0x59,
|
||||
GRUB_KEYBOARD_KEY_NUM2 = 0x5a,
|
||||
GRUB_KEYBOARD_KEY_NUM3 = 0x5b,
|
||||
GRUB_KEYBOARD_KEY_NUM4 = 0x5c,
|
||||
GRUB_KEYBOARD_KEY_NUM5 = 0x5d,
|
||||
GRUB_KEYBOARD_KEY_NUM6 = 0x5e,
|
||||
GRUB_KEYBOARD_KEY_NUM7 = 0x5f,
|
||||
GRUB_KEYBOARD_KEY_NUM8 = 0x60,
|
||||
GRUB_KEYBOARD_KEY_NUM9 = 0x61,
|
||||
GRUB_KEYBOARD_KEY_NUM0 = 0x62,
|
||||
GRUB_KEYBOARD_KEY_NUMDOT = 0x63,
|
||||
GRUB_KEYBOARD_KEY_102ND = 0x64,
|
||||
GRUB_KEYBOARD_KEY_LEFT_CTRL = 0xe0,
|
||||
GRUB_KEYBOARD_KEY_LEFT_SHIFT = 0xe1,
|
||||
GRUB_KEYBOARD_KEY_LEFT_ALT = 0xe2,
|
||||
GRUB_KEYBOARD_KEY_RIGHT_CTRL = 0xe4,
|
||||
GRUB_KEYBOARD_KEY_RIGHT_SHIFT = 0xe5,
|
||||
GRUB_KEYBOARD_KEY_RIGHT_ALT = 0xe6,
|
||||
} grub_keyboard_key_t;
|
||||
|
||||
unsigned EXPORT_FUNC(grub_term_map_key) (grub_keyboard_key_t code, int status);
|
||||
|
||||
#endif /* GRUB_KEYBOARD_LAYOUTS */
|
|
@ -26,16 +26,16 @@
|
|||
#include <grub/types.h>
|
||||
|
||||
/* Check if a loader is loaded. */
|
||||
int grub_loader_is_loaded (void);
|
||||
int EXPORT_FUNC (grub_loader_is_loaded) (void);
|
||||
|
||||
/* Set loader functions. NORETURN must be set to true, if BOOT won't return
|
||||
to the original state. */
|
||||
void grub_loader_set (grub_err_t (*boot) (void),
|
||||
grub_err_t (*unload) (void),
|
||||
int noreturn);
|
||||
void EXPORT_FUNC (grub_loader_set) (grub_err_t (*boot) (void),
|
||||
grub_err_t (*unload) (void),
|
||||
int noreturn);
|
||||
|
||||
/* Unset current loader, if any. */
|
||||
void grub_loader_unset (void);
|
||||
void EXPORT_FUNC (grub_loader_unset) (void);
|
||||
|
||||
/* Call the boot hook in current loader. This may or may not return,
|
||||
depending on the setting by grub_loader_set. */
|
||||
|
@ -56,7 +56,7 @@ typedef enum {
|
|||
} grub_loader_preboot_hook_prio_t;
|
||||
|
||||
/* Register a preboot hook. */
|
||||
void *grub_loader_register_preboot_hook (grub_err_t (*preboot_func) (int noret),
|
||||
void *EXPORT_FUNC(grub_loader_register_preboot_hook) (grub_err_t (*preboot_func) (int noret),
|
||||
grub_err_t (*preboot_rest_func) (void),
|
||||
grub_loader_preboot_hook_prio_t prio);
|
||||
|
||||
|
|
|
@ -19,19 +19,45 @@
|
|||
#ifndef GRUB_TERM_HEADER
|
||||
#define GRUB_TERM_HEADER 1
|
||||
|
||||
#define GRUB_TERM_NO_KEY 0
|
||||
|
||||
/* Internal codes used by GRUB to represent terminal input. */
|
||||
#define GRUB_TERM_LEFT 2
|
||||
#define GRUB_TERM_RIGHT 6
|
||||
#define GRUB_TERM_UP 16
|
||||
#define GRUB_TERM_DOWN 14
|
||||
#define GRUB_TERM_HOME 1
|
||||
#define GRUB_TERM_END 5
|
||||
#define GRUB_TERM_DC 4
|
||||
#define GRUB_TERM_PPAGE 7
|
||||
#define GRUB_TERM_NPAGE 3
|
||||
/* Only for keys otherwise not having shifted modification. */
|
||||
#define GRUB_TERM_SHIFT 0x01000000
|
||||
#define GRUB_TERM_CTRL 0x02000000
|
||||
#define GRUB_TERM_ALT 0x04000000
|
||||
|
||||
/* Keys without associated character. */
|
||||
#define GRUB_TERM_EXTENDED 0x00800000
|
||||
#define GRUB_TERM_KEY_MASK 0x00ffffff
|
||||
|
||||
#define GRUB_TERM_KEY_LEFT (GRUB_TERM_EXTENDED | 0x4b)
|
||||
#define GRUB_TERM_KEY_RIGHT (GRUB_TERM_EXTENDED | 0x4d)
|
||||
#define GRUB_TERM_KEY_UP (GRUB_TERM_EXTENDED | 0x48)
|
||||
#define GRUB_TERM_KEY_DOWN (GRUB_TERM_EXTENDED | 0x50)
|
||||
#define GRUB_TERM_KEY_HOME (GRUB_TERM_EXTENDED | 0x47)
|
||||
#define GRUB_TERM_KEY_END (GRUB_TERM_EXTENDED | 0x4f)
|
||||
#define GRUB_TERM_KEY_DC (GRUB_TERM_EXTENDED | 0x53)
|
||||
#define GRUB_TERM_KEY_PPAGE (GRUB_TERM_EXTENDED | 0x49)
|
||||
#define GRUB_TERM_KEY_NPAGE (GRUB_TERM_EXTENDED | 0x51)
|
||||
#define GRUB_TERM_KEY_F1 (GRUB_TERM_EXTENDED | 0x3b)
|
||||
#define GRUB_TERM_KEY_F2 (GRUB_TERM_EXTENDED | 0x3c)
|
||||
#define GRUB_TERM_KEY_F3 (GRUB_TERM_EXTENDED | 0x3d)
|
||||
#define GRUB_TERM_KEY_F4 (GRUB_TERM_EXTENDED | 0x3e)
|
||||
#define GRUB_TERM_KEY_F5 (GRUB_TERM_EXTENDED | 0x3f)
|
||||
#define GRUB_TERM_KEY_F6 (GRUB_TERM_EXTENDED | 0x40)
|
||||
#define GRUB_TERM_KEY_F7 (GRUB_TERM_EXTENDED | 0x41)
|
||||
#define GRUB_TERM_KEY_F8 (GRUB_TERM_EXTENDED | 0x42)
|
||||
#define GRUB_TERM_KEY_F9 (GRUB_TERM_EXTENDED | 0x43)
|
||||
#define GRUB_TERM_KEY_F10 (GRUB_TERM_EXTENDED | 0x44)
|
||||
#define GRUB_TERM_KEY_F11 (GRUB_TERM_EXTENDED | 0x57)
|
||||
#define GRUB_TERM_KEY_F12 (GRUB_TERM_EXTENDED | 0x58)
|
||||
#define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 0x52)
|
||||
#define GRUB_TERM_KEY_CENTER (GRUB_TERM_EXTENDED | 0x4c)
|
||||
|
||||
#define GRUB_TERM_ESC '\e'
|
||||
#define GRUB_TERM_TAB '\t'
|
||||
#define GRUB_TERM_BACKSPACE 8
|
||||
#define GRUB_TERM_BACKSPACE '\b'
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
|
@ -86,9 +112,15 @@ grub_term_color_state;
|
|||
|
||||
|
||||
/* Bitmasks for modifier keys returned by grub_getkeystatus. */
|
||||
#define GRUB_TERM_STATUS_SHIFT (1 << 0)
|
||||
#define GRUB_TERM_STATUS_CTRL (1 << 1)
|
||||
#define GRUB_TERM_STATUS_ALT (1 << 2)
|
||||
#define GRUB_TERM_STATUS_RSHIFT (1 << 0)
|
||||
#define GRUB_TERM_STATUS_LSHIFT (1 << 1)
|
||||
#define GRUB_TERM_STATUS_RCTRL (1 << 2)
|
||||
#define GRUB_TERM_STATUS_RALT (1 << 3)
|
||||
#define GRUB_TERM_STATUS_SCROLL (1 << 4)
|
||||
#define GRUB_TERM_STATUS_NUM (1 << 5)
|
||||
#define GRUB_TERM_STATUS_CAPS (1 << 6)
|
||||
#define GRUB_TERM_STATUS_LCTRL (1 << 8)
|
||||
#define GRUB_TERM_STATUS_LALT (1 << 9)
|
||||
|
||||
/* Menu-related geometrical constants. */
|
||||
|
||||
|
@ -128,10 +160,7 @@ struct grub_term_input
|
|||
/* Clean up the terminal. */
|
||||
grub_err_t (*fini) (struct grub_term_input *term);
|
||||
|
||||
/* Check if any input character is available. */
|
||||
int (*checkkey) (struct grub_term_input *term);
|
||||
|
||||
/* Get a character. */
|
||||
/* Get a character if any input character is available. Otherwise return -1 */
|
||||
int (*getkey) (struct grub_term_input *term);
|
||||
|
||||
/* Get keyboard modifier status. */
|
||||
|
@ -279,7 +308,6 @@ grub_term_unregister_output (grub_term_output_t term)
|
|||
void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
|
||||
int EXPORT_FUNC(grub_getkey) (void);
|
||||
int EXPORT_FUNC(grub_checkkey) (void);
|
||||
int EXPORT_FUNC(grub_getkeystatus) (void);
|
||||
void grub_cls (void);
|
||||
void EXPORT_FUNC(grub_refresh) (void);
|
||||
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
||||
|
@ -461,8 +489,8 @@ grub_print_spaces (struct grub_term_output *term, int number_spaces)
|
|||
|
||||
extern void (*EXPORT_VAR (grub_term_poll_usb)) (void);
|
||||
|
||||
/* For convenience. */
|
||||
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
|
||||
#define GRUB_TERM_REPEAT_PRE_INTERVAL 400
|
||||
#define GRUB_TERM_REPEAT_INTERVAL 50
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term,
|
|||
const grub_term_color_state state);
|
||||
|
||||
|
||||
int EXPORT_FUNC (grub_terminfo_checkkey) (struct grub_term_input *term);
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_input_init) (struct grub_term_input *term);
|
||||
int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term);
|
||||
void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term,
|
||||
|
|
|
@ -30,6 +30,7 @@ typedef struct grub_usb_controller_dev *grub_usb_controller_dev_t;
|
|||
typedef enum
|
||||
{
|
||||
GRUB_USB_ERR_NONE,
|
||||
GRUB_USB_ERR_WAIT,
|
||||
GRUB_USB_ERR_INTERNAL,
|
||||
GRUB_USB_ERR_STALL,
|
||||
GRUB_USB_ERR_DATA,
|
||||
|
@ -48,14 +49,6 @@ typedef enum
|
|||
GRUB_USB_SPEED_HIGH
|
||||
} grub_usb_speed_t;
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT = 0x21,
|
||||
GRUB_USB_REQTYPE_VENDOR_OUT = 0x40,
|
||||
GRUB_USB_REQTYPE_CLASS_INTERFACE_IN = 0xa1,
|
||||
GRUB_USB_REQTYPE_VENDOR_IN = 0xc0
|
||||
};
|
||||
|
||||
/* Call HOOK with each device, until HOOK returns non-zero. */
|
||||
int grub_usb_iterate (int (*hook) (grub_usb_device_t dev));
|
||||
|
||||
|
@ -97,6 +90,7 @@ grub_usb_err_t
|
|||
grub_usb_root_hub (grub_usb_controller_t controller);
|
||||
|
||||
|
||||
|
||||
/* XXX: All handled by libusb for now. */
|
||||
struct grub_usb_controller_dev
|
||||
{
|
||||
|
@ -105,9 +99,15 @@ struct grub_usb_controller_dev
|
|||
|
||||
int (*iterate) (int (*hook) (grub_usb_controller_t dev));
|
||||
|
||||
grub_usb_err_t (*transfer) (grub_usb_controller_t dev,
|
||||
grub_usb_transfer_t transfer,
|
||||
int timeout, grub_size_t *actual);
|
||||
grub_usb_err_t (*setup_transfer) (grub_usb_controller_t dev,
|
||||
grub_usb_transfer_t transfer);
|
||||
|
||||
grub_usb_err_t (*check_transfer) (grub_usb_controller_t dev,
|
||||
grub_usb_transfer_t transfer,
|
||||
grub_size_t *actual);
|
||||
|
||||
grub_usb_err_t (*cancel_transfer) (grub_usb_controller_t dev,
|
||||
grub_usb_transfer_t transfer);
|
||||
|
||||
int (*hubports) (grub_usb_controller_t dev);
|
||||
|
||||
|
@ -116,6 +116,9 @@ struct grub_usb_controller_dev
|
|||
|
||||
grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
|
||||
|
||||
/* Per controller flag - port reset pending, don't do another reset */
|
||||
grub_uint64_t pending_reset;
|
||||
|
||||
/* The next host controller. */
|
||||
struct grub_usb_controller_dev *next;
|
||||
};
|
||||
|
@ -181,11 +184,19 @@ struct grub_usb_device
|
|||
/* Used by libusb wrapper. Schedulded for removal. */
|
||||
void *data;
|
||||
|
||||
/* Hub information. */
|
||||
|
||||
/* Array of children for a hub. */
|
||||
grub_usb_device_t *children;
|
||||
|
||||
/* Number of hub ports. */
|
||||
unsigned nports;
|
||||
|
||||
grub_usb_transfer_t hub_transfer;
|
||||
|
||||
grub_uint32_t statuschange;
|
||||
|
||||
struct grub_usb_desc_endp *hub_endpoint;
|
||||
};
|
||||
|
||||
|
||||
|
@ -266,5 +277,12 @@ grub_usb_err_t
|
|||
grub_usb_bulk_read_extended (grub_usb_device_t dev,
|
||||
int endpoint, grub_size_t size, char *data,
|
||||
int timeout, grub_size_t *actual);
|
||||
grub_usb_transfer_t
|
||||
grub_usb_bulk_read_background (grub_usb_device_t dev,
|
||||
int endpoint, grub_size_t size, void *data);
|
||||
grub_usb_err_t
|
||||
grub_usb_check_transfer (grub_usb_transfer_t trans, grub_size_t *actual);
|
||||
void
|
||||
grub_usb_cancel_transfer (grub_usb_transfer_t trans);
|
||||
|
||||
#endif /* GRUB_USB_H */
|
||||
|
|
|
@ -56,51 +56,89 @@ struct grub_usb_transfer
|
|||
|
||||
grub_transaction_type_t type;
|
||||
|
||||
grub_transfer_type_t dir;
|
||||
|
||||
struct grub_usb_device *dev;
|
||||
|
||||
struct grub_usb_transaction *transactions;
|
||||
|
||||
int last_trans;
|
||||
/* Index of last processed transaction in OHCI/UHCI driver. */
|
||||
|
||||
void *controller_data;
|
||||
|
||||
/* Used when finishing transfer to copy data back. */
|
||||
struct grub_pci_dma_chunk *data_chunk;
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_usb_transfer *grub_usb_transfer_t;
|
||||
|
||||
|
||||
#define GRUB_USB_REQTYPE_IN (1 << 7)
|
||||
#define GRUB_USB_REQTYPE_OUT (0 << 7)
|
||||
#define GRUB_USB_REQTYPE_STANDARD (0 << 5)
|
||||
#define GRUB_USB_REQTYPE_CLASS (1 << 5)
|
||||
#define GRUB_USB_REQTYPE_VENDOR (2 << 5)
|
||||
#define GRUB_USB_REQTYPE_TARGET_DEV (0 << 0)
|
||||
#define GRUB_USB_REQTYPE_TARGET_INTERF (1 << 0)
|
||||
#define GRUB_USB_REQTYPE_TARGET_ENDP (2 << 0)
|
||||
#define GRUB_USB_REQTYPE_TARGET_OTHER (3 << 0)
|
||||
|
||||
#define GRUB_USB_REQ_GET_STATUS 0x00
|
||||
#define GRUB_USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define GRUB_USB_REQ_SET_FEATURE 0x03
|
||||
#define GRUB_USB_REQ_SET_ADDRESS 0x05
|
||||
#define GRUB_USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define GRUB_USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define GRUB_USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define GRUB_USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define GRUB_USB_REQ_GET_INTERFACE 0x0A
|
||||
#define GRUB_USB_REQ_SET_INTERFACE 0x0B
|
||||
#define GRUB_USB_REQ_SYNC_FRAME 0x0C
|
||||
enum
|
||||
{
|
||||
GRUB_USB_REQTYPE_TARGET_DEV = (0 << 0),
|
||||
GRUB_USB_REQTYPE_TARGET_INTERF = (1 << 0),
|
||||
GRUB_USB_REQTYPE_TARGET_ENDP = (2 << 0),
|
||||
GRUB_USB_REQTYPE_TARGET_OTHER = (3 << 0),
|
||||
GRUB_USB_REQTYPE_STANDARD = (0 << 5),
|
||||
GRUB_USB_REQTYPE_CLASS = (1 << 5),
|
||||
GRUB_USB_REQTYPE_VENDOR = (2 << 5),
|
||||
GRUB_USB_REQTYPE_OUT = (0 << 7),
|
||||
GRUB_USB_REQTYPE_IN = (1 << 7),
|
||||
GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT = GRUB_USB_REQTYPE_TARGET_INTERF
|
||||
| GRUB_USB_REQTYPE_CLASS | GRUB_USB_REQTYPE_OUT,
|
||||
GRUB_USB_REQTYPE_VENDOR_OUT = GRUB_USB_REQTYPE_VENDOR | GRUB_USB_REQTYPE_OUT,
|
||||
GRUB_USB_REQTYPE_CLASS_INTERFACE_IN = GRUB_USB_REQTYPE_TARGET_INTERF
|
||||
| GRUB_USB_REQTYPE_CLASS | GRUB_USB_REQTYPE_IN,
|
||||
GRUB_USB_REQTYPE_VENDOR_IN = GRUB_USB_REQTYPE_VENDOR | GRUB_USB_REQTYPE_IN
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_USB_REQ_GET_STATUS = 0x00,
|
||||
GRUB_USB_REQ_CLEAR_FEATURE = 0x01,
|
||||
GRUB_USB_REQ_SET_FEATURE = 0x03,
|
||||
GRUB_USB_REQ_SET_ADDRESS = 0x05,
|
||||
GRUB_USB_REQ_GET_DESCRIPTOR = 0x06,
|
||||
GRUB_USB_REQ_SET_DESCRIPTOR = 0x07,
|
||||
GRUB_USB_REQ_GET_CONFIGURATION = 0x08,
|
||||
GRUB_USB_REQ_SET_CONFIGURATION = 0x09,
|
||||
GRUB_USB_REQ_GET_INTERFACE = 0x0A,
|
||||
GRUB_USB_REQ_SET_INTERFACE = 0x0B,
|
||||
GRUB_USB_REQ_SYNC_FRAME = 0x0C
|
||||
};
|
||||
|
||||
#define GRUB_USB_FEATURE_ENDP_HALT 0x00
|
||||
#define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
|
||||
#define GRUB_USB_FEATURE_TEST_MODE 0x02
|
||||
|
||||
#define GRUB_USB_HUB_FEATURE_PORT_RESET 0x04
|
||||
#define GRUB_USB_HUB_FEATURE_PORT_POWER 0x08
|
||||
#define GRUB_USB_HUB_FEATURE_C_CONNECTED 0x10
|
||||
enum
|
||||
{
|
||||
GRUB_USB_HUB_FEATURE_PORT_RESET = 0x04,
|
||||
GRUB_USB_HUB_FEATURE_PORT_POWER = 0x08,
|
||||
GRUB_USB_HUB_FEATURE_C_PORT_CONNECTED = 0x10,
|
||||
GRUB_USB_HUB_FEATURE_C_PORT_ENABLED = 0x11,
|
||||
GRUB_USB_HUB_FEATURE_C_PORT_SUSPEND = 0x12,
|
||||
GRUB_USB_HUB_FEATURE_C_PORT_OVERCURRENT = 0x13,
|
||||
GRUB_USB_HUB_FEATURE_C_PORT_RESET = 0x14
|
||||
};
|
||||
|
||||
#define GRUB_USB_HUB_STATUS_CONNECTED (1 << 0)
|
||||
#define GRUB_USB_HUB_STATUS_LOWSPEED (1 << 9)
|
||||
#define GRUB_USB_HUB_STATUS_HIGHSPEED (1 << 10)
|
||||
#define GRUB_USB_HUB_STATUS_C_CONNECTED (1 << 16)
|
||||
#define GRUB_USB_HUB_STATUS_C_PORT_RESET (1 << 20)
|
||||
enum
|
||||
{
|
||||
GRUB_USB_HUB_STATUS_PORT_CONNECTED = (1 << 0),
|
||||
GRUB_USB_HUB_STATUS_PORT_ENABLED = (1 << 1),
|
||||
GRUB_USB_HUB_STATUS_PORT_SUSPEND = (1 << 2),
|
||||
GRUB_USB_HUB_STATUS_PORT_OVERCURRENT = (1 << 3),
|
||||
GRUB_USB_HUB_STATUS_PORT_POWERED = (1 << 8),
|
||||
GRUB_USB_HUB_STATUS_PORT_LOWSPEED = (1 << 9),
|
||||
GRUB_USB_HUB_STATUS_PORT_HIGHSPEED = (1 << 10),
|
||||
GRUB_USB_HUB_STATUS_C_PORT_CONNECTED = (1 << 16),
|
||||
GRUB_USB_HUB_STATUS_C_PORT_ENABLED = (1 << 17),
|
||||
GRUB_USB_HUB_STATUS_C_PORT_SUSPEND = (1 << 18),
|
||||
GRUB_USB_HUB_STATUS_C_PORT_OVERCURRENT = (1 << 19),
|
||||
GRUB_USB_HUB_STATUS_C_PORT_RESET = (1 << 20)
|
||||
};
|
||||
|
||||
struct grub_usb_packet_setup
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue