]>
git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/CpuIoDxe/Ia32/CpuIoAccessGNU.c
1 /* This file is only used when not able to compile the MASM CpuIoAccess.asm
2 NOTE: Compiling with -fomit-frame-pointer would get you to roughly the exact
3 same code as the MASM file although GCC will typically include movzbl %al, %eax
4 or movzwl %ax, %eax instructions on the read functions such that the entire
5 eax result register will be valid, not just the lowest 8 or 16 bits.
9 /* A quick note about GCC inline asm and the GNU assembler:
10 When gas encounters an instruction with a suffix (e.g. inb, inw, or inl vs. just in) it will
11 warn if the operand corresponding to the suffix is not of the correct size and will assume you
12 meant what you said when you specified the suffix.
14 Because GCC does not enable us to see whether it is replacing %0 with %al, %ax, or %eax it is
15 helpful to have the assembler warn us that GCC is making an incorrect assumption. The actual
16 in or out instruction will always be generated correctly in this case since the assembler is
17 correct in assuming we meant what we said when we specified the suffix. However, GCC might
18 generate incorrect surrounding code. For example, if we were to incorrectly specify the
19 output size of an in instruction as UINT32, GCC would potentially fail to issue movz(b|w)l after
20 it under the assumption that the in instruction filled the entire eax register and not just
23 GCC determines which size of register to use based on the C data type. So for in instructions
24 the interesting type is that of the automatic variable named Data which is specified as an
25 output operand to the inline assembly statement. For example:
34 In this case, GCC will replace %0 with %al. If Data had been specified as UINT16, it would replace
35 %0 with %ax, and for UINT32 with %eax.
37 Likewise in the case of IA32 out instructions, GCC will replace %0 with the appropriately sized
38 register based on the size of the input operand. There is one gotcha though. The CpuIoWrite
39 series of functions all use UINT32 as the type of the second (Data) argument. This means that
40 for GCC to output the correct register size we must cast it appropriately.
42 The Port number is always a UINT16 so GCC will always ouput %dx.
45 #include "CpuIoAccess.h"
127 /* NOTE: Cast is technically unnecessary but we use it to illustrate
128 that we always want to output a UINT32 and never anything else.
134 #endif /* def __GNUC__ */