diff --git a/src/system/boot/platform/amiga_m68k/console.cpp b/src/system/boot/platform/amiga_m68k/console.cpp new file mode 100644 index 0000000000..98375b61f2 --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/console.cpp @@ -0,0 +1,81 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT license. + * + * Author: + * François Revol, revol@free.fr. + */ + +#include +#include +#include "toscalls.h" +#include + +#include "Handle.h" +#include "console.h" +#include "keyboard.h" + + +FILE *stdin, *stdout, *stderr; + + + +// #pragma mark - + + +status_t +console_init(void) +{ + //TODO + + return B_OK; +} + + +// #pragma mark - + + +void +console_clear_screen(void) +{ + //TODO +} + + +int32 +console_width(void) +{ + int columnCount = 80; //XXX: check video mode + return columnCount; +} + + +int32 +console_height(void) +{ + int lineCount = 25; //XXX: check video mode + return lineCount; +} + + +void +console_set_cursor(int32 x, int32 y) +{ + //TODO +} + + +void +console_set_color(int32 foreground, int32 background) +{ + //TODO +} + + +int +console_wait_for_key(void) +{ + //TODO + return 0; +} + diff --git a/src/system/boot/platform/amiga_m68k/console.h b/src/system/boot/platform/amiga_m68k/console.h new file mode 100644 index 0000000000..216c923cfd --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/console.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 CONSOLE_H +#define CONSOLE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern status_t console_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* CONSOLE_H */ diff --git a/src/system/boot/platform/amiga_m68k/cpu.cpp b/src/system/boot/platform/amiga_m68k/cpu.cpp new file mode 100644 index 0000000000..21623ac8c3 --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/cpu.cpp @@ -0,0 +1,74 @@ +/* + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + * + * calculate_cpu_conversion_factor() was written by Travis Geiselbrecht and + * licensed under the NewOS license. + */ + + +#include "cpu.h" +#include "amicalls.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +//#define TRACE_CPU +#ifdef TRACE_CPU +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + +#warning M68K: add set_vbr() + + +static status_t +check_cpu_features() +{ + //TODO + return B_ERROR; +} + +#warning M68K: move and implement system_time() +static bigtime_t gSystemTimeCounter = 0; //HACK +extern "C" bigtime_t +system_time(void) +{ + return gSystemTimeCounter++; +} + + +// #pragma mark - + + +extern "C" void +spin(bigtime_t microseconds) +{ + bigtime_t time = system_time(); + while ((system_time() - time) < microseconds) + asm volatile ("nop;"); +} + + +extern "C" void +cpu_init() +{ + if (check_cpu_features() != B_OK) + panic("You need a 68020 or higher in order to boot!\n"); + + gKernelArgs.num_cpus = 1; + // this will eventually be corrected later on + // ...or not! +} + diff --git a/src/system/boot/platform/amiga_m68k/cpu.h b/src/system/boot/platform/amiga_m68k/cpu.h new file mode 100644 index 0000000000..f8eff4f44a --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/cpu.h @@ -0,0 +1,22 @@ +/* + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef CPU_H +#define CPU_H + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void cpu_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_H */ diff --git a/src/system/boot/platform/amiga_m68k/debug.cpp b/src/system/boot/platform/amiga_m68k/debug.cpp new file mode 100644 index 0000000000..e3a4d1602c --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/debug.cpp @@ -0,0 +1,66 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include "keyboard.h" +#include "amicalls.h" + +#include +#include +#include + +#include + +/*! This works only after console_init() was called. +*/ +void +panic(const char *format, ...) +{ + struct AlertMessage { + UWORD column; + UBYTE line; + char messages[14+512]; + } alert = { + 10, 12, + "*** PANIC ***" + } + + const char greetings[] = "\n*** PANIC ***"; + char *buffer = &alert.messages[14]; + va_list list; + + //platform_switch_to_text_mode(); + + memset(buffer, 512); + + va_start(list, format); + vsnprintf(buffer, 512-1, format, list); + va_end(list); + + DisplayAlert(DEADEND_ALERT, &alert, 30); + + clear_key_buffer(); + wait_for_key(); + platform_exit(); +} + + +void +dprintf(const char *format, ...) +{ + char buffer[512]; + va_list list; + + va_start(list, format); + vsnprintf(buffer, sizeof(buffer), format, list); + va_end(list); + +// Bconput(DEV_AUX, buffer); + + //if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) +// Bconput(DEV_CONSOLE, buffer); +} + + diff --git a/src/system/boot/platform/amiga_m68k/devices.cpp b/src/system/boot/platform/amiga_m68k/devices.cpp new file mode 100644 index 0000000000..9a3fed04df --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/devices.cpp @@ -0,0 +1,78 @@ +/* + * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include +#include +#include + +#include + +#include "Handle.h" +#include "amicalls.h" + +//#define TRACE_DEVICES +#ifdef TRACE_DEVICES +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +// exported from shell.S +extern uint8 gBootedFromImage; +extern uint8 gBootDriveAPI; // ATARI_BOOT_DRIVE_API_* +extern uint8 gBootDriveID; +extern uint32 gBootPartitionOffset; + +#define SCRATCH_SIZE (2*4096) +static uint8 gScratchBuffer[SCRATCH_SIZE]; + + +// #pragma mark - + + +status_t +platform_add_boot_device(struct stage2_args *args, NodeList *devicesList) +{ + TRACE(("boot drive ID: %x\n", gBootDriveID)); + +//TODO + gKernelArgs.boot_volume.SetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, + gBootedFromImage); + + return B_OK; +} + + +status_t +platform_get_boot_partition(struct stage2_args *args, Node *bootDevice, + NodeList *list, boot::Partition **_partition) +{ + +//TODO + + return B_ENTRY_NOT_FOUND; +} + + +status_t +platform_add_block_devices(stage2_args *args, NodeList *devicesList) +{ +//TODO + return B_ERROR; +} + + +status_t +platform_register_boot_device(Node *device) +{ +//TODO + + return B_OK; +} + diff --git a/src/system/boot/platform/amiga_m68k/video.cpp b/src/system/boot/platform/amiga_m68k/video.cpp new file mode 100644 index 0000000000..ed30c2a7b0 --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/video.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include "amicalls.h" +#include "video.h" +//#include "mmu.h" +//#include "images.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +//#define TRACE_VIDEO +#ifdef TRACE_VIDEO +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + + +// #pragma mark - + + +bool +video_mode_hook(Menu *menu, MenuItem *item) +{ + // nothing yet + return true; +} + + +Menu * +video_mode_menu() +{ + return NULL; +} + + +// #pragma mark - + + +extern "C" void +platform_switch_to_logo(void) +{ + // TODO: implement me +} + + +extern "C" void +platform_switch_to_text_mode(void) +{ + // TODO: implement me +} + + +extern "C" status_t +platform_init_video(void) +{ + // TODO: implement me + return B_OK; +} + diff --git a/src/system/boot/platform/amiga_m68k/video.h b/src/system/boot/platform/amiga_m68k/video.h new file mode 100644 index 0000000000..37cd88782c --- /dev/null +++ b/src/system/boot/platform/amiga_m68k/video.h @@ -0,0 +1,18 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ +#ifndef VIDEO_H +#define VIDEO_H + + +#include + + +class Menu; +class MenuItem; + +bool video_mode_hook(Menu *menu, MenuItem *item); +Menu *video_mode_menu(); + +#endif /* VIDEO_H */