Ticket #6140: 0008-Add-keyboard-options-for-menu-and-debug-output.patch

File 0008-Add-keyboard-options-for-menu-and-debug-output.patch, 2.4 KB (added by andreasf, 9 years ago)

proposed patch

  • src/system/boot/platform/openfirmware/console.cpp

    From 394a42ea834423d1f70fe2ba859789c709e2a3dc Mon Sep 17 00:00:00 2001
    From: Andreas Faerber <andreas.faerber@web.de>
    Date: Sun, 6 Jun 2010 00:39:19 +0200
    Subject: [PATCH 8/8] Add keyboard options for menu and debug output
    
    ---
     src/system/boot/platform/openfirmware/console.cpp |   11 +++++++++++
     src/system/boot/platform/openfirmware/console.h   |    1 +
     src/system/boot/platform/openfirmware/start.c     |   15 +++++++++++++--
     3 files changed, 25 insertions(+), 2 deletions(-)
    
    diff --git a/src/system/boot/platform/openfirmware/console.cpp b/src/system/boot/platform/openfirmware/console.cpp
    index 9a9b5ac..3af9d76 100644
    a b console_wait_for_key(void)  
    327327    return buffer[0];
    328328}
    329329
     330
     331int
     332console_check_for_key(void)
     333{
     334    char buffer[3];
     335    ssize_t bytesRead = sInput.ReadAt(NULL, 0, buffer, 1);
     336    if (bytesRead <= 0)
     337        return 0;
     338
     339    return buffer[0];
     340}
  • src/system/boot/platform/openfirmware/console.h

    diff --git a/src/system/boot/platform/openfirmware/console.h b/src/system/boot/platform/openfirmware/console.h
    index 487542c..c1a16dd 100644
    a b extern "C" {  
    1212#endif
    1313
    1414extern status_t console_init(void);
     15extern int console_check_for_key(void);
    1516
    1617#ifdef __cplusplus
    1718}
  • src/system/boot/platform/openfirmware/start.c

    diff --git a/src/system/boot/platform/openfirmware/start.c b/src/system/boot/platform/openfirmware/start.c
    index 7a8dc2e..eb9573e 100644
    a b extern uint8 __bss_start;  
    3131extern uint8 _end;
    3232
    3333uint32 gMachine;
     34static uint32 sBootOptions;
    3435
    3536
    3637static void
    platform_exit(void)  
    110111uint32
    111112platform_boot_options(void)
    112113{
    113     // ToDo: implement me!
    114     return 0;
     114    return sBootOptions;
    115115}
    116116
    117117
    start(void *openFirmwareEntry)  
    162162    if (init_real_time_clock() != B_OK)
    163163        of_exit();
    164164
     165    // we need to check for keys once, not for every options inquiry
     166    sBootOptions = 0;
     167    int key = console_check_for_key();
     168    if (key == 32) {
     169        // space bar: option menu
     170        sBootOptions |= BOOT_OPTION_MENU;
     171    } else if (key == 27) {
     172        // ESC: debug output
     173        sBootOptions |= BOOT_OPTION_DEBUG_OUTPUT;
     174    }
     175
    165176    gKernelArgs.platform_args.openfirmware_entry = openFirmwareEntry;
    166177
    167178    main(&args);