Support static_cast on FixedWidthPointer.

This commit is contained in:
Alex Smith 2012-06-22 19:55:38 +01:00
parent f124497815
commit 3a2a3367dc
8 changed files with 21 additions and 10 deletions

View File

@ -22,17 +22,28 @@ class FixedWidthPointer {
public:
operator Type*() const
{
return (Type *)(addr_t)fValue;
return (Type*)(addr_t)fValue;
}
template<typename OtherType>
operator OtherType*() const
{
return static_cast<OtherType*>((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)

View File

@ -75,7 +75,7 @@ platform_start_kernel(void)
= gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size;
preloaded_elf32_image *image = static_cast<preloaded_elf32_image *>(
(void *)gKernelArgs.kernel_image);
gKernelArgs.kernel_image);
//smp_init_other_cpus();
//serial_cleanup();

View File

@ -75,7 +75,7 @@ platform_start_kernel(void)
= gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size;
preloaded_elf32_image *image = static_cast<preloaded_elf32_image *>(
(void *)gKernelArgs.kernel_image);
gKernelArgs.kernel_image);
//smp_init_other_cpus();
//serial_cleanup();

View File

@ -357,7 +357,7 @@ smp_cpu_ready(void)
//TRACE(("smp_cpu_ready: entry cpu %ld\n", curr_cpu));
preloaded_elf32_image *image = static_cast<preloaded_elf32_image *>(
(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));

View File

@ -83,7 +83,7 @@ platform_start_kernel(void)
= gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size;
preloaded_elf32_image *image = static_cast<preloaded_elf32_image *>(
(void *)gKernelArgs.kernel_image);
gKernelArgs.kernel_image);
smp_init_other_cpus();
debug_cleanup();

View File

@ -61,7 +61,7 @@ extern "C" void
platform_start_kernel(void)
{
preloaded_elf32_image* image = static_cast<preloaded_elf32_image*>(
(void*)gKernelArgs.kernel_image);
gKernelArgs.kernel_image);
addr_t kernelEntry = image->elf_header.e_entry;
addr_t stackTop = gKernelArgs.cpu_kstack[0].start

View File

@ -96,7 +96,7 @@ extern "C" void
platform_start_kernel(void)
{
preloaded_elf32_image* image = static_cast<preloaded_elf32_image*>(
(void*)gKernelArgs.kernel_image);
gKernelArgs.kernel_image);
addr_t kernelEntry = image->elf_header.e_entry;
addr_t stackTop = gKernelArgs.cpu_kstack[0].start

View File

@ -91,7 +91,7 @@ extern "C" void
platform_start_kernel(void)
{
preloaded_elf32_image *image = static_cast<preloaded_elf32_image *>(
(void *)gKernelArgs.kernel_image);
gKernelArgs.kernel_image);
addr_t kernelEntry = image->elf_header.e_entry;
addr_t stackTop