From 36ee6a873142e9a493ebf52c9d050afce5d7d147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 22 Aug 2010 01:56:40 +0000 Subject: [PATCH] boot_loader_openfirmware: Add frame buffer support Use the OF "screen" device alias to query frame buffer properties. Postpone the opening of the device as far as possible as it erases the screen output. Initialize the kernel arguments and hook into generic code to display the splash screen. Like on x86, the frame buffer is enabled by default. To disable it, either press ESC during early boot or, for debugging, make sure in start.cpp that platform_boot_options() has the BOOT_OPTION_DEBUG_OUTPUT flag set. Resolves ticket #6105. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38306 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/openfirmware/Jamfile | 3 + .../boot/platform/openfirmware/video.cpp | 76 ++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/system/boot/platform/openfirmware/Jamfile b/src/system/boot/platform/openfirmware/Jamfile index 6ddb5b3a16..7a69ae00a7 100644 --- a/src/system/boot/platform/openfirmware/Jamfile +++ b/src/system/boot/platform/openfirmware/Jamfile @@ -4,6 +4,9 @@ SubDirC++Flags -D_BOOT_MODE -fno-rtti ; local genericPlatformSources = text_menu.cpp + video_blit.cpp + video_rle.cpp + video_splash.cpp ; KernelMergeObject boot_platform_openfirmware.o : diff --git a/src/system/boot/platform/openfirmware/video.cpp b/src/system/boot/platform/openfirmware/video.cpp index 6711ac7b08..8082a91aec 100644 --- a/src/system/boot/platform/openfirmware/video.cpp +++ b/src/system/boot/platform/openfirmware/video.cpp @@ -7,6 +7,40 @@ #include #include +#include +#include + + +static int sScreen; + + +void +platform_blit4(addr_t frameBuffer, const uint8 *data, + uint16 width, uint16 height, uint16 imageWidth, uint16 left, uint16 top) +{ + panic("platform_blit4(): not implemented\n"); +} + + +extern "C" void +platform_set_palette(const uint8 *palette) +{ + switch (gKernelArgs.frame_buffer.depth) { + case 8: + if (of_call_method(sScreen, "set-colors", 3, 0, + 256, 0, palette) == OF_FAILED) { + for (int index = 0; index < 256; index++) { + of_call_method(sScreen, "color!", 4, 0, index, + palette[index * 3 + 2], + palette[index * 3 + 1], + palette[index * 3 + 0]); + } + } + break; + default: + break; + } +} extern "C" void @@ -16,7 +50,46 @@ platform_switch_to_logo(void) if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) != 0) return; - // ToDo: implement me + sScreen = of_open("screen"); + if (sScreen == OF_FAILED) + return; + + int package = of_instance_to_package(sScreen); + if (package == OF_FAILED) + return; + uint32 width, height; + if (of_call_method(sScreen, "dimensions", 0, 2, &height, &width) + == OF_FAILED) { + if (of_getprop(package, "width", &width, sizeof(int32)) == OF_FAILED) + return; + if (of_getprop(package, "height", &height, sizeof(int32)) == OF_FAILED) + return; + } + uint32 depth; + if (of_getprop(package, "depth", &depth, sizeof(uint32)) == OF_FAILED) + return; + uint32 lineBytes; + if (of_getprop(package, "linebytes", &lineBytes, sizeof(uint32)) + == OF_FAILED) + return; + uint32 address; + // address is always 32 bit + if (of_getprop(package, "address", &address, sizeof(uint32)) == OF_FAILED) + return; + gKernelArgs.frame_buffer.physical_buffer.start = address; + gKernelArgs.frame_buffer.physical_buffer.size = lineBytes * height; + gKernelArgs.frame_buffer.width = width; + gKernelArgs.frame_buffer.height = height; + gKernelArgs.frame_buffer.depth = depth; + gKernelArgs.frame_buffer.bytes_per_row = lineBytes; + + dprintf("video mode: %ux%ux%u\n", gKernelArgs.frame_buffer.width, + gKernelArgs.frame_buffer.height, gKernelArgs.frame_buffer.depth); + + gKernelArgs.frame_buffer.enabled = true; + + // the memory will be identity-mapped already + video_display_splash(gKernelArgs.frame_buffer.physical_buffer.start); } @@ -38,7 +111,6 @@ platform_init_video(void) { gKernelArgs.frame_buffer.enabled = false; - // ToDo: implement me return B_OK; }