bios_emulator: how LOG_inpb() is supposed to work on non-x86 systems?
Yuri Zaporozhets
yuriz at vodafonemail.de
Thu Oct 31 21:23:27 CET 2024
Hi all,
When trying to compile drivers/bios_emulator for RISC-V, I get a
bunch of the following warnings:
================
In file included from drivers/bios_emulator/besys.c:51:
drivers/bios_emulator/besys.c: In function ‘BE_inb’:
./arch/riscv/include/asm/io.h:18:43: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
18 | #define __arch_getb(a) (*(volatile unsigned char *)(a))
| ^
./arch/riscv/include/asm/io.h:33:41: note: in expansion of macro ‘__arch_getb’
33 | #define __raw_readb(a) __arch_getb(a)
| ^~~~~~~~~~~
./arch/riscv/include/asm/io.h:209:39: note: in expansion of macro ‘__raw_readb’
209 | #define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; })
| ^~~~~~~~~~~
drivers/bios_emulator/biosemui.h:131:25: note: in expansion of macro ‘inb’
131 | #define PM_inpb(port) inb(port)
| ^~~
drivers/bios_emulator/biosemui.h:138:25: note: in expansion of macro ‘PM_inpb’
138 | #define LOG_inpb(port) PM_inpb(port)
| ^~~~~~~
drivers/bios_emulator/besys.c:572:31: note: in expansion of macro ‘LOG_inpb’
572 | val = LOG_inpb(port);
================
My question is: how _in principle_ is this supposed to work? On non-x86 systems,
the PCI I/O space must always be accessed using some base address (for example,
for my PCIe video card it's 0x60080000). In the sequence above
(inb -> __raw_readb -> __arch_getb) I do not see such base address at all.
Previously, there was a constant VIDEO_IO_OFFSET added to the port
(see 70f2030f02696ee1820d8df690e878de078b01b3), but it was removed completely.
In arch/riscv/include/asm/io.h, the I/O primitives are defined as:
#define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; })
where the __io() macro seems to be an excellent thing to account for the
I/O base address. I would expect that the driver that uses PCI I/O
defines something like:
#define __io(port) (base_addr + port)
where base_addr is a runtime variable. But instead both bios.c and besys.c
have just "#define __io", without any parameters.
I am totally puzzled. I would be grateful for any clarification how this code
was supposed to work in the first place.
P.S. Simon, adding you to CC: since you were working on this code in the past.
Thanks in advance.
--
Regards,
Yuri
More information about the U-Boot
mailing list