mirror of
https://github.com/ipxe/ipxe
synced 2025-12-08 18:30:28 +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 a fixed ISA UART */
|
||||||
#define ISA_UART( NAME, BASE ) \
|
#define ISA_UART( NAME, BASE ) \
|
||||||
struct ns16550_uart NAME = { \
|
static struct ns16550_uart ns16550_ ## NAME = { \
|
||||||
.uart = { \
|
|
||||||
.refcnt = REF_INIT ( ref_no_free ), \
|
|
||||||
.name = #NAME, \
|
|
||||||
.op = &ns16550_operations, \
|
|
||||||
}, \
|
|
||||||
.base = ( ( void * ) (BASE) ), \
|
.base = ( ( void * ) (BASE) ), \
|
||||||
|
}; \
|
||||||
|
struct uart NAME = { \
|
||||||
|
.refcnt = REF_INIT ( ref_no_free ), \
|
||||||
|
.name = #NAME, \
|
||||||
|
.op = &ns16550_operations, \
|
||||||
|
.priv = &ns16550_ ## NAME, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fixed ISA UARTs */
|
/* Fixed ISA UARTs */
|
||||||
|
|||||||
@@ -46,15 +46,15 @@ ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ) {
|
|||||||
#define COM4_BASE 0x2e8
|
#define COM4_BASE 0x2e8
|
||||||
|
|
||||||
/* Fixed ISA serial ports */
|
/* Fixed ISA serial ports */
|
||||||
extern struct ns16550_uart com1;
|
extern struct uart com1;
|
||||||
extern struct ns16550_uart com2;
|
extern struct uart com2;
|
||||||
extern struct ns16550_uart com3;
|
extern struct uart com3;
|
||||||
extern struct ns16550_uart com4;
|
extern struct uart com4;
|
||||||
|
|
||||||
/* Fixed ISA serial port names */
|
/* Fixed ISA serial port names */
|
||||||
#define COM1 &com1.uart
|
#define COM1 &com1
|
||||||
#define COM2 &com2.uart
|
#define COM2 &com2
|
||||||
#define COM3 &com3.uart
|
#define COM3 &com3
|
||||||
#define COM4 &com4.uart
|
#define COM4 &com4
|
||||||
|
|
||||||
#endif /* _BITS_NS16550_H */
|
#endif /* _BITS_NS16550_H */
|
||||||
|
|||||||
@@ -447,9 +447,7 @@ static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) {
|
|||||||
|
|
||||||
case 0x000B: /* Get Serial Console Configuration */
|
case 0x000B: /* Get Serial Console Configuration */
|
||||||
if ( serial_console ) {
|
if ( serial_console ) {
|
||||||
struct ns16550_uart *comport =
|
struct ns16550_uart *comport = serial_console->priv;
|
||||||
container_of ( serial_console,
|
|
||||||
struct ns16550_uart, uart );
|
|
||||||
|
|
||||||
ix86->regs.dx = ( ( intptr_t ) comport->base );
|
ix86->regs.dx = ( ( intptr_t ) comport->base );
|
||||||
ix86->regs.cx = comport->divisor;
|
ix86->regs.cx = comport->divisor;
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
* @v data Data
|
* @v data Data
|
||||||
*/
|
*/
|
||||||
static void ns16550_transmit ( struct uart *uart, uint8_t data ) {
|
static void ns16550_transmit ( struct uart *uart, uint8_t data ) {
|
||||||
struct ns16550_uart *ns16550 =
|
struct ns16550_uart *ns16550 = uart->priv;
|
||||||
container_of ( uart, struct ns16550_uart, uart );
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
uint8_t lsr;
|
uint8_t lsr;
|
||||||
|
|
||||||
@@ -71,8 +70,7 @@ static void ns16550_transmit ( struct uart *uart, uint8_t data ) {
|
|||||||
* @ret ready Data is ready
|
* @ret ready Data is ready
|
||||||
*/
|
*/
|
||||||
static int ns16550_data_ready ( struct uart *uart ) {
|
static int ns16550_data_ready ( struct uart *uart ) {
|
||||||
struct ns16550_uart *ns16550 =
|
struct ns16550_uart *ns16550 = uart->priv;
|
||||||
container_of ( uart, struct ns16550_uart, uart );
|
|
||||||
uint8_t lsr;
|
uint8_t lsr;
|
||||||
|
|
||||||
/* Check for receive data ready */
|
/* Check for receive data ready */
|
||||||
@@ -87,8 +85,7 @@ static int ns16550_data_ready ( struct uart *uart ) {
|
|||||||
* @ret data Data
|
* @ret data Data
|
||||||
*/
|
*/
|
||||||
static uint8_t ns16550_receive ( struct uart *uart ) {
|
static uint8_t ns16550_receive ( struct uart *uart ) {
|
||||||
struct ns16550_uart *ns16550 =
|
struct ns16550_uart *ns16550 = uart->priv;
|
||||||
container_of ( uart, struct ns16550_uart, uart );
|
|
||||||
uint8_t rbr;
|
uint8_t rbr;
|
||||||
|
|
||||||
/* Receive byte */
|
/* Receive byte */
|
||||||
@@ -102,8 +99,7 @@ static uint8_t ns16550_receive ( struct uart *uart ) {
|
|||||||
* @v uart UART
|
* @v uart UART
|
||||||
*/
|
*/
|
||||||
static void ns16550_flush ( struct uart *uart ) {
|
static void ns16550_flush ( struct uart *uart ) {
|
||||||
struct ns16550_uart *ns16550 =
|
struct ns16550_uart *ns16550 = uart->priv;
|
||||||
container_of ( uart, struct ns16550_uart, uart );
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
uint8_t lsr;
|
uint8_t lsr;
|
||||||
|
|
||||||
@@ -123,8 +119,7 @@ static void ns16550_flush ( struct uart *uart ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ns16550_init ( struct uart *uart, unsigned int baud ) {
|
static int ns16550_init ( struct uart *uart, unsigned int baud ) {
|
||||||
struct ns16550_uart *ns16550 =
|
struct ns16550_uart *ns16550 = uart->priv;
|
||||||
container_of ( uart, struct ns16550_uart, uart );
|
|
||||||
uint8_t dlm;
|
uint8_t dlm;
|
||||||
uint8_t dll;
|
uint8_t dll;
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
|
|
||||||
/** A 16550-compatible UART */
|
/** A 16550-compatible UART */
|
||||||
struct ns16550_uart {
|
struct ns16550_uart {
|
||||||
/** Generic UART */
|
|
||||||
struct uart uart;
|
|
||||||
/** Register base address */
|
/** Register base address */
|
||||||
void *base;
|
void *base;
|
||||||
/** Register shift */
|
/** Register shift */
|
||||||
|
|||||||
Reference in New Issue
Block a user