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