Ticket #6105: 0004-OpenFirmware-Add-frame-buffer-support.2.patch

File 0004-OpenFirmware-Add-frame-buffer-support.2.patch, 4.4 KB (added by andreasf, 10 years ago)

proposed patch: add frame buffer support

  • src/system/boot/platform/openfirmware/Jamfile

    From 85ffb73ec345d7f66db9be6771806ce9c1bb51b0 Mon Sep 17 00:00:00 2001
    From: Andreas Faerber <andreas.faerber@web.de>
    Date: Tue, 1 Jun 2010 19:15:59 +0200
    Subject: [PATCH 4/7] OpenFirmware: Add frame buffer support
    
    ---
     src/system/boot/platform/openfirmware/Jamfile   |   12 +++-
     src/system/boot/platform/openfirmware/video.cpp |   77 ++++++++++++++++++++++-
     2 files changed, 84 insertions(+), 5 deletions(-)
    
    diff --git a/src/system/boot/platform/openfirmware/Jamfile b/src/system/boot/platform/openfirmware/Jamfile
    index 00c2b6d..bf3785c 100644
    a b SubDir HAIKU_TOP src system boot platform openfirmware ;  
    22
    33SubDirC++Flags -D_BOOT_MODE -fno-rtti ;
    44
     5local genericPlatformSources =
     6    text_menu.cpp
     7    video_blit.cpp
     8    video_splash.cpp
     9    video_rle.cpp
     10;
     11
    512KernelMergeObject boot_platform_openfirmware.o :
    613    console.cpp
    714    debug.c
    KernelMergeObject boot_platform_openfirmware.o :  
    1926    openfirmware.cpp
    2027    openfirmware_devices.cpp
    2128
    22     # generic
    23     text_menu.cpp
     29    $(genericPlatformSources)
    2430    :
    2531    : boot_platform_openfirmware_$(TARGET_ARCH).a
    2632;
    2733
    28 SEARCH on [ FGristFiles text_menu.cpp ]
     34SEARCH on [ FGristFiles $(genericPlatformSources) ]
    2935    = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ;
    3036SEARCH on [ FGristFiles openfirmware.cpp openfirmware_devices.cpp ]
    3137    = [ FDirName $(HAIKU_TOP) src system kernel platform openfirmware ] ;
  • src/system/boot/platform/openfirmware/video.cpp

    diff --git a/src/system/boot/platform/openfirmware/video.cpp b/src/system/boot/platform/openfirmware/video.cpp
    index a2ff181..4b7575f 100644
    a b  
    11/*
    22 * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
     3 * Copyright 2010, Andreas Färber <andreas.faerber@web.de>
    34 * Distributed under the terms of the MIT License.
    45 */
    56
    67
    78#include <boot/stage2.h>
    89#include <boot/platform.h>
     10#include <boot/platform/generic/video.h>
     11#include <platform/openfirmware/openfirmware.h>
     12
     13
     14static int sScreen;
     15
     16
     17void
     18platform_blit4(addr_t frameBuffer, const uint8 *data,
     19    uint16 width, uint16 height, uint16 imageWidth, uint16 left, uint16 top)
     20{
     21    if (!data)
     22        return;
     23    // TODO
     24}
     25
     26
     27extern "C" void
     28platform_set_palette(const uint8 *palette)
     29{
     30    switch (gKernelArgs.frame_buffer.depth) {
     31        case 8:
     32            if (of_call_method(sScreen, "set-colors", 3, 0,
     33                    256, 0, palette) == OF_FAILED) {
     34                for (int index = 0; index < 256; index++) {
     35                    of_call_method(sScreen, "color!", 4, 0, index,
     36                        palette[index * 3 + 2],
     37                        palette[index * 3 + 1],
     38                        palette[index * 3 + 0]);
     39                }
     40            }
     41            break;
     42        default:
     43            break;
     44    }
     45}
    946
    1047
    1148extern "C" void
    platform_switch_to_logo(void)  
    1552    if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) != 0)
    1653        return;
    1754
    18     // ToDo: implement me
     55    sScreen = of_open("screen");
     56    if (sScreen == OF_FAILED)
     57        return;
     58    int package = of_instance_to_package(sScreen);
     59    if (package == OF_FAILED)
     60        return;
     61    int width, height;
     62    if (of_call_method(sScreen, "dimensions", 0, 2, &height, &width)
     63            == OF_FAILED) {
     64        if (of_getprop(package, "width", &width, sizeof(int)) == OF_FAILED)
     65            return;
     66        if (of_getprop(package, "height", &height, sizeof(int)) == OF_FAILED)
     67            return;
     68    }
     69    int depth;
     70    if (of_getprop(package, "depth", &depth, sizeof(int)) == OF_FAILED)
     71        return;
     72    int lineBytes;
     73    if (of_getprop(package, "linebytes", &lineBytes, sizeof(int))
     74            == OF_FAILED)
     75        return;
     76    uint32 address; // always 32 bit
     77    if (of_getprop(package, "address", &address, sizeof(uint32)) == OF_FAILED)
     78        return;
     79    gKernelArgs.frame_buffer.physical_buffer.start = address;
     80    gKernelArgs.frame_buffer.physical_buffer.size = lineBytes * height;
     81    gKernelArgs.frame_buffer.width = width;
     82    gKernelArgs.frame_buffer.height = height;
     83    gKernelArgs.frame_buffer.depth = depth;
     84    gKernelArgs.frame_buffer.bytes_per_row = lineBytes;
     85
     86    dprintf("video mode: %ux%ux%u\n", gKernelArgs.frame_buffer.width,
     87        gKernelArgs.frame_buffer.height, gKernelArgs.frame_buffer.depth);
     88
     89    gKernelArgs.frame_buffer.enabled = true;
     90
     91    // the memory will be identity-mapped already
     92    video_display_splash(gKernelArgs.frame_buffer.physical_buffer.start);
    1993}
    2094
    2195
    platform_init_video(void)  
    34108{
    35109    gKernelArgs.frame_buffer.enabled = 0;
    36110
    37     // ToDo: implement me
    38111    return B_OK;
    39112}
    40113