bootcon.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Boot console: the earliest on-screen output.
  2. *
  3. * Draws 8x16 text straight into the boot framebuffer described at 0x600. It
  4. * needs no heap, no paging (the LFB is identity-accessible), no drivers and
  5. * no shadow buffer, so it can be the first C code in kernel_main. Purpose:
  6. * stage tracing on machines without serial, and a last visible screen if the
  7. * kernel wedges before the WM paints. The WM's first frame covers it;
  8. * bootcon_set_enabled(0) stops drawing before that happens. The face, cell
  9. * grid and top-left origin match the BIOS loader text and the ring-3
  10. * terminal, and a full screen scrolls instead of wrapping.
  11. */
  12. #ifndef BOOTCON_H
  13. #define BOOTCON_H
  14. #define BOOTCON_LOG_PAGES 8
  15. /* Ring for the storage scan thread's own serial output (see bootcon.c). It
  16. * is allocated on demand from the frame allocator, not BSS. */
  17. #define BOOTCON_SCAN_PAGES 4
  18. /* Always-on COM1 capture used by `seriallog save` and the bootscan window.
  19. * The xHCI/USB/touchpad debug lines go here even though the UART is absent.
  20. * The buffer keeps the newest bytes (it drops the older half when full), so
  21. * a live window can keep tailing a long uptime. */
  22. #define BOOTCON_SERLOG_PAGES 32
  23. void bootcon_init(void);
  24. int bootcon_ok(void);
  25. void bootcon_set_enabled(int on);
  26. void bootcon_puts(const char *s);
  27. /* Switch drawing to the LFB's kernel address once paging is on (the LFB may
  28. * live in the ioremap window, not at its physical address); 0 is ignored. */
  29. void bootcon_set_lfb(void *va);
  30. void bootcon_dec(unsigned int v);
  31. void bootcon_hex(unsigned int v);
  32. /* One line with the cached mode geometry and LFB address. */
  33. void bootcon_fb_info(void);
  34. /* Allocate the RAM log after the page allocator is up. The buffer is taken
  35. * from the frame allocator, not BSS, to keep _end below the 0x90000 wall. */
  36. void bootcon_log_init(void);
  37. /* Everything written through bootcon_puts() after bootcon_log_init(),
  38. * including text produced after the WM has taken over the framebuffer. The
  39. * returned buffer is NUL terminated; *len is the number of valid bytes. */
  40. const char *bootcon_log(unsigned int *len);
  41. int bootcon_log_truncated(void);
  42. /* Unified view for the `bootscan` window (SYS_BOOTLOG). `src` is
  43. * SYS_BOOTLOG_BOOT/SERIAL/SCAN from syscall.h. stat fills the absolute
  44. * counters; `start` is the oldest byte still available (0 for the linear boot
  45. * console log). read copies from absolute offset off and returns the byte
  46. * count (0 when there is nothing left). */
  47. int bootcon_log_stat(int src, unsigned int *total, unsigned int *start,
  48. unsigned int *cap, int *active);
  49. unsigned int bootcon_log_read(int src, unsigned int off, char *dst,
  50. unsigned int max);
  51. /* Capture the bootscan kernel thread's serial output. begin() is called by
  52. * the thread itself (it allocates the ring and records the thread pid), end()
  53. * stops the capture when the thread returns. serial_putc() feeds every COM1
  54. * character through bootcon_scan_char(), which keeps only the owning
  55. * thread's output. The ring survives end() so the `bootscan` window can
  56. * still tail the completed log. */
  57. void bootcon_scan_begin(void);
  58. void bootcon_scan_end(void);
  59. void bootcon_scan_char(char c);
  60. /* Copy up to max bytes from absolute offset off; off is clamped to the
  61. * oldest byte still in the ring. Returns the byte count. */
  62. unsigned int bootcon_scan_read(unsigned int off, char *dst, unsigned int max);
  63. /* Always-on COM1 log (independent of the bootscan thread). It is seeded with
  64. * the characters captured before the page allocator was up and then keeps
  65. * the newest bytes in a BOOTCON_SERLOG_PAGES ring: when full, the older half
  66. * is dropped (the returned buffer stays contiguous for `seriallog save`). */
  67. void bootcon_serlog_char(char c);
  68. const char *bootcon_serlog(unsigned int *len);
  69. int bootcon_serlog_truncated(void);
  70. #endif