mirror of
https://github.com/ipxe/ipxe
synced 2025-12-07 09:50:26 +03:00
[uart] Allow for dynamically registered 16550 UARTs
Use the generic UART driver-private data pointer, rather than embedding the generic UART within the 16550 UART structure. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -35,13 +35,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
/** Define a fixed ISA UART */
|
||||
#define ISA_UART( NAME, BASE ) \
|
||||
struct ns16550_uart NAME = { \
|
||||
.uart = { \
|
||||
.refcnt = REF_INIT ( ref_no_free ), \
|
||||
.name = #NAME, \
|
||||
.op = &ns16550_operations, \
|
||||
}, \
|
||||
static struct ns16550_uart ns16550_ ## NAME = { \
|
||||
.base = ( ( void * ) (BASE) ), \
|
||||
}; \
|
||||
struct uart NAME = { \
|
||||
.refcnt = REF_INIT ( ref_no_free ), \
|
||||
.name = #NAME, \
|
||||
.op = &ns16550_operations, \
|
||||
.priv = &ns16550_ ## NAME, \
|
||||
}
|
||||
|
||||
/* Fixed ISA UARTs */
|
||||
|
||||
@@ -46,15 +46,15 @@ ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ) {
|
||||
#define COM4_BASE 0x2e8
|
||||
|
||||
/* Fixed ISA serial ports */
|
||||
extern struct ns16550_uart com1;
|
||||
extern struct ns16550_uart com2;
|
||||
extern struct ns16550_uart com3;
|
||||
extern struct ns16550_uart com4;
|
||||
extern struct uart com1;
|
||||
extern struct uart com2;
|
||||
extern struct uart com3;
|
||||
extern struct uart com4;
|
||||
|
||||
/* Fixed ISA serial port names */
|
||||
#define COM1 &com1.uart
|
||||
#define COM2 &com2.uart
|
||||
#define COM3 &com3.uart
|
||||
#define COM4 &com4.uart
|
||||
#define COM1 &com1
|
||||
#define COM2 &com2
|
||||
#define COM3 &com3
|
||||
#define COM4 &com4
|
||||
|
||||
#endif /* _BITS_NS16550_H */
|
||||
|
||||
@@ -447,9 +447,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
|
||||
|
||||
case 0x000B: /* Get Serial Console Configuration */
|
||||
if ( serial_console ) {
|
||||
struct ns16550_uart *comport =
|
||||
container_of ( serial_console,
|
||||
struct ns16550_uart, uart );
|
||||
struct ns16550_uart *comport = serial_console->priv;
|
||||
|
||||
ix86->regs.dx = ( ( intptr_t ) comport->base );
|
||||
ix86->regs.cx = comport->divisor;
|
||||
|
||||
@@ -47,8 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* @v data Data
|
||||
*/
|
||||
static void ns16550_transmit ( struct uart *uart, uint8_t data ) {
|
||||
struct ns16550_uart *ns16550 =
|
||||
container_of ( uart, struct ns16550_uart, uart );
|
||||
struct ns16550_uart *ns16550 = uart->priv;
|
||||
unsigned int i;
|
||||
uint8_t lsr;
|
||||
|
||||
@@ -71,8 +70,7 @@ static void ns16550_transmit ( struct uart *uart, uint8_t data ) {
|
||||
* @ret ready Data is ready
|
||||
*/
|
||||
static int ns16550_data_ready ( struct uart *uart ) {
|
||||
struct ns16550_uart *ns16550 =
|
||||
container_of ( uart, struct ns16550_uart, uart );
|
||||
struct ns16550_uart *ns16550 = uart->priv;
|
||||
uint8_t lsr;
|
||||
|
||||
/* Check for receive data ready */
|
||||
@@ -87,8 +85,7 @@ static int ns16550_data_ready ( struct uart *uart ) {
|
||||
* @ret data Data
|
||||
*/
|
||||
static uint8_t ns16550_receive ( struct uart *uart ) {
|
||||
struct ns16550_uart *ns16550 =
|
||||
container_of ( uart, struct ns16550_uart, uart );
|
||||
struct ns16550_uart *ns16550 = uart->priv;
|
||||
uint8_t rbr;
|
||||
|
||||
/* Receive byte */
|
||||
@@ -102,8 +99,7 @@ static uint8_t ns16550_receive ( struct uart *uart ) {
|
||||
* @v uart UART
|
||||
*/
|
||||
static void ns16550_flush ( struct uart *uart ) {
|
||||
struct ns16550_uart *ns16550 =
|
||||
container_of ( uart, struct ns16550_uart, uart );
|
||||
struct ns16550_uart *ns16550 = uart->priv;
|
||||
unsigned int i;
|
||||
uint8_t lsr;
|
||||
|
||||
@@ -123,8 +119,7 @@ static void ns16550_flush ( struct uart *uart ) {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int ns16550_init ( struct uart *uart, unsigned int baud ) {
|
||||
struct ns16550_uart *ns16550 =
|
||||
container_of ( uart, struct ns16550_uart, uart );
|
||||
struct ns16550_uart *ns16550 = uart->priv;
|
||||
uint8_t dlm;
|
||||
uint8_t dll;
|
||||
|
||||
|
||||
@@ -78,8 +78,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
/** A 16550-compatible UART */
|
||||
struct ns16550_uart {
|
||||
/** Generic UART */
|
||||
struct uart uart;
|
||||
/** Register base address */
|
||||
void *base;
|
||||
/** Register shift */
|
||||
|
||||
Reference in New Issue
Block a user