00001 /* 00002 * Copyright (C) 2003-2009 Olivier Boudeville 00003 * 00004 * This file is part of the Ceylan library. 00005 * 00006 * The Ceylan library is free software: you can redistribute it and/or modify 00007 * it under the terms of either the GNU Lesser General Public License or 00008 * the GNU General Public License, as they are published by the Free Software 00009 * Foundation, either version 3 of these Licenses, or (at your option) 00010 * any later version. 00011 * 00012 * The Ceylan library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License and the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License and the GNU General Public License along with the Ceylan library. 00020 * If not, see <http://www.gnu.org/licenses/>. 00021 * 00022 * Author: Olivier Boudeville (olivier.boudeville@esperide.com) 00023 * 00024 */ 00025 00026 00027 #ifndef CEYLAN_ARM7_BASE_H_ 00028 #define CEYLAN_ARM7_BASE_H_ 00029 00030 00031 #include "CeylanARM7Codes.h" /* for ARM7StatusWord and al */ 00032 00033 00034 /* 00035 * Ceylan ARM7 code base centralizing all main code for that processor, notably 00036 * for IPC management. 00037 * 00038 * Later: will offer Wifi facilities. 00039 * 00040 * Sound, including sounds (PCM and IMA ADPCM) and MP3 music is not managed 00041 * here, as it depends on the *.osdl.* file formats. 00042 * @see Helix-OSDL for that. 00043 * 00044 * User code is expected to define only two callback functions: 00045 * 'void handleReceivedApplicationCommand( FIFOCommandID commandID, 00046 * FIFOElement element )', which can be void or better can only contain: 00047 * 'setError( UnexpectedApplicationCommand ) ;' 00048 * 00049 * - and - 00050 * 00051 * 'void handleReceivedIntegratingLibrarySpecificCommand( FIFOCommandID 00052 * commandID, FIFOElement firstElement )', which can be void or better can 00053 * only contain: 00054 * 'setError( UnexpectedExternalLibraryCommand ) ;' 00055 * 00056 * ..plus, of course, the main() function, which can be inspired from the 00057 * examples. 00058 * 00059 * @note This Ceylan base remains lightweight, as otherwise library integrating 00060 * Ceylan (ex: OSDL) would have to redefine mechanisms while still linking with 00061 * the Ceylan counterpart version. 00062 * 00063 * @see testCeylanSound.arm7.c 00064 * 00065 */ 00066 00067 00068 /* 00069 * Apparently the overhead due to the C++, to the STL and (marginally) to 00070 * the Ceylan library itself leads to having an ARM7 executable too big to 00071 * fit in its IWRAM. 00072 * 00073 * Hence for the moment the inclusion of the Ceylan header is commented out 00074 * and libnds is directly used instead. 00075 * 00076 */ 00077 00078 00079 00080 /* Type definitions */ 00081 00082 00084 typedef uint32 FIFOElement ; 00085 00086 00088 typedef uint8 FIFOCommandCount ; 00089 00090 00092 typedef char Byte ; 00093 00094 00096 typedef uint32 BufferSize ; 00097 00098 00099 00101 typedef int InterruptMask ; 00102 00103 00105 extern const InterruptMask AllInterruptsDisabled ; 00106 00107 00109 void atomicSleep() ; 00110 00111 00112 00120 void setStatusWord( ARM7StatusWord newStatus ) ; 00121 00122 00123 00132 void setError( ARM7ErrorCode newError ) ; 00133 00134 00135 00141 void unsetErrorStatus() ; 00142 00143 00144 00146 FIFOElement prepareFIFOCommand( FIFOCommandID id ) ; 00147 00148 00149 00162 InterruptMask setEnabledInterrupts( InterruptMask newMask ) ; 00163 00164 00165 00167 void notifyCommandToARM9() ; 00168 00169 00170 00171 00172 /* I/O section. */ 00173 00174 00175 00177 FIFOElement read() ; 00178 00179 00181 FIFOElement readBlocking() ; 00182 00183 00185 void write( FIFOElement toSend ) ; 00186 00187 00192 void writeBlocking( FIFOElement toSend ) ; 00193 00194 00201 void handleReceivedSystemSpecificCommand( FIFOCommandID commandID, 00202 FIFOElement firstElement ) ; 00203 00204 00214 void handleReceivedIntegratingLibrarySpecificCommand( FIFOCommandID commandID, 00215 FIFOElement firstElement ) ; 00216 00217 00227 void handleReceivedApplicationCommand( FIFOCommandID commandID, 00228 FIFOElement element ) ; 00229 00230 00231 /* Initializes Ceylan and its prerequisites. */ 00232 void initCeylan() ; 00233 00234 00235 00236 #endif // CEYLAN_ARM7_BASE_H_ 00237