Skip to contentSkip to conversation

x86/boot: Use <xen/types.h>

PATCH In review Andrew Cooper 2 participants 4 messages Sep 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: Use <xen/types.h>

... rather than defining them locally. This also covers NULL and *_MAX.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Frediano Ziglio <[email protected]>

---
 xen/arch/x86/boot/cmdline.c |  2 ++
 xen/arch/x86/boot/defs.h    | 17 -----------------
 xen/arch/x86/boot/reloc.c   |  2 ++
 3 files changed, 4 insertions(+), 17 deletions(-)
xen/arch/x86/boot/cmdline.c +2 -0
index b8ad7f3a144a..28a47da7ab02 100644
@@ -31,6 +31,8 @@ asm (
     );
 
 #include <xen/kconfig.h>
+#include <xen/types.h>
+
 #include "defs.h"
 #include "video.h"
 
xen/arch/x86/boot/defs.h +0 -17
index ee1a4da6af03..cf9a80d116f3 100644
@@ -20,14 +20,10 @@
 #ifndef __BOOT_DEFS_H__
 #define __BOOT_DEFS_H__
 
-#include <xen/stdbool.h>
-
 #define __maybe_unused	__attribute__((__unused__))
 #define __packed	__attribute__((__packed__))
 #define __stdcall	__attribute__((__stdcall__))
 
-#define NULL		((void *)0)
-
 #define ALIGN_UP(arg, align) \
                 (((arg) + (align) - 1) & ~((typeof(arg))(align) - 1))
 
@@ -47,17 +43,4 @@
 
 #define tolower(c)	((c) | 0x20)
 
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
-typedef unsigned long long u64;
-typedef unsigned int size_t;
-typedef u8 uint8_t;
-typedef u16 uint16_t;
-typedef u32 uint32_t;
-typedef u64 uint64_t;
-
-#define UINT16_MAX	((uint16_t)(~0U))
-#define UINT_MAX	(~0U)
-
 #endif /* __BOOT_DEFS_H__ */
xen/arch/x86/boot/reloc.c +2 -0
index 589e026ff9fb..ac8b58b69581 100644
@@ -26,6 +26,8 @@ asm (
     "    jmp  reloc                    \n"
     );
 
+#include <xen/types.h>
+
 #include "defs.h"
 
 #include <xen/kconfig.h>
Signature · 1 line
2.39.2
#1 lore raw

xen/arch/x86/boot/cmdline.c asm ( · line 34

Quoted 7 lines · Andrew Cooper
xen/arch/x86/boot/cmdline.c +1 -0
@@ -31,6 +31,8 @@ asm (
     );
 
 #include <xen/kconfig.h>
+#include <xen/types.h>

And why not include the file centrally ...

xen/arch/x86/boot/defs.h line 23

Quoted 7 lines
xen/arch/x86/boot/defs.h +0 -1
@@ -20,14 +20,10 @@
 #ifndef __BOOT_DEFS_H__
 #define __BOOT_DEFS_H__
 
-#include <xen/stdbool.h>

... here? Both above and ...

xen/arch/x86/boot/reloc.c asm ( · line 31

Quoted 9 lines
xen/arch/x86/boot/reloc.c +2 -0
@@ -26,6 +26,8 @@ asm (
     "    jmp  reloc                    \n"
     );
 
+#include <xen/types.h>
+
 #include "defs.h"

... here you have the inclusion ahead of that of defs.h, so there aren't any other dependencies (unless something subtle is going on).

Jan

#2 lore raw
Quoted 25 lines · Jan Beulich

xen/arch/x86/boot/cmdline.c asm ( · line 34

Quoted 7 lines · Andrew Cooper
xen/arch/x86/boot/cmdline.c +1 -0
@@ -31,6 +31,8 @@ asm (
     );
 
 #include <xen/kconfig.h>
+#include <xen/types.h>

And why not include the file centrally ...

xen/arch/x86/boot/defs.h line 23

Quoted 7 lines
xen/arch/x86/boot/defs.h +0 -1
@@ -20,14 +20,10 @@
 #ifndef __BOOT_DEFS_H__
 #define __BOOT_DEFS_H__
 
-#include <xen/stdbool.h>

... here? Both above and ...

Quoted 6 lines
xen/arch/x86/boot/reloc.c +0 -0
@@ -26,6 +26,8 @@ asm (
     "    jmp  reloc                    \n"
     );
 
Quoted 5 lines

xen/arch/x86/boot/reloc.c asm ( · line 31

Quoted 3 lines
xen/arch/x86/boot/reloc.c +2 -0
+#include <xen/types.h>
+
 #include "defs.h"

... here you have the inclusion ahead of that of defs.h, so there aren't any other dependencies (unless something subtle is going on).

Because I intend to delete defs.h entirely.

I've had a bit of fun unpicking __stdcall (looking to remove it entirely, and replace with fastcall), and we need to shuffle a couple more macros into macros.h, but all of defs.h can be replaced with types.h, compiler.h and macros.h

The other problem right now (forcing the order of inclusion here), is that multiboot*.h implicitly use types.h.

~Andrew

Reviewed-by
#3 lore raw
Quoted 26 lines · Andrew Cooper
Quoted 25 lines · Jan Beulich

xen/arch/x86/boot/cmdline.c asm ( · line 34

Quoted 7 lines · Andrew Cooper
xen/arch/x86/boot/cmdline.c +1 -0
@@ -31,6 +31,8 @@ asm (
     );
 
 #include <xen/kconfig.h>
+#include <xen/types.h>

And why not include the file centrally ...

xen/arch/x86/boot/defs.h line 23

Quoted 7 lines
xen/arch/x86/boot/defs.h +0 -1
@@ -20,14 +20,10 @@
 #ifndef __BOOT_DEFS_H__
 #define __BOOT_DEFS_H__
 
-#include <xen/stdbool.h>

... here? Both above and ...

Quoted 6 lines
xen/arch/x86/boot/reloc.c +0 -0
@@ -26,6 +26,8 @@ asm (
     "    jmp  reloc                    \n"
     );
 
Quoted 7 lines
Quoted 5 lines

xen/arch/x86/boot/reloc.c asm ( · line 31

Quoted 3 lines
xen/arch/x86/boot/reloc.c +2 -0
+#include <xen/types.h>
+
 #include "defs.h"

... here you have the inclusion ahead of that of defs.h, so there aren't any other dependencies (unless something subtle is going on).

Because I intend to delete defs.h entirely.

Oh, okay.

Jan