Ticket #6105: 0001-Initial-OpenFirmware-frame-buffer-support.patch
File 0001-Initial-OpenFirmware-frame-buffer-support.patch, 9.6 KB (added by , 14 years ago) |
---|
-
headers/private/kernel/boot/platform/openfirmware/platform_arch.h
From 174fd3c1ae9cafb7113280b15b0f28662bda3497 Mon Sep 17 00:00:00 2001 From: Andreas Faerber <andreas.faerber@web.de> Date: Mon, 31 May 2010 00:28:27 +0200 Subject: [PATCH] Initial OpenFirmware frame buffer support --- .../boot/platform/openfirmware/platform_arch.h | 4 + src/system/boot/platform/generic/video_blit.cpp | 3 - src/system/boot/platform/generic/video_rle.cpp | 2 - src/system/boot/platform/generic/video_splash.cpp | 3 - src/system/boot/platform/openfirmware/Jamfile | 12 ++- .../boot/platform/openfirmware/arch/ppc/mmu.cpp | 19 ++++ src/system/boot/platform/openfirmware/console.cpp | 4 + src/system/boot/platform/openfirmware/video.cpp | 106 +++++++++++++++++++- 8 files changed, 139 insertions(+), 14 deletions(-) diff --git a/headers/private/kernel/boot/platform/openfirmware/platform_arch.h b/headers/private/kernel/boot/platform/openfirmware/platform_arch.h index 7d21e2a..c420aa7 100644
a b extern "C" { 16 16 17 17 /* memory management */ 18 18 19 // For use with arch_mmu_map_physical_memory() 20 static const uint32 kDefaultPageMode = 0x3; // present, R/W 21 19 22 extern status_t arch_set_callback(void); 20 23 extern void *arch_mmu_allocate(void *address, size_t size, uint8 protection, 21 24 bool exactAddress); 22 25 extern status_t arch_mmu_free(void *address, size_t size); 23 26 extern status_t arch_mmu_init(void); 27 extern addr_t arch_mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint32 mode); 24 28 25 29 /* CPU */ 26 30 -
src/system/boot/platform/generic/video_blit.cpp
diff --git a/src/system/boot/platform/generic/video_blit.cpp b/src/system/boot/platform/generic/video_blit.cpp index 56e45fb..b42ebc7 100644
a b 6 6 */ 7 7 8 8 9 #include "video.h"10 11 9 #include <arch/cpu.h> 12 10 #include <boot/stage2.h> 13 11 #include <boot/platform.h> 14 #include <boot/menu.h>15 12 #include <boot/platform/generic/video.h> 16 13 #include <boot/kernel_args.h> 17 14 -
src/system/boot/platform/generic/video_rle.cpp
diff --git a/src/system/boot/platform/generic/video_rle.cpp b/src/system/boot/platform/generic/video_rle.cpp index 4708da0..b108e7f 100644
a b 6 6 */ 7 7 8 8 9 #include "video.h"10 11 9 #include <arch/cpu.h> 12 10 #include <boot/stage2.h> 13 11 #include <boot/platform.h> -
src/system/boot/platform/generic/video_splash.cpp
diff --git a/src/system/boot/platform/generic/video_splash.cpp b/src/system/boot/platform/generic/video_splash.cpp index 532c856..5b7db9e 100644
a b 6 6 */ 7 7 8 8 9 #include "video.h"10 #include "mmu.h"11 12 9 #include <arch/cpu.h> 13 10 #include <boot/stage2.h> 14 11 #include <boot/platform.h> -
src/system/boot/platform/openfirmware/Jamfile
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 ; 2 2 3 3 SubDirC++Flags -D_BOOT_MODE -fno-rtti ; 4 4 5 local genericPlatformSources = 6 text_menu.cpp 7 video_blit.cpp 8 video_splash.cpp 9 video_rle.cpp 10 ; 11 5 12 KernelMergeObject boot_platform_openfirmware.o : 6 13 console.cpp 7 14 debug.c … … KernelMergeObject boot_platform_openfirmware.o : 19 26 openfirmware.cpp 20 27 openfirmware_devices.cpp 21 28 22 # generic 23 text_menu.cpp 29 $(genericPlatformSources) 24 30 : 25 31 : boot_platform_openfirmware_$(TARGET_ARCH).a 26 32 ; 27 33 28 SEARCH on [ FGristFiles text_menu.cpp]34 SEARCH on [ FGristFiles $(genericPlatformSources) ] 29 35 = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ; 30 36 SEARCH on [ FGristFiles openfirmware.cpp openfirmware_devices.cpp ] 31 37 = [ FDirName $(HAIKU_TOP) src system kernel platform openfirmware ] ; -
src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp
diff --git a/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp b/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp index 48af378..4997b64 100644
a b find_free_virtual_range(void *base, size_t size) 608 608 } 609 609 610 610 611 // TODO: This is a hack identity-mapping the physical memory 612 // since we don't seem to have the concept of next virtual addresses/pages in ppc (yet?) 613 extern "C" addr_t 614 arch_mmu_map_physical_memory(addr_t physicalAddress, size_t size, uint32 mode) 615 { 616 addr_t address = physicalAddress/*sNextVirtualAddress*/; 617 addr_t pageOffset = physicalAddress & (B_PAGE_SIZE - 1); 618 619 physicalAddress -= pageOffset; 620 size += pageOffset; 621 622 for (addr_t offset = 0; offset < size; offset += B_PAGE_SIZE) { 623 map_page((void*)(physicalAddress + offset)/*get_next_virtual_page()*/, (void*)(physicalAddress + offset), mode); 624 } 625 626 return address /*+ pageOffset*/; 627 } 628 629 611 630 extern "C" void * 612 631 arch_mmu_allocate(void *_virtualAddress, size_t size, uint8 _protection, 613 632 bool exactAddress) -
src/system/boot/platform/openfirmware/console.cpp
diff --git a/src/system/boot/platform/openfirmware/console.cpp b/src/system/boot/platform/openfirmware/console.cpp index a639fea..9a9b5ac 100644
a b 8 8 #include <string.h> 9 9 #include <platform/openfirmware/openfirmware.h> 10 10 #include <util/kernel_cpp.h> 11 #include <boot/stage2.h> 11 12 12 13 #include "Handle.h" 13 14 #include "console.h" … … ConsoleHandle::WriteAt(void */*cookie*/, off_t /*pos*/, const void *buffer, 69 70 { 70 71 const char *string = (const char *)buffer; 71 72 73 if (gKernelArgs.frame_buffer.enabled) 74 return bufferSize; 75 72 76 // be nice to our audience and replace single "\n" with "\r\n" 73 77 74 78 while (bufferSize > 0) { -
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 6dbe494..418e57f 100644
a b 1 1 /* 2 2 * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Copyright 2010, Andreas Färber <andreas.faerber@web.de> 3 4 * Distributed under the terms of the MIT License. 4 5 */ 5 6 6 7 8 #include <platform_arch.h> 9 #include <boot/stage2.h> 7 10 #include <boot/platform.h> 11 #include <boot/kernel_args.h> 12 #include <boot/platform/generic/video.h> 13 #include <platform/openfirmware/openfirmware.h> 14 #include <arch_mmu.h> 15 16 17 static int sScreen; 18 static addr_t sFrameBuffer; 19 20 21 void 22 platform_blit4(addr_t frameBuffer, const uint8 *data, 23 uint16 width, uint16 height, uint16 imageWidth, uint16 left, uint16 top) 24 { 25 if (!data) 26 return; 27 // TODO 28 } 29 30 31 extern "C" void 32 platform_set_palette(const uint8 *palette) 33 { 34 switch (gKernelArgs.frame_buffer.depth) { 35 case 8: 36 // TODO try to optimize with set-colors 37 for (int index = 0; index < 256; index++) { 38 of_call_method(sScreen, "color!", 4, 0, index, 39 palette[index * 3 + 2], 40 palette[index * 3 + 1], 41 palette[index * 3 + 0]); 42 } 43 break; 44 default: 45 break; 46 } 47 } 8 48 9 49 10 50 extern "C" void 11 51 platform_switch_to_logo(void) 12 52 { 13 // ToDo: implement me 53 // in debug mode, we'll never show the logo 54 if ((platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) != 0) 55 return; 56 addr_t lastBase = gKernelArgs.frame_buffer.physical_buffer.start; 57 size_t lastSize = gKernelArgs.frame_buffer.physical_buffer.size; 58 59 if (sScreen == OF_FAILED) 60 return; 61 int mode = 0x9; 62 if (of_call_method(sScreen, "set-mode", 1, 0, mode) == OF_FAILED) 63 dprintf("** mode not set!\n"); 64 int depth = 32; 65 if (of_call_method(sScreen, "set-depth", 1, 0, depth) == OF_FAILED) 66 dprintf("** depth not set!\n"); 67 int width, height; 68 if (of_call_method(sScreen, "dimensions", 0, 2, &height, &width) == OF_FAILED) 69 return; 70 int package = of_instance_to_package(sScreen); 71 if (package == OF_FAILED) 72 return; 73 int lineBytes; 74 if (of_getprop(package, "linebytes", &lineBytes, sizeof(int)) == OF_FAILED) 75 return; 76 if (of_getprop(package, "address", &gKernelArgs.frame_buffer.physical_buffer.start, sizeof(int)) == OF_FAILED) 77 return; 78 gKernelArgs.frame_buffer.width = width; 79 gKernelArgs.frame_buffer.height = height; 80 gKernelArgs.frame_buffer.depth = depth; 81 gKernelArgs.frame_buffer.bytes_per_row = lineBytes; 82 gKernelArgs.frame_buffer.physical_buffer.size = lineBytes * height; 83 84 dprintf("video mode: %ux%ux%u\n", gKernelArgs.frame_buffer.width, 85 gKernelArgs.frame_buffer.height, gKernelArgs.frame_buffer.depth); 86 87 gKernelArgs.frame_buffer.enabled = true; 88 89 // If the new frame buffer is either larger than the old one or located at 90 // a different address, we need to remap it, so we first have to throw 91 // away its previous mapping 92 if (lastBase != 0 93 && (lastBase != gKernelArgs.frame_buffer.physical_buffer.start 94 || lastSize < gKernelArgs.frame_buffer.physical_buffer.size)) { 95 arch_mmu_free((void *)sFrameBuffer, lastSize); // XXX not yet implemented 96 lastBase = 0; 97 } 98 if (lastBase == 0) { 99 // the graphics memory has not been mapped yet! 100 sFrameBuffer = arch_mmu_map_physical_memory( 101 gKernelArgs.frame_buffer.physical_buffer.start, 102 gKernelArgs.frame_buffer.physical_buffer.size, kDefaultPageMode); 103 } 104 105 video_display_splash(sFrameBuffer); 14 106 } 15 107 16 108 17 109 extern "C" void 18 110 platform_switch_to_text_mode(void) 19 111 { 20 // ToDo: implement me 112 if (!gKernelArgs.frame_buffer.enabled) 113 return; 114 115 gKernelArgs.frame_buffer.enabled = 0; 21 116 } 22 117 23 118 24 119 extern "C" status_t 25 120 platform_init_video(void) 26 121 { 27 // ToDo: implement me 122 gKernelArgs.frame_buffer.enabled = 0; 123 124 sScreen = of_open("screen"); 125 if (sScreen == OF_FAILED) 126 return B_NO_INIT; 127 28 128 return B_OK; 29 129 } 30 130