diff --git a/headers/private/kernel/util/FixedWidthPointer.h b/headers/private/kernel/util/FixedWidthPointer.h index 56d88afaef..7024b65292 100644 --- a/headers/private/kernel/util/FixedWidthPointer.h +++ b/headers/private/kernel/util/FixedWidthPointer.h @@ -22,17 +22,28 @@ class FixedWidthPointer { public: operator Type*() const { - return (Type *)(addr_t)fValue; + return (Type*)(addr_t)fValue; + } + + template + operator OtherType*() const + { + return static_cast((Type*)(addr_t)fValue); } Type& operator*() const { - return *(Type *)*this; + return *((Type*)(addr_t)fValue); } Type* operator->() const { - return *this; + return (Type*)(addr_t)fValue; + } + + Type& operator[](size_t i) const + { + return ((Type*)(addr_t)fValue)[i]; } FixedWidthPointer& operator=(const FixedWidthPointer& p) diff --git a/src/system/boot/platform/amiga_m68k/start.cpp b/src/system/boot/platform/amiga_m68k/start.cpp index 2356f85fb4..490778e2dd 100644 --- a/src/system/boot/platform/amiga_m68k/start.cpp +++ b/src/system/boot/platform/amiga_m68k/start.cpp @@ -75,7 +75,7 @@ platform_start_kernel(void) = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; preloaded_elf32_image *image = static_cast( - (void *)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); //smp_init_other_cpus(); //serial_cleanup(); diff --git a/src/system/boot/platform/atari_m68k/start.cpp b/src/system/boot/platform/atari_m68k/start.cpp index e03ee4165c..76fd2c733a 100644 --- a/src/system/boot/platform/atari_m68k/start.cpp +++ b/src/system/boot/platform/atari_m68k/start.cpp @@ -75,7 +75,7 @@ platform_start_kernel(void) = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; preloaded_elf32_image *image = static_cast( - (void *)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); //smp_init_other_cpus(); //serial_cleanup(); diff --git a/src/system/boot/platform/bios_ia32/smp.cpp b/src/system/boot/platform/bios_ia32/smp.cpp index af2e64e5db..d4364f7d9d 100644 --- a/src/system/boot/platform/bios_ia32/smp.cpp +++ b/src/system/boot/platform/bios_ia32/smp.cpp @@ -357,7 +357,7 @@ smp_cpu_ready(void) //TRACE(("smp_cpu_ready: entry cpu %ld\n", curr_cpu)); preloaded_elf32_image *image = static_cast( - (void *)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); // Important. Make sure supervisor threads can fault on read only pages... asm("movl %%eax, %%cr0" : : "a" ((1 << 31) | (1 << 16) | (1 << 5) | 1)); diff --git a/src/system/boot/platform/bios_ia32/start.cpp b/src/system/boot/platform/bios_ia32/start.cpp index 82213afccb..41284f608c 100644 --- a/src/system/boot/platform/bios_ia32/start.cpp +++ b/src/system/boot/platform/bios_ia32/start.cpp @@ -83,7 +83,7 @@ platform_start_kernel(void) = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; preloaded_elf32_image *image = static_cast( - (void *)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); smp_init_other_cpus(); debug_cleanup(); diff --git a/src/system/boot/platform/cfe/start.cpp b/src/system/boot/platform/cfe/start.cpp index 20e56a4198..8d72532030 100644 --- a/src/system/boot/platform/cfe/start.cpp +++ b/src/system/boot/platform/cfe/start.cpp @@ -61,7 +61,7 @@ extern "C" void platform_start_kernel(void) { preloaded_elf32_image* image = static_cast( - (void*)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); addr_t kernelEntry = image->elf_header.e_entry; addr_t stackTop = gKernelArgs.cpu_kstack[0].start diff --git a/src/system/boot/platform/openfirmware/start.cpp b/src/system/boot/platform/openfirmware/start.cpp index d895caabcc..d1729ad3c6 100644 --- a/src/system/boot/platform/openfirmware/start.cpp +++ b/src/system/boot/platform/openfirmware/start.cpp @@ -96,7 +96,7 @@ extern "C" void platform_start_kernel(void) { preloaded_elf32_image* image = static_cast( - (void*)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); addr_t kernelEntry = image->elf_header.e_entry; addr_t stackTop = gKernelArgs.cpu_kstack[0].start diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index ffde980117..0f1fa00fcc 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -91,7 +91,7 @@ extern "C" void platform_start_kernel(void) { preloaded_elf32_image *image = static_cast( - (void *)gKernelArgs.kernel_image); + gKernelArgs.kernel_image); addr_t kernelEntry = image->elf_header.e_entry; addr_t stackTop