aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / core / klog.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* klog.h -- RAM copy of the console output, so a board with no serial line |
| 18 | * attached (the hub Raspberry Pi 5) can write it to its card before the |
| 19 | * reset (core/klog_slot.c). The first CK_KLOG_HEAD bytes are kept in order; |
| 20 | * after that the newest CK_KLOG_TAIL bytes are kept in a ring, so both the |
| 21 | * start of the boot and the lines right before a failure survive. Pure: |
| 22 | * no device access, no allocation. Host test: tests/test_klog.c. */ |
| 23 | #ifndef AIENOS_CK_KLOG_H |
| 24 | #define AIENOS_CK_KLOG_H |
| 25 | #include <stddef.h> |
| 26 | #include <stdint.h> |
| 27 | |
| 28 | #define CK_KLOG_HEAD (192u * 1024u) |
| 29 | #define CK_KLOG_TAIL (64u * 1024u) |
| 30 | /* Largest ck_klog_read output: head + the dropped-bytes line + tail. */ |
| 31 | #define CK_KLOG_MAX (CK_KLOG_HEAD + 64u + CK_KLOG_TAIL) |
| 32 | |
| 33 | void ck_klog_put(const char *s, size_t n); |
| 34 | /* Copies the log into out: the head, then "\n[klog: N bytes dropped]\n" when |
| 35 | * the ring overwrote anything, then the ring oldest first. Stops at cap. |
| 36 | * Returns the bytes written. */ |
| 37 | size_t ck_klog_read(char *out, size_t cap); |
| 38 | /* Every byte ever put, kept or not. */ |
| 39 | uint64_t ck_klog_total(void); |
| 40 | /* Empties the log (tests). */ |
| 41 | void ck_klog_clear(void); |
| 42 | #endif |