freemyipod r90 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r89‎ | r90 | r91 >
Date:04:40, 11 August 2010
Author:theseven
Status:new
Tags:
Comment:
Commit forgotten files
Modified paths:
  • /embios/trunk/execimage.c (added) (history)
  • /embios/trunk/execimage.h (added) (history)

Diff [purge]

Index: embios/trunk/execimage.c
@@ -0,0 +1,54 @@
 2+//
 3+//
 4+// Copyright 2010 TheSeven
 5+//
 6+//
 7+// This file is part of emBIOS.
 8+//
 9+// emBIOS is free software: you can redistribute it and/or
 10+// modify it under the terms of the GNU General Public License as
 11+// published by the Free Software Foundation, either version 2 of the
 12+// License, or (at your option) any later version.
 13+//
 14+// emBIOS is distributed in the hope that it will be useful,
 15+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 17+// See the GNU General Public License for more details.
 18+//
 19+// You should have received a copy of the GNU General Public License along
 20+// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
 21+//
 22+//
 23+
 24+
 25+#include "global.h"
 26+#include "console.h"
 27+#include "execimage.h"
 28+
 29+
 30+int execimage(void* image)
 31+{
 32+ struct execimage_header* header = (struct execimage_header*)image;
 33+ if (memcmp(header, "emBIexec", 8))
 34+ {
 35+ cprintf(CONSOLE_BOOT, "execimage: Bad signature!\n"
 36+ "%02X %02X %02X %02X %02X %02X %02X %02X\n",
 37+ header->signature[0], header->signature[1], header->signature[2],
 38+ header->signature[3], header->signature[4], header->signature[5],
 39+ header->signature[6], header->signature[7]);
 40+ return -1;
 41+ }
 42+ if (header->version > 0)
 43+ {
 44+ cprintf(CONSOLE_BOOT, "execimage: Unsupported version! (%08X)\n", header->version);
 45+ return -2;
 46+ }
 47+ if (header->baseaddr != image)
 48+ {
 49+ cprintf(CONSOLE_BOOT, "execimage: Image loaded to wrong address! "
 50+ "(expected: %08X, got: %08X)\n", header->baseaddr, image);
 51+ return -3;
 52+ }
 53+ return thread_create(header->threadname, header->entrypoint, header->stackaddr,
 54+ header->stacksize, header->threadtype, header->threadpriority, true);
 55+}
Index: embios/trunk/execimage.h
@@ -0,0 +1,50 @@
 2+//
 3+//
 4+// Copyright 2010 TheSeven
 5+//
 6+//
 7+// This file is part of emBIOS.
 8+//
 9+// emBIOS is free software: you can redistribute it and/or
 10+// modify it under the terms of the GNU General Public License as
 11+// published by the Free Software Foundation, either version 2 of the
 12+// License, or (at your option) any later version.
 13+//
 14+// emBIOS is distributed in the hope that it will be useful,
 15+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 17+// See the GNU General Public License for more details.
 18+//
 19+// You should have received a copy of the GNU General Public License along
 20+// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
 21+//
 22+//
 23+
 24+
 25+#ifndef __EXECIMAGE_H__
 26+#define __EXECIMAGE_H__
 27+
 28+
 29+#include "global.h"
 30+
 31+
 32+struct execimage_header
 33+{
 34+ char signature[8];
 35+ int version;
 36+ void* baseaddr;
 37+ int size;
 38+ uint32_t crc32;
 39+ void* stackaddr;
 40+ int stacksize;
 41+ void* entrypoint;
 42+ char* threadname;
 43+ int threadtype;
 44+ int threadpriority;
 45+};
 46+
 47+
 48+int execimage(void* image);
 49+
 50+
 51+#endif