Subversion Repositories freemyipod

Rev

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

Rev 696 Rev 704
Line 1027... Line 1027...
1027
    int free = dbgconsendreadidx - dbgconsendwriteidx - 1;
1027
    int free = dbgconsendreadidx - dbgconsendwriteidx - 1;
1028
    if (free < 0) free += sizeof(dbgconsendbuf);
1028
    if (free < 0) free += sizeof(dbgconsendbuf);
1029
    return free;
1029
    return free;
1030
}
1030
}
1031
 
1031
 
1032
int dbgconsole_makespace(int length) ICODE_ATTR;
1032
int dbgconsole_makespace(int length, bool safe) ICODE_ATTR;
1033
int dbgconsole_makespace(int length)
1033
int dbgconsole_makespace(int length, bool safe)
1034
{
1034
{
1035
    int free = dbgconsole_getfree();
1035
    int free = dbgconsole_getfree();
1036
    while (!free && dbgconsoleattached)
1036
    while (!free && dbgconsoleattached && !safe)
1037
    {
1037
    {
1038
        dbgconsoleattached = false;
1038
        dbgconsoleattached = false;
1039
        wakeup_wait(&dbgconsendwakeup, 2000000);
1039
        wakeup_wait(&dbgconsendwakeup, 2000000);
1040
        free = dbgconsole_getfree();
1040
        free = dbgconsole_getfree();
1041
    }
1041
    }
Line 1056... Line 1056...
1056
    if (offset != 16) memcpy(&dbgconsendbuf[idx], &dbgconoverflowstr[offset], 16 - offset);
1056
    if (offset != 16) memcpy(&dbgconsendbuf[idx], &dbgconoverflowstr[offset], 16 - offset);
1057
    leave_critical_section(mode);
1057
    leave_critical_section(mode);
1058
    return length;
1058
    return length;
1059
}
1059
}
1060
 
1060
 
1061
void dbgconsole_putc(char string)
1061
void dbgconsole_putc_internal(char string, bool safe)
1062
{
1062
{
1063
    dbgconsole_makespace(1);
1063
    dbgconsole_makespace(1, safe);
1064
    dbgconsendbuf[dbgconsendwriteidx++] = string;
1064
    dbgconsendbuf[dbgconsendwriteidx++] = string;
1065
    if (dbgconsendwriteidx >= sizeof(dbgconsendbuf))
1065
    if (dbgconsendwriteidx >= sizeof(dbgconsendbuf))
1066
        dbgconsendwriteidx -= sizeof(dbgconsendbuf);
1066
        dbgconsendwriteidx -= sizeof(dbgconsendbuf);
1067
}
1067
}
1068
 
1068
 
-
 
1069
void dbgconsole_putc(char string)
-
 
1070
{
-
 
1071
    dbgconsole_putc_internal(string, false);
-
 
1072
}
-
 
1073
 
-
 
1074
void dbgconsole_sputc(char string)
-
 
1075
{
-
 
1076
    dbgconsole_putc_internal(string, true);
-
 
1077
}
-
 
1078
 
1069
void dbgconsole_write(const char* string, size_t length)
1079
void dbgconsole_write_internal(const char* string, size_t length, bool safe)
1070
{
1080
{
1071
    while (length)
1081
    while (length)
1072
    {
1082
    {
1073
        int space = dbgconsole_makespace(length);
1083
        int space = dbgconsole_makespace(length, safe);
1074
        if (dbgconsendwriteidx + space >= sizeof(dbgconsendbuf))
1084
        if (dbgconsendwriteidx + space >= sizeof(dbgconsendbuf))
1075
        {
1085
        {
1076
            int bytes = sizeof(dbgconsendbuf) - dbgconsendwriteidx;
1086
            int bytes = sizeof(dbgconsendbuf) - dbgconsendwriteidx;
1077
            memcpy(&dbgconsendbuf[dbgconsendwriteidx], string, bytes);
1087
            memcpy(&dbgconsendbuf[dbgconsendwriteidx], string, bytes);
1078
            dbgconsendwriteidx = 0;
1088
            dbgconsendwriteidx = 0;
Line 1085... Line 1095...
1085
        string = &string[space];
1095
        string = &string[space];
1086
        length -= space;
1096
        length -= space;
1087
    }
1097
    }
1088
}
1098
}
1089
 
1099
 
-
 
1100
void dbgconsole_write(const char* string, size_t length)
-
 
1101
{
-
 
1102
    dbgconsole_write_internal(string, length, false);
-
 
1103
}
-
 
1104
 
-
 
1105
void dbgconsole_swrite(const char* string, size_t length)
-
 
1106
{
-
 
1107
    dbgconsole_write_internal(string, length, true);
-
 
1108
}
-
 
1109
 
1090
void dbgconsole_puts(const char* string)
1110
void dbgconsole_puts(const char* string)
1091
{
1111
{
1092
    dbgconsole_write(string, strlen(string));
1112
    dbgconsole_write(string, strlen(string));
1093
}
1113
}
1094
 
1114
 
-
 
1115
void dbgconsole_sputs(const char* string)
-
 
1116
{
-
 
1117
    dbgconsole_swrite(string, strlen(string));
-
 
1118
}
-
 
1119
 
1095
int dbgconsole_getavailable() ICODE_ATTR;
1120
int dbgconsole_getavailable() ICODE_ATTR;
1096
int dbgconsole_getavailable()
1121
int dbgconsole_getavailable()
1097
{
1122
{
1098
    int available = dbgconrecvwriteidx - dbgconrecvreadidx;
1123
    int available = dbgconrecvwriteidx - dbgconrecvreadidx;
1099
    if (available < 0) available += sizeof(dbgconrecvbuf);
1124
    if (available < 0) available += sizeof(dbgconrecvbuf);