Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
90 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
6
//    This file is part of emBIOS.
7
//
8
//    emBIOS is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emBIOS 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.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "global.h"
25
#include "console.h"
26
#include "execimage.h"
27
 
28
 
29
int execimage(void* image)
30
{
31
    struct execimage_header* header = (struct execimage_header*)image;
32
    if (memcmp(header, "emBIexec", 8))
33
    {
34
        cprintf(CONSOLE_BOOT, "execimage: Bad signature!\n"
35
                              "%02X %02X %02X %02X %02X %02X %02X %02X\n",
36
                header->signature[0], header->signature[1], header->signature[2],
37
                header->signature[3], header->signature[4], header->signature[5],
38
                header->signature[6], header->signature[7]);
39
        return -1;
40
    }
41
    if (header->version > 0)
42
    {
43
        cprintf(CONSOLE_BOOT, "execimage: Unsupported version! (%08X)\n", header->version);
44
        return -2;
45
    }
46
    if (header->baseaddr != image)
47
    {
48
        cprintf(CONSOLE_BOOT, "execimage: Image loaded to wrong address! "
49
                              "(expected: %08X, got: %08X)\n", header->baseaddr, image);
50
        return -3;
51
    }
52
    return thread_create(header->threadname, header->entrypoint, header->stackaddr,
53
                         header->stacksize, header->threadtype, header->threadpriority, true);
54
}