60 while (len && !buf[len - 1]) len--;
65 while (*str && len && (*str == *buf))
73 return (!len && !*str);
89 while (len && *str ==
' ')
95 while (len && (*str >=
'0' && *str <
'8'))
97 value = (value << 3) | (*str -
'0');
103 while (len && *str ==
' ')
110 if (len && *str)
return -1;
126 while (num--) *dst++ =
value;
141 void *
memcpy(
void *destination,
const void *source,
size_t num)
143 uint8_t *dst = destination;
144 const uint8_t *src = source;
145 while (num--) *dst++ = *src++;
159 void *
memmove(
void *destination,
const void *source,
size_t num)
161 if (destination < source || destination >= source + num)
162 return memcpy(destination, source, num);
163 else if (destination != source)
165 uint8_t *dst = (uint8_t *)destination + num - 1;
166 uint8_t *src = (uint8_t *)source + num - 1;
167 while (num--) *dst-- = *src--;
183 asm(
".text\n.align 4\n" 184 ".globl debugCaptureCpuContext\n" 185 "debugCaptureCpuContext:\n" 187 " movl 8(%esp), %eax\n" 190 " movl %ecx, 0x2C(%eax)\n" 191 " movl %edx, 0x30(%eax)\n" 192 " movl %ebx, 0x34(%eax)\n" 193 " leal 4(%esp), %edx\n" 194 " movl %edx, 0x38(%eax)\n" 195 " movl %ebp, 0x3C(%eax)\n" 196 " movl %esi, 0x40(%eax)\n" 197 " movl %edi, 0x44(%eax)\n" 199 " movw %es, 0x48(%eax)\n" 200 " movw %cs, 0x4C(%eax)\n" 201 " movw %ss, 0x50(%eax)\n" 202 " movw %ds, 0x54(%eax)\n" 203 " movw %fs, 0x58(%eax)\n" 204 " movw %gs, 0x5C(%eax)\n" 207 " movl %edx, 0x1C(%eax)\n" 208 " movl (%esp), %edx\n" 209 " movl %edx, 0x20(%eax)\n" 230 const char *lines[] =
232 " ASSERTION FAILED ",
233 " Assertion: ", assertion,
235 "\n Function: ",
function,
253 const char *lines[] =
256 " Unimplemented code section reached.",
259 "\n Function: ",
function,
uint32_t stringLength(const char *str)
Returns the length of a nullterminated string.
void * memcpy(void *destination, const void *source, size_t num)
Copies a block of memory from source to destination.
bool stringIsEqual(const char *str, const char *buf, uint32_t len)
Checks if the string is equal to the memory region.
void debugCaptureCpuContext(struct taskContext *context)
Fills out the task context structure with the values from the currently running code.
void * memmove(void *destination, const void *source, size_t num)
Moves a block of memory from source to destination.
void * memset(void *ptr, int value, size_t num)
Fills a memory region with some specific byte value.
uint32_t stringParseOctal(const char *str, uint32_t len)
Converts an octal string to a integer number.
void consoleSystemFailure(const char **lines, uint32_t numArgs, uint32_t *args, struct taskContext *context)
Print a system failure message and halts the system.
void debugNotImplemented(const char *file, const char *function, const char *line, struct taskContext *context)
Used internally to implement NOTIMPLEMENTED()
void debugAssertFailed(const char *assertion, const char *file, const char *function, const char *line, struct taskContext *context)
Used internally to implement assert()