From 6152d8f58bda2d98b826b140e9560e13b40b60a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Tue, 1 Jan 2008 18:28:26 +0000 Subject: [PATCH] Some atari boot code git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23205 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/atari_m68k/Jamfile | 53 +++++++++++++ src/system/boot/platform/atari_m68k/bios.h | 42 ++++++++++ src/system/boot/platform/atari_m68k/debug.c | 54 +++++++++++++ src/system/boot/platform/atari_m68k/gemdos.h | 24 ++++++ .../boot/platform/atari_m68k/keyboard.cpp | 78 +++++++++++++++++++ .../boot/platform/atari_m68k/keyboard.h | 38 +++++++++ src/system/boot/platform/atari_m68k/menu.cpp | 66 ++++++++++++++++ src/system/boot/platform/atari_m68k/xbios.h | 18 +++++ 8 files changed, 373 insertions(+) create mode 100644 src/system/boot/platform/atari_m68k/Jamfile create mode 100644 src/system/boot/platform/atari_m68k/bios.h create mode 100644 src/system/boot/platform/atari_m68k/debug.c create mode 100644 src/system/boot/platform/atari_m68k/gemdos.h create mode 100644 src/system/boot/platform/atari_m68k/keyboard.cpp create mode 100644 src/system/boot/platform/atari_m68k/keyboard.h create mode 100644 src/system/boot/platform/atari_m68k/menu.cpp create mode 100644 src/system/boot/platform/atari_m68k/xbios.h diff --git a/src/system/boot/platform/atari_m68k/Jamfile b/src/system/boot/platform/atari_m68k/Jamfile new file mode 100644 index 0000000000..dee4790ef0 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/Jamfile @@ -0,0 +1,53 @@ +SubDir HAIKU_TOP src system boot platform atari_m68k ; + +SubDirHdrs $(HAIKU_TOP) headers private kernel boot platform $(TARGET_BOOT_PLATFORM) ; + +UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; +UsePrivateHeaders [ FDirName graphics common ] ; +#UsePrivateHeaders [ FDirName graphics vesa ] ; +UsePrivateHeaders [ FDirName storage ] ; + +{ + local defines = _BOOT_MODE ; + + defines = [ FDefines $(defines) ] ; + SubDirCcFlags $(defines) -Wall -Wno-multichar ; + SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ; +} + +#SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ; + +KernelMergeObject boot_platform_atari_m68k.o : + shell.S + start.c + debug.c + bios.S + console.cpp + serial.cpp + devices.cpp + keyboard.cpp + menu.cpp + mmu.cpp + cpu.cpp + smp.cpp + smp_trampoline.S + support.S + video.cpp + apm.cpp + + # generic + text_menu.cpp + + # VESA/DDC EDID + #decode_edid.c + #dump_edid.c + + : -fno-pic +; + +SEARCH on [ FGristFiles text_menu.cpp ] + = [ FDirName $(HAIKU_TOP) src system boot platform generic ] ; + +# Tell the build system to where stage1.bin can be found, so it can be used +# elsewhere. +SEARCH on stage1.bin = $(SUBDIR) ; diff --git a/src/system/boot/platform/atari_m68k/bios.h b/src/system/boot/platform/atari_m68k/bios.h new file mode 100644 index 0000000000..cfdbcdb549 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/bios.h @@ -0,0 +1,42 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT license. + * + * Author: + * François Revol, revol@free.fr. + */ +#ifndef _BIOS_H +#define _BIOS_H + +/* + * Atari BIOS calls + */ + +#define BIOS_TRAP XXX + +// BIOSxxx...: x: param type {W|L} + +#define BIOS(nr) \ +({ uint32 ret; \ +asm volatile ( \ +" move #%0,-(sp)\n" \ +" trap #" #BIOS_TRAP "\n" \ +" add.l #2,sp" \ +:: "=r"(ret)); \ +ret; }) + +#define BIOSW(nr, w0) \ +({ uint32 ret; \ +asm volatile ( \ +" move.w %1,-(sp)\n" \ +" move #" #nr ",-(sp)\n" \ +" trap #" #BIOS_TRAP "\n" \ +" add.l #2,sp" \ +:: "=r"(ret)); \ +ret; }) + +#define Bconin(p0) (uint32)BIOSW(2, p0) +//XXX nparams ? +#define Kbshift(p0) (uint32)BIOSW(11, p0) + +#endif /* _BIOS_H */ diff --git a/src/system/boot/platform/atari_m68k/debug.c b/src/system/boot/platform/atari_m68k/debug.c new file mode 100644 index 0000000000..79c8cc3e8c --- /dev/null +++ b/src/system/boot/platform/atari_m68k/debug.c @@ -0,0 +1,54 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include "serial.h" +#include "keyboard.h" + +#include +#include +#include + + +/*! This works only after console_init() was called. +*/ +void +panic(const char *format, ...) +{ + va_list list; + + platform_switch_to_text_mode(); + + puts("*** PANIC ***"); + + va_start(list, format); + vprintf(format, list); + va_end(list); + + puts("\nPress key to reboot."); + + clear_key_buffer(); + wait_for_key(); + platform_exit(); +} + + +void +dprintf(const char *format, ...) +{ + char buffer[512]; + va_list list; + int length; + + va_start(list, format); + length = vsnprintf(buffer, sizeof(buffer), format, list); + va_end(list); + + serial_puts(buffer, length); + + if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) + fprintf(stderr, "%s", buffer); +} + diff --git a/src/system/boot/platform/atari_m68k/gemdos.h b/src/system/boot/platform/atari_m68k/gemdos.h new file mode 100644 index 0000000000..ba29b4ea9e --- /dev/null +++ b/src/system/boot/platform/atari_m68k/gemdos.h @@ -0,0 +1,24 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT license. + * + * Author: + * François Revol, revol@free.fr. + */ +#ifndef _GEMDOS_H +#define _GEMDOS_H + +/* + * Atari GEMDOS calls + */ + +#define GEMDOS_TRAP 1 + +// official names +#define Cconin() GEMDOS(1) + +// check for names +#define supexec() GEMDOS(0x20) +#define terminate() GEMDOS(0) + +#endif /* _GEMDOS_H */ diff --git a/src/system/boot/platform/atari_m68k/keyboard.cpp b/src/system/boot/platform/atari_m68k/keyboard.cpp new file mode 100644 index 0000000000..cf28868683 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/keyboard.cpp @@ -0,0 +1,78 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include "keyboard.h" +#include "bios.h" + +#include + + +static uint16 +check_for_key(void) +{ +//XXX: non blocking in ? +#if 0 + bios_regs regs; + regs.eax = 0x0100; + call_bios(0x16, ®s); + + // the zero flag is set when there is no key stroke waiting for us + if (regs.flags & ZERO_FLAG) + return 0; + + // remove the key from the buffer + regs.eax = 0; + call_bios(0x16, ®s); + + return regs.eax & 0xffff; +#endif + return 0; +} + + +extern "C" void +clear_key_buffer(void) +{ + while (check_for_key() != 0) + ; +} + + +extern "C" union key +wait_for_key(void) +{ + union key key; + key.d0 = Bconin(2); + + return key; +} + + +extern "C" uint32 +check_for_boot_keys(void) +{ + union key key; + uint32 options = 0; + + while ((key.ax = check_for_key()) != 0) { + switch (key.code.ascii) { + case ' ': + options |= BOOT_OPTION_MENU; + break; + case 0x1b: // escape + options |= BOOT_OPTION_DEBUG_OUTPUT; + break; + case 0: + // evaluate BIOS scan codes + // ... + break; + } + } + + dprintf("options = %ld\n", options); + return options; +} + diff --git a/src/system/boot/platform/atari_m68k/keyboard.h b/src/system/boot/platform/atari_m68k/keyboard.h new file mode 100644 index 0000000000..dec5f19e05 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/keyboard.h @@ -0,0 +1,38 @@ +#ifndef KEYBOARD_H +#define KEYBOARD_H + + +#include + + +union key { + uint32 d0; + struct { + uint16 bios; // scan code + uint16 ascii; + } code; +}; + +#define BIOS_KEY_UP 0x48 +#define BIOS_KEY_DOWN 0x50 +#define BIOS_KEY_LEFT 0x4b +#define BIOS_KEY_RIGHT 0x4d +// XXX: FIXME +#define BIOS_KEY_HOME 0x47 +#define BIOS_KEY_END 0x4f +#define BIOS_KEY_PAGE_UP 0x49 +#define BIOS_KEY_PAGE_DOWN 0x51 + +#ifdef __cplusplus +extern "C" { +#endif + +extern void clear_key_buffer(void); +extern union key wait_for_key(void); +extern uint32 check_for_boot_keys(void); + +#ifdef __cplusplus +} +#endif + +#endif /* KEYBOARD_H */ diff --git a/src/system/boot/platform/atari_m68k/menu.cpp b/src/system/boot/platform/atari_m68k/menu.cpp new file mode 100644 index 0000000000..d2e6014bee --- /dev/null +++ b/src/system/boot/platform/atari_m68k/menu.cpp @@ -0,0 +1,66 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "smp.h" +#include "video.h" + +#include +#include +#include + + +void +platform_add_menus(Menu *menu) +{ + MenuItem *item; + + switch (menu->Type()) { + case MAIN_MENU: + menu->AddItem(item = new(nothrow) MenuItem("Select fail-safe video mode", video_mode_menu())); + item->SetTarget(video_mode_hook); + break; + case SAFE_MODE_MENU: + menu->AddItem(item = new(nothrow) MenuItem("Use fail-safe video mode")); + item->SetType(MENU_ITEM_MARKABLE); + item->SetData(B_SAFEMODE_FAIL_SAFE_VIDEO_MODE); + item->SetHelpText("The system will use VESA mode and won't try to open any video graphics driver"); + + smp_add_safemode_menus(menu); + +#if 0 + menu->AddItem(item = new(nothrow) MenuItem("Don't call the BIOS")); + item->SetType(MENU_ITEM_MARKABLE); + + menu->AddItem(item = new(nothrow) MenuItem("Disable APM")); + item->SetType(MENU_ITEM_MARKABLE); + item->SetData("disable_apm"); + item->SetHelpText("This overrides the APM setting in the kernel settings file"); + + menu->AddItem(item = new(nothrow) MenuItem("Disable ACPI")); + item->SetType(MENU_ITEM_MARKABLE); + item->SetData(B_SAFEMODE_DISABLE_ACPI); + item->SetHelpText("This overrides the ACPI setting in the kernel settings file"); +#endif + break; + default: + break; + } +} + + +void +platform_update_menu_item(Menu *menu, MenuItem *item) +{ + platform_generic_update_text_menu_item(menu, item); +} + + +void +platform_run_menu(Menu *menu) +{ + platform_generic_run_text_menu(menu); +} + diff --git a/src/system/boot/platform/atari_m68k/xbios.h b/src/system/boot/platform/atari_m68k/xbios.h new file mode 100644 index 0000000000..97245b5208 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/xbios.h @@ -0,0 +1,18 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT license. + * + * Author: + * François Revol, revol@free.fr. + */ +#ifndef _XBIOS_H +#define _XBIOS_H + +/* + * Atari XBIOS calls + */ + +#define BIOS_TRAP 14 +//#define GEMDOS_TRAP 1 + +#endif /* _XBIOS_H */