read.c 893 B

12345678910111213141516171819202122232425262728293031
  1. /* See LICENSE of license details. */
  2. #include <stdint.h>
  3. #include <errno.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6. #include "stub.h"
  7. ssize_t _read(int fd, void* ptr, size_t len)
  8. {
  9. // The below code was copied from freedom-e-sdk, but seems it is definitely wrong, so just comment it out
  10. // Need to implement this function in the future, otherwise cannot use the C scanf function
  11. //uint8_t * current = (uint8_t *)ptr;
  12. //volatile uint32_t * uart_rx = (uint32_t *)(UART0_CTRL_ADDR + UART_REG_RXFIFO);
  13. //volatile uint8_t * uart_rx_cnt = (uint8_t *)(UART0_CTRL_ADDR + UART_REG_RXCTRL + 2);
  14. //ssize_t result = 0;
  15. //if (isatty(fd)) {
  16. // for (current = (uint8_t *)ptr;
  17. // (current < ((uint8_t *)ptr) + len) && (*uart_rx_cnt > 0);
  18. // current ++) {
  19. // *current = *uart_rx;
  20. // result++;
  21. // }
  22. // return result;
  23. //}
  24. return _stub(EBADF);
  25. }