Reactos

[MINIHAL] Minor improvements (#7398)

* [FREELDR] Mark noreturn functions

* [FREELDR] Compile hw debugging support code only in debug builds

- Make BREAKPOINT() portable

* [FREELDR] Consolidate identical names into a single string

* [FREELDR] Use intrinsics for string I/O operations on x86 and x64

Stop them being pulled in from a static minihal library

* [MINIHAL] Exclude unnecessary portio dependency

authored by

Dmitry Borisov and committed by
GitHub
029e53dd 0089017d

+64 -23
+1
boot/freeldr/freeldr/arch/arm/debug.c
··· 24 24 *UART0DR = ByteToSend; 25 25 } 26 26 27 + DECLSPEC_NORETURN 27 28 VOID 28 29 FrLdrBugCheckWithMessage( 29 30 ULONG BugCode,
+27 -21
boot/freeldr/freeldr/arch/i386/i386bug.c
··· 12 12 13 13 static const CHAR *i386ExceptionDescriptionText[] = 14 14 { 15 - "Exception 00: DIVIDE BY ZERO", 16 - "Exception 01: DEBUG EXCEPTION", 17 - "Exception 02: NON-MASKABLE INTERRUPT EXCEPTION", 18 - "Exception 03: BREAKPOINT (INT 3)", 19 - "Exception 04: OVERFLOW", 20 - "Exception 05: BOUND EXCEPTION", 21 - "Exception 06: INVALID OPCODE", 22 - "Exception 07: FPU NOT AVAILABLE", 23 - "Exception 08: DOUBLE FAULT", 24 - "Exception 09: COPROCESSOR SEGMENT OVERRUN", 25 - "Exception 0A: INVALID TSS", 26 - "Exception 0B: SEGMENT NOT PRESENT", 27 - "Exception 0C: STACK EXCEPTION", 28 - "Exception 0D: GENERAL PROTECTION FAULT", 29 - "Exception 0E: PAGE FAULT", 30 - "Exception 0F: Reserved", 31 - "Exception 10: COPROCESSOR ERROR", 32 - "Exception 11: ALIGNMENT CHECK", 33 - "Exception 12: MACHINE CHECK" 15 + "DIVIDE BY ZERO", 16 + "DEBUG EXCEPTION", 17 + "NON-MASKABLE INTERRUPT EXCEPTION", 18 + "BREAKPOINT (INT 3)", 19 + "OVERFLOW", 20 + "BOUND EXCEPTION", 21 + "INVALID OPCODE", 22 + "FPU NOT AVAILABLE", 23 + "DOUBLE FAULT", 24 + "COPROCESSOR SEGMENT OVERRUN", 25 + "INVALID TSS", 26 + "SEGMENT NOT PRESENT", 27 + "STACK EXCEPTION", 28 + "GENERAL PROTECTION FAULT", 29 + "PAGE FAULT", 30 + "Reserved", 31 + "COPROCESSOR ERROR", 32 + "ALIGNMENT CHECK", 33 + "MACHINE CHECK" 34 34 }; 35 35 36 36 #define SCREEN_ATTR 0x1F // Bright white on blue background ··· 118 118 119 119 PrintText("FreeLdr " KERNEL_VERSION_STR " " KERNEL_VERSION_BUILD_STR "\n" 120 120 "Report this error on the ReactOS Bug Tracker: https://jira.reactos.org\n\n" 121 - "0x%02lx: %s\n\n", TrapIndex, i386ExceptionDescriptionText[TrapIndex]); 121 + "0x%02lx: Exception %02X: %s\n\n", 122 + TrapIndex, 123 + TrapIndex, 124 + i386ExceptionDescriptionText[TrapIndex]); 122 125 123 126 #ifdef _M_IX86 124 127 PrintText("EAX: %.8lx ESP: %.8lx CR0: %.8lx DR0: %.8lx\n", ··· 194 197 InstructionPointer[6], InstructionPointer[7]); 195 198 } 196 199 200 + DECLSPEC_NORETURN 197 201 VOID 198 202 FrLdrBugCheckWithMessage( 199 203 ULONG BugCode, ··· 227 231 for (;;); 228 232 } 229 233 234 + static 235 + DECLSPEC_NORETURN 230 236 void 231 - NTAPI 232 237 FrLdrBugCheckEx( 233 238 ULONG BugCode, 234 239 PCHAR File, ··· 256 261 for (;;); 257 262 } 258 263 264 + DECLSPEC_NORETURN 259 265 void 260 266 NTAPI 261 267 FrLdrBugCheck(ULONG BugCode)
+2
boot/freeldr/freeldr/arch/i386/i386trap.S
··· 142 142 TRAP_STUB _i386MachineCheck, 18 143 143 TRAP_STUB _i386SimdFloatError, 19 144 144 145 + #if DBG 145 146 /************************************************************************ 146 147 * DEBUGGING SUPPORT FUNCTIONS 147 148 ************************************************************************/ ··· 176 177 BREAKPOINT_TEMPLATE _INSTRUCTION_BREAKPOINT4, HEX(00fffffff), HEX(0000003c0) 177 178 BREAKPOINT_TEMPLATE _MEMORY_READWRITE_BREAKPOINT4, HEX(00fffffff), HEX(0300003c0) 178 179 BREAKPOINT_TEMPLATE _MEMORY_WRITE_BREAKPOINT4, HEX(00fffffff), HEX(0100003c0) 180 + #endif // DBG 179 181 180 182 END
+1
boot/freeldr/freeldr/arch/uefi/uefildr.c
··· 80 80 } 81 81 82 82 #ifndef _M_ARM 83 + DECLSPEC_NORETURN 83 84 VOID __cdecl Reboot(VOID) 84 85 { 85 86 //TODO: Replace with a true firmware reboot eventually
+1
boot/freeldr/freeldr/include/arch/arm/hardware.h
··· 34 34 35 35 #define DriveMapGetBiosDriveNumber(DeviceName) 0 36 36 37 + DECLSPEC_NORETURN 37 38 FORCEINLINE VOID Reboot(VOID) 38 39 { 39 40 DbgBreakPoint();
+11
boot/freeldr/freeldr/include/arch/pc/hardware.h
··· 23 23 #define TAG_HW_RESOURCE_LIST 'lRwH' 24 24 #define TAG_HW_DISK_CONTEXT 'cDwH' 25 25 26 + /* 27 + * These aren't defined in the ioaccess.h header. 28 + * Because of that we manually define the symbols we need to make use of I/O ports. 29 + */ 30 + #define READ_PORT_BUFFER_UCHAR(port, buffer, count) __inbytestring(H2I(port), buffer, count) 31 + #define READ_PORT_BUFFER_USHORT(port, buffer, count) __inwordstring(H2I(port), buffer, count) 32 + #define READ_PORT_BUFFER_ULONG(port, buffer, count) __indwordstring(H2I(port), buffer, count) 33 + #define WRITE_PORT_BUFFER_UCHAR(port, buffer, count) __outbytestring(H2I(port), buffer, count) 34 + #define WRITE_PORT_BUFFER_USHORT(port, buffer, count) __outwordstring(H2I(port), buffer, count) 35 + #define WRITE_PORT_BUFFER_ULONG(port, buffer, count) __outdwordstring(H2I(port), buffer, count) 36 + 26 37 /* PROTOTYPES ***************************************************************/ 27 38 28 39 /* hardware.c */
+3
boot/freeldr/freeldr/include/arch/pc/pcbios.h
··· 182 182 IN UCHAR BootDrive OPTIONAL, 183 183 IN ULONG BootPartition OPTIONAL); 184 184 185 + DECLSPEC_NORETURN 185 186 VOID __cdecl Relocator16Boot( 186 187 IN REGS* In, 187 188 IN USHORT StackSegment, ··· 189 190 IN USHORT CodeSegment, 190 191 IN USHORT CodePointer); 191 192 193 + DECLSPEC_NORETURN 192 194 VOID __cdecl Reboot(VOID); 195 + 193 196 VOID DetectHardware(VOID); 194 197 195 198 #endif /* ! __ASM__ */
+3 -1
boot/freeldr/freeldr/include/debug.h
··· 85 85 // 86 86 // You may have as many BREAKPOINT()'s as you like but you may only 87 87 // have up to four of any of the others. 88 - #define BREAKPOINT() __asm__ ("int $3"); 88 + #define BREAKPOINT() __debugbreak() 89 89 void INSTRUCTION_BREAKPOINT1(unsigned long addr); 90 90 void MEMORY_READWRITE_BREAKPOINT1(unsigned long addr); 91 91 void MEMORY_WRITE_BREAKPOINT1(unsigned long addr); ··· 125 125 126 126 #endif // DBG 127 127 128 + DECLSPEC_NORETURN 128 129 void 129 130 NTAPI 130 131 FrLdrBugCheck(ULONG BugCode); 131 132 133 + DECLSPEC_NORETURN 132 134 VOID 133 135 FrLdrBugCheckWithMessage( 134 136 ULONG BugCode,
+1
boot/freeldr/freeldr/include/linux.h
··· 129 129 #include <poppack.h> 130 130 131 131 // Implemented in linux.S 132 + DECLSPEC_NORETURN 132 133 VOID __cdecl 133 134 BootLinuxKernel( 134 135 _In_ ULONG KernelSize,
+14
hal/halx86/include/halp.h
··· 588 588 #define KiEnterInterruptTrap(TrapFrame) /* We do all neccessary in asm code */ 589 589 #endif // _M_AMD64 590 590 591 + #ifdef _MINIHAL_ 592 + #if defined(_M_IX86) || defined(_M_AMD64) 593 + /* Use intrinsics for IA-32 and amd64 */ 594 + #include <ioaccess.h> 595 + 596 + #define READ_PORT_BUFFER_UCHAR(port, buffer, count) __inbytestring(H2I(port), buffer, count) 597 + #define READ_PORT_BUFFER_USHORT(port, buffer, count) __inwordstring(H2I(port), buffer, count) 598 + #define READ_PORT_BUFFER_ULONG(port, buffer, count) __indwordstring(H2I(port), buffer, count) 599 + #define WRITE_PORT_BUFFER_UCHAR(port, buffer, count) __outbytestring(H2I(port), buffer, count) 600 + #define WRITE_PORT_BUFFER_USHORT(port, buffer, count) __outwordstring(H2I(port), buffer, count) 601 + #define WRITE_PORT_BUFFER_ULONG(port, buffer, count) __outdwordstring(H2I(port), buffer, count) 602 + #endif 603 + #endif 604 + 591 605 extern BOOLEAN HalpNMIInProgress; 592 606 593 607 extern ADDRESS_USAGE HalpDefaultIoSpace;
-1
hal/halx86/minihal/CMakeLists.txt
··· 5 5 add_definitions(-D_MINIHAL_) 6 6 7 7 list(APPEND MINI_HAL_SOURCE 8 - ../generic/portio.c 9 8 ../legacy/bus/bushndlr.c 10 9 ../legacy/bus/cmosbus.c 11 10 ../legacy/bus/isabus.c