/to_shout

to_shout - Bare-Metal Output Library

Primary LanguageCGNU Lesser General Public License v3.0LGPL-3.0

to_shout - Bare-Metal Output Library

License: LGPL v3

A lightweight, platform-independent output library designed for bare-metal environments, embedded systems, and OS kernel development. No standard library dependencies required!

Features

  • Platform Independent: Works on any system with VGA text mode or custom output implementation
  • Type-Aware Output: Automatically detects variable types and formats output appropriately
  • Multiple Formats: Supports decimal, hexadecimal, and binary output
  • Color Support: Change text colors for better debugging visibility
  • No Dependencies: Doesn't require any standard library functions
  • Bare-Metal Ready: Perfect for OS development, bootloaders, and embedded systems

Installation

Simply include to_shout.h in your project:

#include "to_shout.h"

Quick Start

// Initialize VGA output
vga_init();

// Basic output
to_shout("Hello, bare-metal world!");
to_shout(42);
to_shout(-123456789);
to_shout(3.14159f);

// Specialized output
to_shout_hex(0xDEADBEEF);    // Output as hexadecimal
to_shout_bin(0b10101010);    // Output as binary

// Colored output
set_color(COLOR_YELLOW, COLOR_BLACK);
to_shout("Warning message!");
set_color(COLOR_RED, COLOR_BLACK);
to_shout("Error message!");

// System information
to_shout_info();

API Reference

Core Functions

  • to_shout(x) - Type-aware output for any supported type
  • to_shout_hex(x) - Output value as hexadecimal
  • to_shout_bin(x) - Output value as binary
  • to_shout_info() - Display system information

Output Control

  • vga_init() - Initialize VGA screen
  • set_color(foreground, background) - Set text colors
  • platform_putchar(c) - Low-level character output

Supported Types

  • Integers (int, long)
  • Floating point (float, double)
  • Characters (char)
  • Strings (char*, const char*)
  • Hexadecimal output (unsigned int)
  • Binary output (unsigned int)

Customization

To adapt for different platforms, modify the platform_putchar() function:

// Example for UART output
static inline void platform_putchar(char c) {
    while (!(UART_STATUS & UART_READY)) {}
    UART_DATA = c;
    if (c == '\n') platform_putchar('\r');
}

Examples

Basic Usage

vga_init();
to_shout("Booting system...");
to_shout(42);
to_shout(3.14159);
to_shout_hex(0x123ABC);

Error Reporting

set_color(COLOR_RED, COLOR_BLACK);
to_shout("ERROR: Invalid memory address");
to_shout_hex(memory_address);
set_color(COLOR_WHITE, COLOR_BLACK); // Reset to default

Debug Output

// Debug function with color coding
void debug_message(const char* msg, int value) {
    set_color(COLOR_CYAN, COLOR_BLACK);
    print_str("[DEBUG] ");
    set_color(COLOR_WHITE, COLOR_BLACK);
    print_str(msg);
    print_str(": ");
    to_shout(value);
}

License

This project is licensed under the LGPL-3.0 License - see the LGPL-3.0 for details.

Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Acknowledgments

  • Inspired by the need for simple output in bare-metal environments
  • Designed for educational use in OS development courses
  • Tested on x86 real mode and protected mode

Support

If you find this library useful, please give it a star on GitHub!