fbfs.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #define WIDTH 1920
  2. #define HEIGHT 1080
  3. #define BPP 2
  4. #define DEPTH 16
  5. #include "stream.h"
  6. static uint32_t* _fb;
  7. Cell* fbfs_open() {
  8. return alloc_int(1);
  9. }
  10. Cell* fbfs_read() {
  11. return alloc_int(0);
  12. }
  13. Cell* fbfs_delete() {
  14. return alloc_int(0);
  15. }
  16. Cell* fbfs_write(Cell* arg) {
  17. return NULL;
  18. }
  19. Cell* fbfs_mmap(Cell* arg) {
  20. long sz = WIDTH*HEIGHT*BPP;
  21. printf("[fbfs_mmap] addr: %p\r\n",_fb);
  22. if (_fb>0) {
  23. Cell* buffer_cell = alloc_int(0);
  24. buffer_cell->ar.addr = _fb;
  25. buffer_cell->dr.size = sz;
  26. buffer_cell->tag = TAG_BYTES;
  27. printf("[fbfs_mmap] buffer_cell->ar.addr: %p\r\n",buffer_cell->ar.addr);
  28. return buffer_cell;
  29. } else {
  30. return alloc_nil();
  31. }
  32. }
  33. void mount_fbfs(uint32_t* fb) {
  34. _fb = fb;
  35. fs_mount_builtin("/framebuffer", fbfs_open, fbfs_read, fbfs_write, fbfs_delete, fbfs_mmap);
  36. insert_global_symbol(alloc_sym("screen-width"),alloc_int(WIDTH));
  37. insert_global_symbol(alloc_sym("screen-height"),alloc_int(HEIGHT));
  38. insert_global_symbol(alloc_sym("screen-bpp"),alloc_int(BPP));
  39. }