Subversion Repositories freemyipod

Rev

Rev 25 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 26
Line 39... Line 39...
39
    size_t bytes;
39
    size_t bytes;
40
};
40
};
41
 
41
 
42
 
42
 
43
struct mutex console_mutex;
43
struct mutex console_mutex;
-
 
44
struct mutex console_readmutex;
44
 
45
 
45
 
46
 
46
void console_init()
47
void console_init()
47
{
48
{
48
    mutex_init(&console_mutex);
49
    mutex_init(&console_mutex);
-
 
50
    mutex_init(&console_readmutex);
49
}
51
}
50
 
52
 
51
void cputc_internal(unsigned int consoles, char string) ICODE_ATTR;
53
void cputc_internal(unsigned int consoles, char string) ICODE_ATTR;
52
void cputc_internal(unsigned int consoles, char string)
54
void cputc_internal(unsigned int consoles, char string)
53
{
55
{
Line 121... Line 123...
121
{
123
{
122
    mutex_lock(&console_mutex, TIMEOUT_BLOCK);
124
    mutex_lock(&console_mutex, TIMEOUT_BLOCK);
123
    if (consoles & 1) lcdconsole_update();
125
    if (consoles & 1) lcdconsole_update();
124
    mutex_unlock(&console_mutex);
126
    mutex_unlock(&console_mutex);
125
}
127
}
-
 
128
 
-
 
129
int cgetc(unsigned int consoles, int timeout)
-
 
130
{
-
 
131
    int result;
-
 
132
    mutex_lock(&console_readmutex, TIMEOUT_BLOCK);
-
 
133
    if ((consoles & 2) && (result = dbgconsole_getc(timeout)) != -1) return result;
-
 
134
    mutex_unlock(&console_mutex);
-
 
135
}
-
 
136
 
-
 
137
int cread(unsigned int consoles, char* buffer, size_t length, int timeout)
-
 
138
{
-
 
139
    int result;
-
 
140
    mutex_lock(&console_readmutex, TIMEOUT_BLOCK);
-
 
141
    if ((consoles & 2) && (result = dbgconsole_read(buffer, length, timeout))) return result;
-
 
142
    mutex_unlock(&console_mutex);
-
 
143
}
-
 
144
 
-
 
145
void creada(unsigned int consoles, char* buffer, size_t length, int timeout)
-
 
146
{
-
 
147
    int result;
-
 
148
    mutex_lock(&console_readmutex, TIMEOUT_BLOCK);
-
 
149
    while (length)
-
 
150
    {
-
 
151
        if (length && (consoles & 2) && (result = dbgconsole_read(buffer, length, timeout)))
-
 
152
        {
-
 
153
            buffer = &buffer[result];
-
 
154
            length -= result;
-
 
155
        }
-
 
156
    }
-
 
157
    mutex_unlock(&console_mutex);
-
 
158
}