Subversion Repositories freemyipod

Rev

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),
74
                ("timeout", c_uint32),
75
                ("blocked_since", c_uint32),
76
                ("blocked_by", c_uint32),
77
                ("stack", c_uint32),
78
                ("err_no", c_int32),
79
                ("block_type", thread_block),
80
                ("thread_type", thread_type),
81
                ("priority", c_uint8),
82
                ("cpuload", c_uint8),
83
               ]
84
 
171 farthen 85
swtypes = {
86
    0: "invalid",
434 theseven 87
    1: "emBIOS Debugger",
427 farthen 88
    2: "emCORE Debugger"
171 farthen 89
}
90
 
506 farthen 91
hwtypes = {
549 farthen 92
    0:          ("invalid",     "invalid"),
93
    0x47324e49: ("ipodnano2g",  "iPod nano 2g"),
94
    0x47334e49: ("ipodnano3g",  "iPod nano 3g"),
95
    0x47344e49: ("ipodnano4g",  "iPod nano 4g"),
96
    0x4c435049: ("ipodclassic", "iPod classic"),
97
}