Subversion Repositories freemyipod

Rev

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

Rev Author Line No. Line
176 farthen 1
#!/usr/bin/env python
2
#
3
#
4
#    Copyright 2010 TheSeven, benedikt93, Farthen
5
#
6
#
427 farthen 7
#    This file is part of emCORE.
176 farthen 8
#
427 farthen 9
#    emCORE is free software: you can redistribute it and/or
176 farthen 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
#
427 farthen 14
#    emCORE is distributed in the hope that it will be useful,
176 farthen 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
427 farthen 20
#    along with emCORE.  If not, see <http://www.gnu.org/licenses/>.
176 farthen 21
#
22
#
23
 
507 farthen 24
"""
25
    Contains emCORE data structures, enums and dicts
26
"""
27
 
506 farthen 28
from ctypes import *
29
from misc import ExtendedCStruct, c_enum
173 farthen 30
 
31
 
506 farthen 32
class thread_type(c_enum):
33
    _fields_ = ["USER_THREAD",
34
                "OS_THREAD",
35
                "CORE_THREAD",
36
               ]
173 farthen 37
 
506 farthen 38
class thread_state(c_enum):
39
    _fields_ = ["THREAD_FREE",
40
                "THREAD_SUSPENDED",
41
                "THREAD_READY",
42
                "THREAD_RUNNING",
43
                "THREAD_BLOCKED",
44
                "THREAD_DEFUNCT",
45
                "THREAD_DEFUNCT_ACK",
46
               ]
171 farthen 47
 
506 farthen 48
class thread_block(c_enum):
49
    _fields_ = ["THREAD_NOT_BLOCKED",
50
                "THREAD_BLOCK_SLEEP",
51
                "THREAD_BLOCK_MUTEX",
52
                "THREAD_BLOCK_WAKEUP",
53
                "THREAD_DEFUNCT_STKOV",
54
                "THREAD_DEFUNCT_PANIC"
55
               ]
56
 
57
class responsecode(c_enum):
58
    _fields_ = ["INVALID",
59
                "OK",
60
                "UNSUPPORTED",
61
                "BUSY"
62
               ]
63
 
64
class scheduler_thread(ExtendedCStruct):
65
    _fields_ = [("regs", c_uint32 * 16),
66
                ("cpsr", c_uint32),
67
                ("state", c_uint32),
68
                ("name", c_uint32),
69
                ("cputime_current", c_uint32),
70
                ("cputime_total", c_uint64),
71
                ("startusec", c_uint32),
72
                ("thread_next", c_uint32),
73
                ("queue_next", c_uint32),
713 user890104 74
                ("owned_mutexes", c_uint32),
506 farthen 75
                ("timeout", c_uint32),
76
                ("blocked_since", c_uint32),
77
                ("blocked_by", c_uint32),
78
                ("stack", c_uint32),
79
                ("err_no", c_int32),
80
                ("block_type", thread_block),
81
                ("thread_type", thread_type),
82
                ("priority", c_uint8),
83
                ("cpuload", c_uint8),
84
               ]
85
 
608 farthen 86
class mutex(ExtendedCStruct):
87
    _fields_ = [("owner", c_uint32),
88
                ("waiters", c_uint32),
774 theseven 89
                ("owned_next", c_uint32),
608 farthen 90
                ("count", c_int32),
91
                ]
92
 
93
class wakeup(ExtendedCStruct):
94
    _fields_ = [("waiter", c_uint32),
95
                ("signalled", c_uint32),
96
               ]
97
 
98
 
171 farthen 99
swtypes = {
100
    0: "invalid",
434 theseven 101
    1: "emBIOS Debugger",
427 farthen 102
    2: "emCORE Debugger"
171 farthen 103
}
104
 
506 farthen 105
hwtypes = {
549 farthen 106
    0:          ("invalid",     "invalid"),
927 user890104 107
    0x47324e49: ("ipodnano2g",  "iPod Nano 2G"),
108
    0x47334e49: ("ipodnano3g",  "iPod Nano 3G"),
109
    0x47344e49: ("ipodnano4g",  "iPod Nano 4G"),
110
    0x4c435049: ("ipodclassic", "iPod Classic"),
111
    0x47325449: ("ipodtouch2g", "iPod Touch 2G"),
112
}