问题
I am trying to understand the 8250 serial port on pci express bus of our board by going through the driver code and I am having hard time understanding the below two members of struct uart_8250_port
struct uart_8250_port x;
memset(&x, 0, sizeof(x));
....
....
x.port.regshift = 0;
x.port.iotype = UPIO_MEM;
x.port.flags = UPF_SHARE_IRQ | UPF_LOW_LATENCY;
x.port.membase = raw_address;
x.port.mapbase = ioremap(raw_address);
What are the members membase
and mapbase
? Also, why does membase
take physical pci bar address whereas mapbase
takes address returned from ioremap
?
回答1:
mapbase
is basically a bus address of the port register space in the question. membase
is the same address in CPU virtual address space for memory mapped IO (MMIO) and iobase
is the similar for IO.
Yes, you may already notice that in your example you have a mistake, i.e. membase
and mapbase
should be exchanged.
mapbase
address is needed to do, for example, DMA operations on top of UART hardware since DMA operates with bus addresses.
来源:https://stackoverflow.com/questions/38602052/what-are-mapbase-and-membase-members-of-uart-8250-port-structure