VT100 Terminal App
Circle VT100 module documentation
Loading...
Searching...
No Matches
kernel.h
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Module: kernel.h
3// Description: Main entry point for Pi_VT100, a VT100 emulator running
4// on Pi zero bare metal implementation based on Circle
5// Author: R. Zuehlsdorff, ralf.zuehlsdorff@t-online.de
6// Created: 2026-01-18
7// License: MIT License (https://opensource.org/license/mit/)
8//------------------------------------------------------------------------------
9// Change Log:
10// 2026-01-18 R. Zuehlsdorff Initial creation
11//------------------------------------------------------------------------------
12
13#pragma once
14
15// Include Circle core components
16#include <circle/types.h>
17#include <circle/koptions.h>
18#include <circle/devicenameservice.h>
19#include <circle/device.h>
20#include <circle/exceptionhandler.h>
21#include <circle/interrupt.h>
22#include <circle/logger.h>
23#include <circle/net/netsubsystem.h>
24#include <circle/serial.h>
25#include <circle/screen.h>
26#include <circle/sched/scheduler.h>
27#include <circle/timer.h>
28#include <circle/usb/usbhcidevice.h>
29#include <circle/nulldevice.h>
30#include <SDCard/emmc.h>
31#include <fatfs/ff.h>
32#include <wlan/bcm4343.h>
33#include <wlan/hostap/wpa_supplicant/wpasupplicant.h>
34
35// Forward declarations for class references used in this module
36class CTWlanLog;
37class CTRenderer;
38class CTFontConverter;
39class CTKeyboard;
40class CTConfig;
41class CTUART;
42class CTFileLog;
43class CTSetup;
44class CVTTest;
45
46#include "hal.h"
47
57enum TShutdownMode
58{
59 ShutdownNone,
60 ShutdownHalt,
61 ShutdownReboot
62};
63
73{
74public:
76 CKernel(void);
78 ~CKernel(void);
79
81 static CKernel *Get(void);
82
84 boolean Initialize(void);
85
87 TShutdownMode Run(void);
88
90 bool IsTelnetReady() const;
92 void MarkTelnetReady();
94 void MarkTelnetWaiting();
96 void ApplyRuntimeConfig();
97
99 void ToggleSetupDialog();
103 bool IsLocalModeEnabled() const;
105 void ToggleLocalMode();
106
108 bool HandleVTTestKey(const char *pString);
109
111 void RunVTTestTick();
112
114 void SendHostOutput(const char *pData, size_t nLength);
116 void HandleWlanHostRx(const char *pData, size_t nLength);
117
118protected:
120 boolean initFilesystem(void);
121
122private:
124 void EnsureSerialTaskStarted();
126 void ProcessSerial();
127
128 // do not change this order - some members depend on others
129 CKernelOptions m_Options;
130 CDeviceNameService m_DeviceNameService;
131 CScreenDevice m_Screen;
132 CInterruptSystem m_Interrupt;
133 CLogger m_Logger;
134 CTimer m_Timer;
135 CScheduler m_Scheduler;
136 CUSBHCIDevice m_USBHCI;
137 CExceptionHandler m_ExceptionHandler;
138 CEMMCDevice m_EMMC;
139 FATFS m_FileSystem;
140 CHAL m_HAL;
141 CBcm4343Device m_WLAN;
142 CNetSubSystem m_Net;
143 CWPASupplicant m_WpaSupplicant;
144
145 // Tasks are created inside constructor and
146 // initialized in kernel::Initialize()
147 CTRenderer *m_pRenderer;
148 CTFontConverter *m_pFontConverter;
149 CTKeyboard *m_pKeyboard;
150 CTConfig *m_pConfig;
151 CTUART *m_pUART;
152 CTFileLog *m_pFileLog;
153 CTWlanLog *m_pWlanLog;
154 CTSetup *m_pSetup;
155 CVTTest *m_pVTTest;
156 CDevice *m_pLogTarget;
157 CNullDevice *m_pNullLog;
158
159 boolean m_bWlanLoggerEnabled;
160 boolean m_bMDNSAdvertised;
161 bool m_bSerialTaskStarted;
162 bool m_bTelnetReady;
163 bool m_bWaitingMessageActive;
164 bool m_bWaitingMessageShowsIP;
165 bool m_bScreenLoggerEnabled;
166 bool m_bLocalModeEnabled;
167};
Provides buzzer control, GPIO switching, and timing utilities.
Definition hal.h:43
Central coordinator for hardware bring-up and runtime control.
Definition kernel.h:73
CKernel(void)
Construct the kernel and wire up Circle subsystems.
Definition kernel.cpp:212
void ShowModernSetupDialog()
Show the modern on-screen setup dialog.
Definition kernel.cpp:309
~CKernel(void)
Release kernel-owned resources.
Definition kernel.cpp:284
void MarkTelnetWaiting()
Mark telnet service as waiting for configuration.
Definition kernel.cpp:799
bool HandleVTTestKey(const char *pString)
Forward a key press to the VT test runner (manual confirmation).
Definition kernel.cpp:325
TShutdownMode Run(void)
Enter the cooperative scheduler and main control loop.
Definition kernel.cpp:606
bool IsTelnetReady() const
Check whether the telnet service finished setup.
Definition kernel.cpp:666
boolean initFilesystem(void)
Mount the filesystem and prepare SD card access.
Definition kernel.cpp:334
void MarkTelnetReady()
Mark telnet service as ready for clients.
Definition kernel.cpp:671
bool IsLocalModeEnabled() const
Check whether keyboard input loopback mode is active.
Definition kernel.cpp:263
void RunVTTestTick()
Run periodic VT test tick (if enabled).
Definition kernel.cpp:317
void ToggleSetupDialog()
Toggle the on-screen setup dialog.
Definition kernel.cpp:301
void ToggleLocalMode()
Toggle local keyboard loopback mode.
Definition kernel.cpp:268
void SendHostOutput(const char *pData, size_t nLength)
Forward keyboard-generated host output to TCP host mode or UART fallback.
Definition kernel.cpp:721
void ApplyRuntimeConfig()
Apply current CTConfig values to runtime subsystems.
Definition kernel.cpp:700
void HandleWlanHostRx(const char *pData, size_t nLength)
Consume bytes received from WLAN host bridge and render them.
Definition kernel.cpp:742
boolean Initialize(void)
Initialize all VT100 subsystems and dependencies.
Definition kernel.cpp:367
static CKernel * Get(void)
Access the singleton kernel instance.
Definition kernel.cpp:75
Cooperative task responsible for configuration persistence and lookup.
Definition TConfig.h:54
Provides file-based persistence for Circle logger messages.
Definition TFileLog.h:39
Background task that materializes VT100 fonts on demand.
Definition TFontConverter.h:49
Cooperative task managing keyboard devices and event translation.
Definition TKeyboard.h:46
Combines Circle framebuffer access with a VT100-aware state machine.
Definition TRenderer.h:51
Definition TSetup.h:21
Task responsible for UART initialization and data retrieval.
Definition TUART.h:34
Network logging endpoint streaming log traffic to remote clients.
Definition TWlanLog.h:47
Definition VTTest.h:18
Declares the hardware abstraction layer for the VT100 firmware.