/** 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 */
#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 */
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;
* @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;
* @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 */
* @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 */
* @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;
* @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;
/** A 16550-compatible UART */
struct ns16550_uart {
- /** Generic UART */
- struct uart uart;
/** Register base address */
void *base;
/** Register shift */