[rendering] This simple trick didn't work...
[wikipediardware.git] / mbr / application.h
blob3a8a430aa41ccbaad3352dc8ece5ca7b558ac2cb
1 /*
2 e07 bootloader suite - ROM base application header
3 Copyright (c) 2009 Christopher Hall <hsw@openmoko.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #if !defined(_APPLICATION_H_)
20 #define _APPLICATION_H_
22 #include "regs.h"
23 #include "types.h"
24 #include "wikireader.h"
25 #include "misc.h"
28 #if !defined(APPLICATION_TITLE)
29 #error "APPLICATION_TITLE must be defined before including application.h"
30 #endif
32 // setup and configure run time environment
33 // the very first line of main() after the '}'
34 #define APPLICATION_INITIALISE() \
35 do { \
36 asm volatile ("\txld.w\t%r15, __dp\n" \
37 "\txld.w\t%r10, __SIZE_bss\n" \
38 "\tor\t%r10, %r10\n" \
39 "\tjreq\tclear_bss_done\n" \
40 "\txld.w\t%r9, __START_bss\n" \
41 "\txor\t%r8, %r8\n" \
42 "clear_bss_loop:\n" \
43 "\tld.w\t[%r9]+, %r8\n" \
44 "\tsub\t%r10, 4\n" \
45 "\tjrgt\tclear_bss_loop\n" \
46 "clear_bss_done:\n" \
47 ); \
48 init_pins(); \
49 init_rs232_ch0(); \
50 init_ram(); \
51 } while (0)
54 // the last line of main() before the final '}'
55 // at present just returns the next_program number to
56 #define APPLICATION_FINALISE(next_program, status) \
57 do { \
58 ReturnType rc = {next_program, status}; \
59 return (rc); \
60 } while (0)
63 __attribute__ ((packed))
64 typedef struct {
65 unsigned int block;
66 unsigned int status;
67 } ReturnType;
69 typedef ReturnType application(int block, int status);
72 #endif