* 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
This commit is contained in:
François Revol
2008-01-17 09:00:27 +00:00
parent b70fb738a6
commit 7d59553ec8
4 changed files with 124 additions and 157 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ KernelMergeObject boot_platform_atari_m68k_shell.o :
KernelMergeObject boot_platform_atari_m68k_other.o : KernelMergeObject boot_platform_atari_m68k_other.o :
# shell.S # shell.S
start.c start.c
toscalls.S toscalls.c
debug.c debug.c
#bios.S #bios.S
console.cpp console.cpp
-110
View File
@@ -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]);
}
@@ -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
@@ -0,0 +1,123 @@
/*
* Copyright 2004-2007, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "toscalls.h"
#include <boot/platform.h>
#include <boot/stdio.h>
#include <stdarg.h>
#include <Errors.h>
/*! 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++);
}
}