freemyipod r100 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r99‎ | r100 | r101 >
Date:22:39, 11 August 2010
Author:theseven
Status:new
Tags:
Comment:
Check the syscall table version before accepting it
Modified paths:
  • /apps/embiosapp.h (modified) (history)
  • /apps/syscallapi.h (modified) (history)
  • /embios/trunk/syscallapi.c (modified) (history)
  • /embios/trunk/syscallapi.h (modified) (history)

Diff [purge]

Index: apps/embiosapp.h
@@ -7,7 +7,7 @@
88
99 #define EMBIOS_APP_HEADER(threadnamestr, stacksizebytes, mainfunc, threadprio) \
1010 uint32_t __embios_thread_stack[stacksizebytes >> 2]; \
11 - char __embios_thread_name[] = threadnamestr; \
 11+ const char __embios_thread_name[] = threadnamestr; \
1212 struct embios_app_header \
1313 { \
1414 char signature[8]; \
@@ -18,7 +18,7 @@
1919 void* stackaddr; \
2020 int stacksize; \
2121 void* entrypoint; \
22 - char* threadname; \
 22+ const char* threadname; \
2323 int threadtype; \
2424 int threadpriority; \
2525 } __embios_executable_hdr __attribute__((section(".execheader"))) = \
@@ -35,10 +35,15 @@
3636 .threadtype = 0, \
3737 .threadpriority = threadprio \
3838 }; \
39 - struct embios_syscall_table* __embios_syscall;
 39+ struct embios_syscall_table* __embios_syscall; \
 40+ const uint32_t __embios_required_version = EMBIOS_API_VERSION; \
 41+ const char __embios_incompatible_api_str[] = "Incompatible API version!\nGot %d, need %d";
4042
4143
4244 #define embios_init() \
43 - asm volatile("swi\t2\n\tldr\tr1,\t=__embios_syscall\n\tstr\tr0,\t[r1]\n\t" \
 45+ asm volatile("swi\t2\n\tldr\tr3,\t=__embios_required_version\nldr\tr3,\t[r3]\n\t" \
 46+ "ldr\tr2,\t[r0]\n\tcmp\tr3,\tr2\n\tldrls\tr1,\t[r0,#4]\n\tcmpls\tr1,\tr3\n\t" \
 47+ "movhi\tr0,\t#0\n\tldrhi\tr1,\t=__embios_incompatible_api_str\n\t" \
 48+ "swihi\t1\n\tldr\tr1,\t=__embios_syscall\n\tstr\tr0,\t[r1]\n\t" \
4449 ::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory");
4550
Index: apps/syscallapi.h
@@ -56,6 +56,8 @@
5757
5858 struct embios_syscall_table
5959 {
 60+ uint32_t table_version;
 61+ uint32_t table_minversion;
6062 void (*panic) (enum panic_severity severity, const char* string);
6163 void (*panicf) (enum panic_severity severity, const char* fmt, ...);
6264 };
Index: embios/trunk/syscallapi.c
@@ -28,6 +28,8 @@
2929
3030 struct embios_syscall_table syscall_table ICONST_ATTR =
3131 {
 32+ .table_version = EMBIOS_API_VERSION,
 33+ .table_minversion = EMBIOS_MIN_API_VERSION,
3234 .panic = panic,
3335 .panicf = panicf
3436 };
Index: embios/trunk/syscallapi.h
@@ -56,6 +56,8 @@
5757
5858 struct embios_syscall_table
5959 {
 60+ uint32_t table_version;
 61+ uint32_t table_minversion;
6062 void (*panic) (enum panic_severity severity, const char* string);
6163 void (*panicf) (enum panic_severity severity, const char* fmt, ...);
6264 };