filename | src/dcload.c |
changeset | 102:844a3f2a76ff |
next | 106:9048bac046c3 |
author | nkeynes |
date | Mon Mar 13 12:38:39 2006 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Refactor bios into more generic syscall structure. Add initial hooks for dc-load functions |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/dcload.c Mon Mar 13 12:38:39 2006 +00001.3 @@ -0,0 +1,87 @@1.4 +/**1.5 + * $Id: dcload.c,v 1.1 2006-03-13 12:38:34 nkeynes Exp $1.6 + *1.7 + * DC-load syscall implementation.1.8 + *1.9 + * Copyright (c) 2005 Nathan Keynes.1.10 + *1.11 + * This program is free software; you can redistribute it and/or modify1.12 + * it under the terms of the GNU General Public License as published by1.13 + * the Free Software Foundation; either version 2 of the License, or1.14 + * (at your option) any later version.1.15 + *1.16 + * This program is distributed in the hope that it will be useful,1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.19 + * GNU General Public License for more details.1.20 + */1.21 +1.22 +#include <stdio.h>1.23 +#include "dream.h"1.24 +#include "mem.h"1.25 +#include "syscall.h"1.26 +#include "sh4/sh4core.h"1.27 +1.28 +#define SYS_READ 01.29 +#define SYS_WRITE 11.30 +#define SYS_OPEN 21.31 +#define SYS_CLOSE 31.32 +#define SYS_CREAT 41.33 +#define SYS_LINK 51.34 +#define SYS_UNLINK 61.35 +#define SYS_CHDIR 71.36 +#define SYS_CHMOD 81.37 +#define SYS_LSEEK 91.38 +#define SYS_FSTAT 101.39 +#define SYS_TIME 111.40 +#define SYS_STAT 121.41 +#define SYS_UTIME 131.42 +#define SYS_ASSIGNWRKMEM 141.43 +#define SYS_EXIT 151.44 +#define SYS_OPENDIR 161.45 +#define SYS_CLOSEDIR 171.46 +#define SYS_READDIR 181.47 +#define SYS_GETHOSTINFO 191.48 +1.49 +#define SYS_MAGIC 0xDEADBEEF1.50 +#define SYS_MAGIC_ADDR 0x8c0040041.51 +#define SYSCALL_ADDR 0x8c0040081.52 +1.53 +void dcload_syscall( uint32_t syscall_id )1.54 +{1.55 + uint32_t syscall = sh4r.r[4];1.56 + switch( sh4r.r[4] ) {1.57 + case SYS_READ:1.58 + if( sh4r.r[5] == 0 ) {1.59 + char *buf = mem_get_region( sh4r.r[6] );1.60 + int length = sh4r.r[7];1.61 + sh4r.r[0] = read( 0, buf, length );1.62 + } else {1.63 + sh4r.r[0] = -1;1.64 + }1.65 + break;1.66 + case SYS_WRITE:1.67 + if( sh4r.r[5] == 1 || sh4r.r[5] == 2 ) {1.68 + char *buf = mem_get_region( sh4r.r[6] );1.69 + int length = sh4r.r[7];1.70 + sh4r.r[0] = write( sh4r.r[5], buf, length );1.71 + } else {1.72 + sh4r.r[0] = -1;1.73 + }1.74 + break;1.75 + case SYS_EXIT:1.76 + dreamcast_stop();1.77 + sh4_stop();1.78 + sh4r.r[0] = 0;1.79 + break;1.80 + default:1.81 + sh4r.r[0] = -1;1.82 + }1.83 +1.84 +}1.85 +1.86 +void dcload_install()1.87 +{1.88 + syscall_add_hook_vector( 0xF0, SYSCALL_ADDR, dcload_syscall );1.89 + sh4_write_long( SYS_MAGIC_ADDR, SYS_MAGIC );1.90 +}
.