From 7d59553ec8cf1faad6326bc7bf4fdb0cc7767408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 17 Jan 2008 09:00:27 +0000 Subject: [PATCH] * As we use asm macros we don't need the asm stubs now. * Put cookies and error stuff to toscalls.c. * dump all cookies instead of fixed list. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23582 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/atari_m68k/Jamfile | 2 +- src/system/boot/platform/atari_m68k/debug.c | 110 ---------------- .../boot/platform/atari_m68k/toscalls.S | 46 ------- .../boot/platform/atari_m68k/toscalls.c | 123 ++++++++++++++++++ 4 files changed, 124 insertions(+), 157 deletions(-) delete mode 100644 src/system/boot/platform/atari_m68k/toscalls.S create mode 100644 src/system/boot/platform/atari_m68k/toscalls.c diff --git a/src/system/boot/platform/atari_m68k/Jamfile b/src/system/boot/platform/atari_m68k/Jamfile index 9d076727c9..3bb4b895bc 100644 --- a/src/system/boot/platform/atari_m68k/Jamfile +++ b/src/system/boot/platform/atari_m68k/Jamfile @@ -26,7 +26,7 @@ KernelMergeObject boot_platform_atari_m68k_shell.o : KernelMergeObject boot_platform_atari_m68k_other.o : # shell.S start.c - toscalls.S + toscalls.c debug.c #bios.S console.cpp diff --git a/src/system/boot/platform/atari_m68k/debug.c b/src/system/boot/platform/atari_m68k/debug.c index d97a65756c..05cc3b0f04 100644 --- a/src/system/boot/platform/atari_m68k/debug.c +++ b/src/system/boot/platform/atari_m68k/debug.c @@ -58,113 +58,3 @@ dprintf(const char *format, ...) } -/*! Maps TOS error codes to native errors - */ -status_t toserror(int32 err) -{ - // generated from: - // http://www.fortunecity.com/skyscraper/apple/308/html/appendd.htm - // with: - // while read N; do read V; read L; echo -e "\tcase $V: /* $N - $L */\n\t\treturn EINVAL;"; done >> errs - switch (err) { - /* BIOS errors */ - case 0: /* E_OK - No error */ - return B_OK; - case -1: /* ERROR - Generic error */ - return B_ERROR; - case -2: /* EDRVNR - Drive not ready */ - return B_DEV_NOT_READY; - case -3: /* EUNCMD - Unknown command */ - return EINVAL; //XXX - case -4: /* E_CRC - CRC error */ - return B_DEV_CRC_ERROR; - case -5: /* EBADRQ - Bad request */ - return EINVAL; //XXX - case -6: /* E_SEEK - Seek error */ - return B_DEV_SEEK_ERROR; - case -7: /* EMEDIA - Unknown media */ - return B_DEV_UNREADABLE; - case -8: /* ESECNF - Sector not found */ - return B_DEV_FORMAT_ERROR; - case -9: /* EPAPER - Out of paper */ - return ENODEV; - case -10: /* EWRITF - Write fault */ - return B_DEV_WRITE_ERROR; - case -11: /* EREADF - Read fault */ - return B_DEV_READ_ERROR; - case -12: /* EWRPRO - Device is write protected */ - return B_READ_ONLY_DEVICE; - case -14: /* E_CHNG - Media change detected */ - return B_DEV_MEDIA_CHANGED; - case -15: /* EUNDEV - Unknown device */ - return B_DEV_BAD_DRIVE_NUM; - case -16: /* EBADSF - Bad sectors on format */ - return B_DEV_UNREADABLE; - case -17: /* EOTHER - Insert other disk (request) */ - return B_DEV_MEDIA_CHANGE_REQUESTED; - /* GEMDOS errors */ - case -32: /* EINVFN - Invalid function */ - return EINVAL; - case -33: /* EFILNF - File not found */ - return B_FILE_NOT_FOUND; - case -34: /* EPTHNF - Path not found */ - return B_ENTRY_NOT_FOUND; - case -35: /* ENHNDL - No more handles */ - return B_NO_MORE_FDS; - case -36: /* EACCDN - Access denied */ - return EACCES; - case -37: /* EIHNDL - Invalid handle */ - return EBADF; - case -39: /* ENSMEM - Insufficient memory */ - return ENOMEM; - case -40: /* EIMBA - Invalid memory block address */ - return EFAULT; - case -46: /* EDRIVE - Invalid drive specification */ - return B_DEV_BAD_DRIVE_NUM; - case -48: /* ENSAME - Cross device rename */ - return EXDEV; - case -49: /* ENMFIL - No more files */ - return EMFILE; - case -58: /* ELOCKED - Record is already locked */ - return EINVAL; //XXX - case -59: /* ENSLOCK - Invalid lock removal request */ - return EINVAL; //XXX - case -64: /* ERANGE or ENAMETOOLONG - Range error */ - return ENAMETOOLONG; - case -65: /* EINTRN - Internal error */ - return B_ERROR; - case -66: /* EPLFMT - Invalid program load format */ - return ENOEXEC; - case -67: /* EGSBF - Memory block growth failure */ - return EINVAL; - case -80: /* ELOOP - Too many symbolic links */ - return ELOOP; - case -200: /* EMOUNT - Mount point crossed (indicator) */ - return EINVAL; - default: - return B_ERROR; - } -} - - -void dump_tos_cookie(uint32 cookie) -{ - const tos_cookie *c; - c = tos_find_cookie(cookie); - if (!c) - dprintf("%4.4s: nil\n", &cookie); - else - dprintf("%4.4s: 0x%08lx, %d\n", &cookie, c->ivalue, c->ivalue); -} -void dump_tos_cookies(void) -{ - static const uint32 clist[] = { '_CPU', '_FPU', '_VDO', '_FDC', - '_SND', '_MCH', '_SWI', '_FRB', - '_FLK', '_NET', '_IDT', '_AKP', - 'FSMC', 'SAM\0', 'MiNT', NULL }; - int i; - dprintf("Cookies:\n"); - for (i = 0; clist[i]; i++) - dump_tos_cookie(clist[i]); -} - diff --git a/src/system/boot/platform/atari_m68k/toscalls.S b/src/system/boot/platform/atari_m68k/toscalls.S deleted file mode 100644 index 8bc67cf8fa..0000000000 --- a/src/system/boot/platform/atari_m68k/toscalls.S +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2007, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT license. - * - * Author: - * François Revol, revol@free.fr. - */ - -#define FUNCTION(x) .global x; .type x,@function; x - -/* non reentrant but that's enough - * idea taken from - * http://www.fortunecity.com/skyscraper/apple/308/html/chap4.htm - */ - -_trap_ret_addr: - .long 0 - -/* uint32 bios(uint16 nr, ...); */ -FUNCTION(bios): - move.l (%a7)+,_trap_ret_addr - trap #13 - move.l _trap_ret_addr,-(%a7) - rts - -/* uint32 xbios(uint16 nr, ...); */ -FUNCTION(xbios): - move.l (%a7)+,_trap_ret_addr - trap #14 - move.l _trap_ret_addr,-(%a7) - rts - -/* uint32 gemdos(uint16 nr, ...); */ -FUNCTION(gemdos): - move.l (%a7)+,_trap_ret_addr - trap #1 - move.l _trap_ret_addr,-(%a7) - rts - -/* uint32 vdi(uint16 nr, ...); */ -FUNCTION(vdi): - move.l (%a7)+,_trap_ret_addr - trap #14 - move.l _trap_ret_addr,-(%a7) - rts - diff --git a/src/system/boot/platform/atari_m68k/toscalls.c b/src/system/boot/platform/atari_m68k/toscalls.c new file mode 100644 index 0000000000..ceb10ecc23 --- /dev/null +++ b/src/system/boot/platform/atari_m68k/toscalls.c @@ -0,0 +1,123 @@ +/* + * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include "toscalls.h" + +#include +#include +#include + +#include + + +/*! Maps TOS error codes to native errors + */ +status_t +toserror(int32 err) +{ + // generated from: + // http://www.fortunecity.com/skyscraper/apple/308/html/appendd.htm + // with: + // while read N; do read V; read L; echo -e "\tcase $V: /* $N - $L */\n\t\treturn EINVAL;"; done >> errs + switch (err) { + /* BIOS errors */ + case 0: /* E_OK - No error */ + return B_OK; + case -1: /* ERROR - Generic error */ + return B_ERROR; + case -2: /* EDRVNR - Drive not ready */ + return B_DEV_NOT_READY; + case -3: /* EUNCMD - Unknown command */ + return EINVAL; //XXX + case -4: /* E_CRC - CRC error */ + return B_DEV_CRC_ERROR; + case -5: /* EBADRQ - Bad request */ + return EINVAL; //XXX + case -6: /* E_SEEK - Seek error */ + return B_DEV_SEEK_ERROR; + case -7: /* EMEDIA - Unknown media */ + return B_DEV_UNREADABLE; + case -8: /* ESECNF - Sector not found */ + return B_DEV_FORMAT_ERROR; + case -9: /* EPAPER - Out of paper */ + return ENODEV; + case -10: /* EWRITF - Write fault */ + return B_DEV_WRITE_ERROR; + case -11: /* EREADF - Read fault */ + return B_DEV_READ_ERROR; + case -12: /* EWRPRO - Device is write protected */ + return B_READ_ONLY_DEVICE; + case -14: /* E_CHNG - Media change detected */ + return B_DEV_MEDIA_CHANGED; + case -15: /* EUNDEV - Unknown device */ + return B_DEV_BAD_DRIVE_NUM; + case -16: /* EBADSF - Bad sectors on format */ + return B_DEV_UNREADABLE; + case -17: /* EOTHER - Insert other disk (request) */ + return B_DEV_MEDIA_CHANGE_REQUESTED; + /* GEMDOS errors */ + case -32: /* EINVFN - Invalid function */ + return EINVAL; + case -33: /* EFILNF - File not found */ + return B_FILE_NOT_FOUND; + case -34: /* EPTHNF - Path not found */ + return B_ENTRY_NOT_FOUND; + case -35: /* ENHNDL - No more handles */ + return B_NO_MORE_FDS; + case -36: /* EACCDN - Access denied */ + return EACCES; + case -37: /* EIHNDL - Invalid handle */ + return EBADF; + case -39: /* ENSMEM - Insufficient memory */ + return ENOMEM; + case -40: /* EIMBA - Invalid memory block address */ + return EFAULT; + case -46: /* EDRIVE - Invalid drive specification */ + return B_DEV_BAD_DRIVE_NUM; + case -48: /* ENSAME - Cross device rename */ + return EXDEV; + case -49: /* ENMFIL - No more files */ + return EMFILE; + case -58: /* ELOCKED - Record is already locked */ + return EINVAL; //XXX + case -59: /* ENSLOCK - Invalid lock removal request */ + return EINVAL; //XXX + case -64: /* ERANGE or ENAMETOOLONG - Range error */ + return ENAMETOOLONG; + case -65: /* EINTRN - Internal error */ + return B_ERROR; + case -66: /* EPLFMT - Invalid program load format */ + return ENOEXEC; + case -67: /* EGSBF - Memory block growth failure */ + return EINVAL; + case -80: /* ELOOP - Too many symbolic links */ + return ELOOP; + case -200: /* EMOUNT - Mount point crossed (indicator) */ + return EINVAL; + default: + return B_ERROR; + } +} + + +void +dump_tos_cookie(const struct tos_cookie *c) +{ + if (c) + dprintf("%4.4s: 0x%08lx, %d\n", &c->cookie, c->ivalue, c->ivalue); +} + + +void +dump_tos_cookies(void) +{ + const tos_cookie *c = COOKIE_JAR; + dprintf("Cookies:\n"); + while (c && (c->cookie)) { + dump_tos_cookie(c++); + } +} +