merge with mainline
This commit is contained in:
		
						commit
						d84666e6bb
					
				
					 37 changed files with 2533 additions and 641 deletions
				
			
		
							
								
								
									
										73
									
								
								include/grub/ns8250.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								include/grub/ns8250.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,73 @@ | |||
| /* serial.h - serial device interface */ | ||||
| /*
 | ||||
|  *  GRUB  --  GRand Unified Bootloader | ||||
|  *  Copyright (C) 2000,2001,2002,2005,2007  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_NS8250_HEADER | ||||
| #define GRUB_NS8250_HEADER	1 | ||||
| 
 | ||||
| /* Macros.  */ | ||||
| 
 | ||||
| /* The offsets of UART registers.  */ | ||||
| #define UART_TX		0 | ||||
| #define UART_RX		0 | ||||
| #define UART_DLL	0 | ||||
| #define UART_IER	1 | ||||
| #define UART_DLH	1 | ||||
| #define UART_IIR	2 | ||||
| #define UART_FCR	2 | ||||
| #define UART_LCR	3 | ||||
| #define UART_MCR	4 | ||||
| #define UART_LSR	5 | ||||
| #define UART_MSR	6 | ||||
| #define UART_SR		7 | ||||
| 
 | ||||
| /* For LSR bits.  */ | ||||
| #define UART_DATA_READY		0x01 | ||||
| #define UART_EMPTY_TRANSMITTER	0x20 | ||||
| 
 | ||||
| /* The type of parity.  */ | ||||
| #define UART_NO_PARITY		0x00 | ||||
| #define UART_ODD_PARITY		0x08 | ||||
| #define UART_EVEN_PARITY	0x18 | ||||
| 
 | ||||
| /* The type of word length.  */ | ||||
| #define UART_5BITS_WORD	0x00 | ||||
| #define UART_6BITS_WORD	0x01 | ||||
| #define UART_7BITS_WORD	0x02 | ||||
| #define UART_8BITS_WORD	0x03 | ||||
| 
 | ||||
| /* The type of the length of stop bit.  */ | ||||
| #define UART_1_STOP_BIT		0x00 | ||||
| #define UART_2_STOP_BITS	0x04 | ||||
| 
 | ||||
| /* the switch of DLAB.  */ | ||||
| #define UART_DLAB	0x80 | ||||
| 
 | ||||
| /* Enable the FIFO.  */ | ||||
| #define UART_ENABLE_FIFO_TRIGGER14	0xC7 | ||||
| 
 | ||||
| /* Enable the FIFO.  */ | ||||
| #define UART_ENABLE_FIFO_TRIGGER1       0x07 | ||||
| 
 | ||||
| /* Turn on DTR, RTS, and OUT2.  */ | ||||
| #define UART_ENABLE_DTRRTS	0x03 | ||||
| 
 | ||||
| /* Turn on DTR, RTS, and OUT2.  */ | ||||
| #define UART_ENABLE_OUT2	0x08 | ||||
| 
 | ||||
| #endif /* ! GRUB_SERIAL_MACHINE_HEADER */ | ||||
|  | @ -1,7 +1,7 @@ | |||
| /* serial.h - serial device interface */ | ||||
| /*
 | ||||
|  *  GRUB  --  GRand Unified Bootloader | ||||
|  *  Copyright (C) 2000,2001,2002,2005,2007  Free Software Foundation, Inc. | ||||
|  *  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 | ||||
|  | @ -20,54 +20,100 @@ | |||
| #ifndef GRUB_SERIAL_HEADER | ||||
| #define GRUB_SERIAL_HEADER	1 | ||||
| 
 | ||||
| /* Macros.  */ | ||||
| #include <grub/types.h> | ||||
| #include <grub/cpu/io.h> | ||||
| #include <grub/usb.h> | ||||
| #include <grub/list.h> | ||||
| #include <grub/term.h> | ||||
| 
 | ||||
| /* The offsets of UART registers.  */ | ||||
| #define UART_TX		0 | ||||
| #define UART_RX		0 | ||||
| #define UART_DLL	0 | ||||
| #define UART_IER	1 | ||||
| #define UART_DLH	1 | ||||
| #define UART_IIR	2 | ||||
| #define UART_FCR	2 | ||||
| #define UART_LCR	3 | ||||
| #define UART_MCR	4 | ||||
| #define UART_LSR	5 | ||||
| #define UART_MSR	6 | ||||
| #define UART_SR		7 | ||||
| struct grub_serial_port; | ||||
| struct grub_serial_config; | ||||
| 
 | ||||
| /* For LSR bits.  */ | ||||
| #define UART_DATA_READY		0x01 | ||||
| #define UART_EMPTY_TRANSMITTER	0x20 | ||||
| struct grub_serial_driver | ||||
| { | ||||
|   grub_err_t (*configure) (struct grub_serial_port *port, | ||||
| 			   struct grub_serial_config *config); | ||||
|   int (*fetch) (struct grub_serial_port *port); | ||||
|   void (*put) (struct grub_serial_port *port, const int c); | ||||
|   void (*fini) (struct grub_serial_port *port); | ||||
| }; | ||||
| 
 | ||||
| /* The type of parity.  */ | ||||
| #define UART_NO_PARITY		0x00 | ||||
| #define UART_ODD_PARITY		0x08 | ||||
| #define UART_EVEN_PARITY	0x18 | ||||
| typedef enum | ||||
|   { | ||||
|     GRUB_SERIAL_PARITY_NONE, | ||||
|     GRUB_SERIAL_PARITY_ODD, | ||||
|     GRUB_SERIAL_PARITY_EVEN, | ||||
|   } grub_serial_parity_t; | ||||
| 
 | ||||
| /* The type of word length.  */ | ||||
| #define UART_5BITS_WORD	0x00 | ||||
| #define UART_6BITS_WORD	0x01 | ||||
| #define UART_7BITS_WORD	0x02 | ||||
| #define UART_8BITS_WORD	0x03 | ||||
| typedef enum | ||||
|   { | ||||
|     GRUB_SERIAL_STOP_BITS_1, | ||||
|     GRUB_SERIAL_STOP_BITS_2, | ||||
|   } grub_serial_stop_bits_t; | ||||
| 
 | ||||
| /* The type of the length of stop bit.  */ | ||||
| #define UART_1_STOP_BIT		0x00 | ||||
| #define UART_2_STOP_BITS	0x04 | ||||
| struct grub_serial_config | ||||
| { | ||||
|   unsigned speed; | ||||
|   int word_len; | ||||
|   grub_serial_parity_t parity; | ||||
|   grub_serial_stop_bits_t stop_bits; | ||||
| }; | ||||
| 
 | ||||
| /* the switch of DLAB.  */ | ||||
| #define UART_DLAB	0x80 | ||||
| struct grub_serial_port | ||||
| { | ||||
|   struct grub_serial_port *next; | ||||
|   char *name; | ||||
|   struct grub_serial_driver *driver; | ||||
|   struct grub_serial_config config; | ||||
|   int configured; | ||||
|   /* This should be void *data but since serial is useful as an early console
 | ||||
|      when malloc isn't available it's a union. | ||||
|    */ | ||||
|   union | ||||
|   { | ||||
|     grub_port_t port; | ||||
|     struct | ||||
|     { | ||||
|       grub_usb_device_t usbdev; | ||||
|       int configno; | ||||
|       int interfno; | ||||
|       char buf[64]; | ||||
|       int bufstart, bufend; | ||||
|       struct grub_usb_desc_endp *in_endp; | ||||
|       struct grub_usb_desc_endp *out_endp; | ||||
|     }; | ||||
|   }; | ||||
|   grub_term_output_t term_out; | ||||
|   grub_term_input_t term_in; | ||||
| }; | ||||
| 
 | ||||
| /* Enable the FIFO.  */ | ||||
| #define UART_ENABLE_FIFO_TRIGGER14	0xC7 | ||||
| grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port); | ||||
| 
 | ||||
| /* Enable the FIFO.  */ | ||||
| #define UART_ENABLE_FIFO_TRIGGER1       0x07 | ||||
| void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port); | ||||
| 
 | ||||
| /* Turn on DTR, RTS, and OUT2.  */ | ||||
| #define UART_ENABLE_DTRRTS	0x03 | ||||
|   /* Set default settings.  */ | ||||
| static inline grub_err_t | ||||
| grub_serial_config_defaults (struct grub_serial_port *port) | ||||
| { | ||||
|   struct grub_serial_config config = | ||||
|     { | ||||
| #ifdef GRUB_MACHINE_MIPS_YEELOONG | ||||
|       .speed = 115200, | ||||
| #else | ||||
|       .speed = 9600, | ||||
| #endif | ||||
|       .word_len = 8, | ||||
|       .parity = GRUB_SERIAL_PARITY_NONE, | ||||
|       .stop_bits = GRUB_SERIAL_STOP_BITS_1 | ||||
|     }; | ||||
| 
 | ||||
| /* Turn on DTR, RTS, and OUT2.  */ | ||||
| #define UART_ENABLE_OUT2	0x08 | ||||
|   return port->driver->configure (port, &config); | ||||
| } | ||||
| 
 | ||||
| #endif /* ! GRUB_SERIAL_MACHINE_HEADER */ | ||||
| void grub_ns8250_init (void); | ||||
| char *grub_serial_ns8250_add_port (grub_port_t port); | ||||
| extern struct grub_serial_driver grub_ns8250_driver; | ||||
| void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -459,6 +459,7 @@ grub_print_spaces (struct grub_term_output *term, int number_spaces) | |||
|     grub_putcode (' ', term); | ||||
| } | ||||
| 
 | ||||
| extern void (*EXPORT_VAR (grub_term_poll_usb)) (void); | ||||
| 
 | ||||
| /* For convenience.  */ | ||||
| #define GRUB_TERM_ASCII_CHAR(c)	((c) & 0xff) | ||||
|  |  | |||
|  | @ -32,7 +32,7 @@ struct grub_terminfo_input_state | |||
| { | ||||
|   int input_buf[GRUB_TERMINFO_READKEY_MAX_LEN]; | ||||
|   int npending; | ||||
|   int (*readkey) (void); | ||||
|   int (*readkey) (struct grub_term_input *term); | ||||
| }; | ||||
| 
 | ||||
| struct grub_terminfo_output_state | ||||
|  | @ -51,7 +51,7 @@ struct grub_terminfo_output_state | |||
| 
 | ||||
|   unsigned int xpos, ypos; | ||||
| 
 | ||||
|   void (*put) (const int c); | ||||
|   void (*put) (struct grub_term_output *term, const int c); | ||||
| }; | ||||
| 
 | ||||
| void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term, | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ | |||
| #ifndef	GRUB_USB_H | ||||
| #define	GRUB_USB_H	1 | ||||
| 
 | ||||
| #include <grub/err.h> | ||||
| #include <grub/usbdesc.h> | ||||
| #include <grub/usbtrans.h> | ||||
| 
 | ||||
|  | @ -47,6 +48,14 @@ 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,7 +106,8 @@ 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); | ||||
| 			      grub_usb_transfer_t transfer, | ||||
| 			      int timeout, grub_size_t *actual); | ||||
| 
 | ||||
|   int (*hubports) (grub_usb_controller_t dev); | ||||
| 
 | ||||
|  | @ -132,6 +142,8 @@ struct grub_usb_interface | |||
|   int attached; | ||||
| 
 | ||||
|   void (*detach_hook) (struct grub_usb_device *dev, int config, int interface); | ||||
| 
 | ||||
|   void *detach_data; | ||||
| }; | ||||
| 
 | ||||
| struct grub_usb_configuration | ||||
|  | @ -166,12 +178,32 @@ struct grub_usb_device | |||
|   /* Data toggle values (used for bulk transfers only).  */ | ||||
|   int toggle[256]; | ||||
| 
 | ||||
|   /* Device-specific data.  */ | ||||
|   /* Used by libusb wrapper.  Schedulded for removal. */ | ||||
|   void *data; | ||||
| 
 | ||||
|   /* Array of children for a hub.  */ | ||||
|   grub_usb_device_t *children; | ||||
| 
 | ||||
|   /* Number of hub ports.  */ | ||||
|   unsigned nports; | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| 
 | ||||
| typedef enum grub_usb_ep_type | ||||
|   { | ||||
|     GRUB_USB_EP_CONTROL, | ||||
|     GRUB_USB_EP_ISOCHRONOUS, | ||||
|     GRUB_USB_EP_BULK, | ||||
|     GRUB_USB_EP_INTERRUPT | ||||
|   } grub_usb_ep_type_t; | ||||
| 
 | ||||
| static inline enum grub_usb_ep_type | ||||
| grub_usb_get_ep_type (struct grub_usb_desc_endp *ep) | ||||
| { | ||||
|   return ep->attrib & 3; | ||||
| } | ||||
| 
 | ||||
| typedef enum | ||||
|   { | ||||
|     GRUB_USB_CLASS_NOTHERE, | ||||
|  | @ -230,5 +262,9 @@ void grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc); | |||
| void grub_usb_poll_devices (void); | ||||
| 
 | ||||
| void grub_usb_device_attach (grub_usb_device_t dev); | ||||
| 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); | ||||
| 
 | ||||
| #endif /* GRUB_USB_H */ | ||||
|  |  | |||
|  | @ -31,6 +31,12 @@ typedef enum { | |||
|   GRUB_USB_DESCRIPTOR_HUB = 0x29 | ||||
| } grub_usb_descriptor_t; | ||||
| 
 | ||||
| struct grub_usb_desc | ||||
| { | ||||
|   grub_uint8_t length; | ||||
|   grub_uint8_t type; | ||||
| } __attribute__ ((packed)); | ||||
| 
 | ||||
| struct grub_usb_desc_device | ||||
| { | ||||
|   grub_uint8_t length; | ||||
|  |  | |||
							
								
								
									
										34
									
								
								include/grub/usbserial.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								include/grub/usbserial.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| /* serial.h - serial device interface */ | ||||
| /*
 | ||||
|  *  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_USBSERIAL_HEADER | ||||
| #define GRUB_USBSERIAL_HEADER	1 | ||||
| 
 | ||||
| void grub_usbserial_fini (struct grub_serial_port *port); | ||||
| 
 | ||||
| void grub_usbserial_detach (grub_usb_device_t usbdev, int configno, | ||||
| 			    int interfno); | ||||
| 
 | ||||
| int | ||||
| grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno, | ||||
| 		       struct grub_serial_driver *driver); | ||||
| int | ||||
| grub_usbserial_fetch (struct grub_serial_port *port, grub_size_t header_size); | ||||
| 
 | ||||
| #endif | ||||
|  | @ -38,6 +38,7 @@ struct grub_usb_transaction | |||
|   int toggle; | ||||
|   grub_transfer_type_t pid; | ||||
|   grub_uint32_t data; | ||||
|   grub_size_t preceding; | ||||
| }; | ||||
| typedef struct grub_usb_transaction *grub_usb_transaction_t; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue