libc_glue.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. void _exit(int status) {
  2. uart_puts("-- clib exit called. hanging.\r\n");
  3. memcpy(FB, (uint32_t*)0x200000, 1920*1080*4);
  4. while (1) {
  5. uart_putc(uart_getc());
  6. }
  7. }
  8. void* _sbrk(int incr)
  9. {
  10. uart_puts("-- sbrk: ");
  11. printhex((uint32_t)heap_end);
  12. uart_puts(" ");
  13. printhex_signed(incr);
  14. uart_puts("\r\n");
  15. uint8_t* prev_heap_end;
  16. prev_heap_end = heap_end;
  17. heap_end += incr;
  18. return (void*)prev_heap_end;
  19. }
  20. void _kill() {
  21. uart_puts("-- clib kill called. not implemented.\r\n");
  22. }
  23. int _getpid() {
  24. uart_puts("-- clib getpid_r called. stubbed.\r\n");
  25. return 1;
  26. }
  27. int _isatty_r() {
  28. uart_puts("-- clib isatty_r called. stubbed.\r\n");
  29. return 1;
  30. }
  31. int _close() {
  32. uart_puts("-- clib close called. stubbed.\r\n");
  33. return 1;
  34. }
  35. int _fstat() {
  36. //uart_puts("-- clib fstat called. stubbed.\n");
  37. return 0;
  38. }
  39. int _fseek() {
  40. //uart_puts("-- clib fseek called. stubbed.\n");
  41. return 0;
  42. }
  43. int _lseek() {
  44. //uart_puts("-- clib lseek called. stubbed.\n");
  45. return 0;
  46. }
  47. int _read() {
  48. //uart_puts("-- clib read called. stubbed.\n");
  49. return 0;
  50. }
  51. size_t _write(int fildes, const void *buf, size_t nbytes) {
  52. //uart_puts("-- clib write called:\n");
  53. for (int i=0; i<nbytes; i++) {
  54. uart_putc(((char*)buf)[i]);
  55. }
  56. return nbytes;
  57. }
  58. int _fini() {
  59. uart_puts("-- clib _fini called. stubbed.\n");
  60. return 0;
  61. }