1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/testaica.c Tue Aug 19 23:39:14 2008 +0000
1.5 + * $Id: testdata.c 602 2008-01-15 20:50:23Z nkeynes $
1.9 + * Copyright (c) 2006 Nathan Keynes.
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
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 of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.26 +#define AICA_RAM_BASE 0x00800000
1.28 +#define AICA_SYSCALL (AICA_RAM_BASE+0x30)
1.29 +#define AICA_SYSCALL_ARG1 (AICA_SYSCALL+4)
1.30 +#define AICA_SYSCALL_ARG2 (AICA_SYSCALL+8)
1.31 +#define AICA_SYSCALL_ARG3 (AICA_SYSCALL+12)
1.32 +#define AICA_SYSCALL_RETURN (AICA_SYSCALL+4)
1.35 +#define SYS_WRITE 1
1.37 +#define SYS_CLOSE 3
1.38 +#define SYS_CREAT 4
1.40 +#define SYS_UNLINK 6
1.41 +#define SYS_CHDIR 7
1.42 +#define SYS_CHMOD 8
1.43 +#define SYS_LSEEK 9
1.44 +#define SYS_FSTAT 10
1.45 +#define SYS_TIME 11
1.46 +#define SYS_STAT 12
1.47 +#define SYS_UTIME 13
1.48 +#define SYS_ASSIGNWRKMEM 14
1.49 +#define SYS_EXIT 15
1.50 +#define SYS_OPENDIR 16
1.51 +#define SYS_CLOSEDIR 17
1.52 +#define SYS_READDIR 18
1.53 +#define SYS_GETHOSTINFO 19
1.55 +uint32_t do_syscall( uint32_t syscall, uint32_t arg1, uint32_t arg2, uint32_t arg3 )
1.60 + switch( syscall ) {
1.63 + data = (char *)(AICA_RAM_BASE + (arg2 & 0x001FFFFF));
1.65 + return read( fd, data, len );
1.68 + data = (char *)(AICA_RAM_BASE + (arg2 & 0x001FFFFF));
1.70 + return write( fd, data, len );
1.81 +int main( int argc, char *argv[] )
1.83 + char buf[65536] __attribute__((aligned(32)));
1.84 + uint32_t aica_addr = AICA_RAM_BASE;
1.88 + /* Load ARM program from stdin and copy to ARM memory */
1.89 + while( (len = read(0, buf, sizeof(buf))) > 0 ) {
1.90 + aica_dma_write( aica_addr, buf, len );
1.94 + /* Main loop waiting for IO commands */
1.97 + int syscall = long_read(AICA_SYSCALL);
1.98 + if( syscall != -1 ) {
1.99 + uint32_t result = do_syscall( syscall, long_read(AICA_SYSCALL_ARG1),
1.100 + long_read(AICA_SYSCALL_ARG2), long_read(AICA_SYSCALL_ARG3) );
1.101 + long_write( AICA_SYSCALL_RETURN, result );
1.102 + long_write( AICA_SYSCALL, -1 );
1.106 \ No newline at end of file