2 * $Id: testdata.c 602 2008-01-15 20:50:23Z nkeynes $
6 * Copyright (c) 2006 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
23 #define AICA_RAM_BASE 0x00800000
25 #define AICA_SYSCALL (AICA_RAM_BASE+0x30)
26 #define AICA_SYSCALL_ARG1 (AICA_SYSCALL+4)
27 #define AICA_SYSCALL_ARG2 (AICA_SYSCALL+8)
28 #define AICA_SYSCALL_ARG3 (AICA_SYSCALL+12)
29 #define AICA_SYSCALL_RETURN (AICA_SYSCALL+4)
45 #define SYS_ASSIGNWRKMEM 14
47 #define SYS_OPENDIR 16
48 #define SYS_CLOSEDIR 17
49 #define SYS_READDIR 18
50 #define SYS_GETHOSTINFO 19
52 uint32_t do_syscall( uint32_t syscall, uint32_t arg1, uint32_t arg2, uint32_t arg3 )
60 data = (char *)(AICA_RAM_BASE + (arg2 & 0x001FFFFF));
62 return read( fd, data, len );
65 data = (char *)(AICA_RAM_BASE + (arg2 & 0x001FFFFF));
67 return write( fd, data, len );
78 int main( int argc, char *argv[] )
80 char buf[65536] __attribute__((aligned(32)));
81 uint32_t aica_addr = AICA_RAM_BASE;
85 /* Load ARM program from stdin and copy to ARM memory */
86 while( (len = read(0, buf, sizeof(buf))) > 0 ) {
87 aica_dma_write( aica_addr, buf, len );
91 /* Main loop waiting for IO commands */
94 int syscall = long_read(AICA_SYSCALL);
96 uint32_t result = do_syscall( syscall, long_read(AICA_SYSCALL_ARG1),
97 long_read(AICA_SYSCALL_ARG2), long_read(AICA_SYSCALL_ARG3) );
98 long_write( AICA_SYSCALL_RETURN, result );
99 long_write( AICA_SYSCALL, -1 );
.