From b89b833a5cd5059a863779cb2c507f0abd080191 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Sun, 14 Jan 2024 17:36:23 +0100 Subject: 64-bit works up until kernel start --- .config | 5 ++++- Makefile | 4 ++-- Makefile.parisc | 13 ++++++------- src/malloc.h | 4 ++-- src/output.c | 25 +++++++++++++++++++++++-- src/parisc/hppa.h | 13 ++++++++++++- src/parisc/malloc.c | 4 ++-- src/parisc/parisc.c | 3 ++- src/util.h | 2 +- 9 files changed, 54 insertions(+), 19 deletions(-) diff --git a/.config b/.config index 722c564..69b6356 100644 --- a/.config +++ b/.config @@ -78,4 +78,7 @@ CONFIG_VGA_EXTRA_STACK_SIZE=512 # # Debugging # -CONFIG_DEBUG_LEVEL=0 +CONFIG_DEBUG_LEVEL=10 +CONFIG_DEBUG_SERIAL=y +CONFIG_DEBUG_SERIAL_PORT=0x3f8 +CONFIG_DEBUG_IO=y diff --git a/Makefile b/Makefile index dd7c059..2c813a5 100644 --- a/Makefile +++ b/Makefile @@ -107,8 +107,8 @@ parisc: FORCE ifneq "$(CONFIG_PARISC)" "y" @echo "ERROR: run 'make config' and select PA-RISC before building the parisc target." endif - DIRS="" OUT=out/ BITS=32 BIT_SUFFIX="" CROSS_PREFIX=hppa-linux-gnu- $(MAKE) -f Makefile.parisc all - # DIRS="" OUT=out-64/ BITS=64 BIT_SUFFIX="64" CROSS_PREFIX=hppa64-linux-gnu- $(MAKE) -f Makefile.parisc all + # DIRS="" OUT=out/ BITS=32 BIT_SUFFIX="" CROSS_PREFIX=hppa-linux-gnu- $(MAKE) -f Makefile.parisc all + DIRS="" OUT=out-64/ BITS=64 BIT_SUFFIX="64" CROSS_PREFIX=hppa64-linux-gnu- $(MAKE) -f Makefile.parisc all # Make definitions .PHONY : all clean distclean parisc FORCE diff --git a/Makefile.parisc b/Makefile.parisc index 36edc0c..3312ffb 100644 --- a/Makefile.parisc +++ b/Makefile.parisc @@ -69,16 +69,15 @@ COMMONCFLAGS := -I$(OUT) -Isrc -Ivgasrc -Os -MD -g \ -Wall -Wno-strict-aliasing -Wold-style-definition -Wno-address-of-packed-member \ -Wno-stringop-overflow -Wno-array-bounds \ $(call cc-option,$(CC),-Wtype-limits,) \ - -fomit-frame-pointer \ - -freg-struct-return -ffreestanding -fno-delete-null-pointer-checks \ - -fdata-sections -fno-common -fno-merge-constants -mdisable-fpregs \ - -fno-builtin-printf -fno-ipa-sra -COMMONCFLAGS += $(call cc-option,$(CC),-nopie,) -COMMONCFLAGS += $(call cc-option,$(CC),-fno-pie,) + -mdisable-fpregs -ffreestanding \ + -fno-builtin-printf -fno-common -fomit-frame-pointer -fno-ipa-sra -freg-struct-return -fno-delete-null-pointer-checks +# -ffreestanding -fdata-sections -fno-common -fno-merge-constants -mdisable-fpregs +# COMMONCFLAGS += $(call cc-option,$(CC),-nopie,) +# COMMONCFLAGS += $(call cc-option,$(CC),-fno-pie,) COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,) COMMONCFLAGS += $(call cc-option,$(CC),-fstack-check=no,) -COMMONCFLAGS += $(call cc-option,$(CC),-mfast-indirect-calls,) +# COMMONCFLAGS += $(call cc-option,$(CC),-mfast-indirect-calls,) COMMONCFLAGS-64 = -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast COMMONCFLAGS-32 = diff --git a/src/malloc.h b/src/malloc.h index 73962b4..016761c 100644 --- a/src/malloc.h +++ b/src/malloc.h @@ -16,8 +16,8 @@ void malloc_preinit(void); extern u32 LegacyRamSize; void malloc_init(void); void malloc_prepboot(void); -unsigned long malloc_palloc(struct zone_s *zone, u32 size, u32 align); -void *parisc_malloc(u32 size, u32 align); +unsigned long malloc_palloc(struct zone_s *zone, u32 size, unsigned long align); +void *parisc_malloc(u32 size, unsigned long align); void *x86_malloc(struct zone_s *zone, u32 size, u32 align); #define _malloc(zone, size, align) \ (CONFIG_X86 ? x86_malloc(zone, size, align) : parisc_malloc(size, align)) diff --git a/src/output.c b/src/output.c index 9892ea7..f6ce8ae 100644 --- a/src/output.c +++ b/src/output.c @@ -122,8 +122,13 @@ putc(struct putcinfo *action, char c) return; } +#if 0 void (*func)(struct putcinfo *info, char c) = GET_GLOBAL(action->func); func(action, c); +#else + builtin_console_out(c); + // screen_putc(action,c); +#endif } // Ouptut a string. @@ -185,8 +190,12 @@ putsinglehex(struct putcinfo *action, u32 val, int uc) // Output an integer in hexadecimal with a specified width. static void -puthex(struct putcinfo *action, u32 val, int width, int uc) +puthex(struct putcinfo *action, u64 val, int width, int uc) { + if (width > 8) { + width -= 8; + puthex(action, val >> 32, width, uc); + } switch (width) { default: putsinglehex(action, (val >> 28) & 0xf, uc); case 7: putsinglehex(action, (val >> 24) & 0xf, uc); @@ -246,7 +255,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) const char *n = s+1; int field_width = 0; char padchar = ' '; +#ifdef __LP64__ + u8 is64 = 1; +#else u8 is64 = 0; +#endif for (;;) { c = GET_GLOBAL(*(u8*)n); if (!isdigit(c)) @@ -267,7 +280,7 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) n++; c = GET_GLOBAL(*(u8*)n); } - s32 val; + s32 val = 0; s64 val64; const char *sarg; switch (c) { @@ -293,7 +306,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) putuint(action, val64); break; case 'p': +#ifdef __LP64__ + val64 = va_arg(args, s64); +#else val = va_arg(args, s32); +#endif if (!MODESEGMENT && GET_GLOBAL(*(u8*)(n+1)) == 'P') { // %pP is 'struct pci_device' printer put_pci_device(action, (void*)val); @@ -302,7 +319,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) } putc(action, '0'); putc(action, 'x'); +#ifdef __LP64__ + puthex(action, val64, 16, 0); +#else puthex(action, val, 8, 0); +#endif break; case 'X': case 'x': diff --git a/src/parisc/hppa.h b/src/parisc/hppa.h index 03cd9f9..4d8a6e5 100644 --- a/src/parisc/hppa.h +++ b/src/parisc/hppa.h @@ -208,6 +208,17 @@ static inline u32 ror(u32 word, unsigned int shift) return (word >> (shift & 31)) | (word << ((-shift) & 31)); } + +/* F_EXTEND() is used to access I/O ports. ROM_EXTEND() to access firmware ROM/RAM */ +#define F_EXTEND(x) ((unsigned long)(0xfffffffful<<32) | (x)) +#define ROM_EXTEND(x) ((unsigned long)(0xfffffff0ul<<32) | (x)) + +static inline void builtin_console_out(char c) +{ + asm volatile("copy %0,%%r26 ! diag 0x101" : : "r" (c) : "r26"); +} + + extern char has_astro; /* false for B160L machine with Dino PCI chip */ extern unsigned long hppa_port_pci_cmd; extern unsigned long hppa_port_pci_data; @@ -216,7 +227,7 @@ extern unsigned long hppa_port_pci_data; #define pci_ioport_addr(port) ((port >= 0x1000) && (port < FIRMWARE_START)) #define is_astro_ioport(port) (has_astro && (port < IOS_DIST_BASE_SIZE)) -#define astro_ioport_addr(port) ((void *)(portaddr_t)(IOS_DIST_BASE_ADDR + port)) +#define astro_ioport_addr(port) ((void *)(portaddr_t) F_EXTEND(IOS_DIST_BASE_ADDR + port)) /* inb()/outb() accesses little-endian memory and does byteswapping to host endianess */ diff --git a/src/parisc/malloc.c b/src/parisc/malloc.c index b4f56d5..399d300 100644 --- a/src/parisc/malloc.c +++ b/src/parisc/malloc.c @@ -23,7 +23,7 @@ static unsigned long stackptr; // Allocate physical memory from the given zone and track it as a PMM allocation unsigned long -malloc_palloc(struct zone_s *zone, u32 size, u32 align) +malloc_palloc(struct zone_s *zone, u32 size, unsigned long align) { unsigned long data; @@ -42,7 +42,7 @@ malloc_palloc(struct zone_s *zone, u32 size, u32 align) // Allocate virtual memory from the given zone void * __malloc -parisc_malloc(u32 size, u32 align) +parisc_malloc(u32 size, unsigned long align) { return (void*) malloc_palloc(NULL, size, align); } diff --git a/src/parisc/parisc.c b/src/parisc/parisc.c index 2e8f25c..42b8e31 100644 --- a/src/parisc/parisc.c +++ b/src/parisc/parisc.c @@ -112,7 +112,7 @@ void wrmsr_smp(u32 index, u64 val) { } #define initrd_end boot_args[4] #define smp_cpus boot_args[5] #define pdc_debug boot_args[6] -#define fw_cfg_port boot_args[7] +#define fw_cfg_port F_EXTEND(boot_args[7]) /* flags for pdc_debug */ #define DEBUG_PDC 0x01 @@ -202,6 +202,7 @@ void __VISIBLE __noreturn hlt(void) if (pdc_debug) printf("HALT initiated from %p\n", __builtin_return_address(0)); printf("SeaBIOS wants SYSTEM HALT.\n\n"); +while (1) {} ; /* call qemu artificial "halt" asm instruction */ asm volatile("\t.word 0xfffdead0": : :"memory"); while (1); diff --git a/src/util.h b/src/util.h index dd919a8..3329c31 100644 --- a/src/util.h +++ b/src/util.h @@ -95,7 +95,7 @@ u32 find_resume_vector(void); void acpi_reboot(void); void find_acpi_features(void); extern struct smbios_entry_point *SMBiosAddr; -struct smbios_entry_point *get_smbios_entry_point(); +struct smbios_entry_point *get_smbios_entry_point(void); void copy_smbios(void *pos); void display_uuid(void); void copy_table(void *pos); -- cgit v1.1