Add brand.h.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-07-10 21:37:07 +02:00
parent b5509037bc
commit 6a9eee3238
6 changed files with 119 additions and 54 deletions

103
libc/include/brand.h Normal file
View File

@ -0,0 +1,103 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
brand.h
Macros expanding to the name of the operating system and distribution.
*******************************************************************************/
#ifndef INCLUDE_BRAND_H
#define INCLUDE_BRAND_H
/* The name of the distribution of the operation system. */
#define BRAND_DISTRIBUTION_NAME "Sortix"
/* The website of the distribution. */
#define BRAND_DISTRIBUTION_WEBSITE "http://sortix.org"
/* The name of the operating system. */
#define BRAND_OPERATING_SYSTEM_NAME "Sortix"
/* The name of the kernel. */
#define BRAND_KERNEL_NAME "Sortix Kernel"
/* Ascii version of the maxsi logo. */
#define BRAND_MAXSI \
" _ \n" \
" / \\ \n" \
" /\\ /\\ / \\ \n" \
" / \\ / \\ | | \n" \
" / \\/ \\ | | \n" \
" | O O \\_______________________ / | \n" \
" | | \n" \
" | \\_______/ / \n" \
" \\ / \n" \
" ------ --------------- ---/ \n" \
" / \\ / \\ \n" \
" / \\ / \\ \n" \
" / \\ / \\ \n" \
" /_____________\\ /____________\\ \n" \
" \n" \
/* Dead version of the maxsi logo, used for panic screens and such. */
#define BRAND_MAXSI_DEAD \
" _ \n" \
" / \\ \n" \
" /\\ /\\ / \\ \n" \
" / \\ / \\ | | \n" \
" / \\/ \\ | | \n" \
" | X X \\_______________________ / | \n" \
" | | \n" \
" | _________ / \n" \
" \\ / \n" \
" ------ --------------- ---/ \n" \
" / \\ / \\ \n" \
" / \\ / \\ \n" \
" / \\ / \\ \n" \
" /_____________\\ /____________\\ \n" \
" \n" \
/* Message printed by the kernel just after boot. */
#define BRAND_KERNEL_BOOT_MESSAGE \
"\e[37;41m\e[2J" \
BRAND_MAXSI \
" BOOTING OPERATING SYSTEM... "
/* Message printed by init after it takes control. */
#define BRAND_INIT_BOOT_MESSAGE \
"\r\e[m\e[J"
/* Message printed when a critical error occurs and the system panics. */
#define BRAND_PANIC_LONG \
"\e[m\e[31;40m\e[2J\e[H" \
BRAND_MAXSI_DEAD \
" \n" \
" RED MAXSI OF DEATH \n" \
" \n" \
"A critical error occured within the kernel of the operating system and it has\n" \
"forcefully shut down as a last resort.\n" \
"\n" \
"Technical information:\n" \
/* Short version of the panic version that consumes minimal space. */
#define BRAND_PANIC_SHORT \
"\e[m\e[31m\e[0J" \
"RED MAXSI OF DEATH\n" \
#endif

View File

@ -26,6 +26,7 @@
#include <sys/types.h>
#include <assert.h>
#include <brand.h>
#include <errno.h>
#include <malloc.h>
#include <stddef.h>
@ -104,30 +105,9 @@ extern "C" { size_t stack[STACK_SIZE / sizeof(size_t)] = {0}; }
namespace Sortix {
void DoMaxsiLogo()
{
Log::Print("\e[37;41m\e[2J"); // Make the background color red.
Log::Print(" _ \n");
Log::Print(" / \\ \n");
Log::Print(" /\\ /\\ / \\ \n");
Log::Print(" / \\ / \\ | | \n");
Log::Print(" / \\/ \\ | | \n");
Log::Print(" | O O \\_______________________ / | \n");
Log::Print(" | | \n");
Log::Print(" | \\_______/ / \n");
Log::Print(" \\ / \n");
Log::Print(" ------ --------------- ---/ \n");
Log::Print(" / \\ / \\ \n");
Log::Print(" / \\ / \\ \n");
Log::Print(" / \\ / \\ \n");
Log::Print(" /_____________\\ /____________\\ \n");
Log::Print(" \n");
}
void DoWelcome()
{
DoMaxsiLogo();
Log::Print(" BOOTING OPERATING SYSTEM... ");
Log::Print(BRAND_KERNEL_BOOT_MESSAGE);
}
// Forward declarations.

View File

@ -22,6 +22,7 @@
*******************************************************************************/
#include <brand.h>
#include <errno.h>
#include <sortix/kernel/kernel.h>
@ -38,7 +39,7 @@ namespace Info {
const char* KernelInfo(const char* req)
{
if ( strcmp(req, "name") == 0 ) { return "Sortix"; }
if ( strcmp(req, "name") == 0 ) { return BRAND_KERNEL_NAME; }
if ( strcmp(req, "version") == 0 ) { return VERSIONSTR; }
if ( strcmp(req, "builddate") == 0 ) { return __DATE__; }
if ( strcmp(req, "buildtime") == 0 ) { return __TIME__; }

View File

@ -22,6 +22,7 @@
*******************************************************************************/
#include <brand.h>
#include <string.h>
#include <sortix/kernel/calltrace.h>
@ -43,35 +44,12 @@ static bool doublepanic = false;
static void PanicLogoLong()
{
Log::Print("\e[m\e[31;40m\e[2J\e[H");
Log::Print(" _ \n");
Log::Print(" / \\ \n");
Log::Print(" /\\ /\\ / \\ \n");
Log::Print(" / \\ / \\ | | \n");
Log::Print(" / \\/ \\ | | \n");
Log::Print(" | X X \\_______________________ / | \n");
Log::Print(" | | \n");
Log::Print(" | _________ / \n");
Log::Print(" \\ / \n");
Log::Print(" ------ --------------- ---/ \n");
Log::Print(" / \\ / \\ \n");
Log::Print(" / \\ / \\ \n");
Log::Print(" / \\ / \\ \n");
Log::Print(" /_____________\\ /____________\\ \n");
Log::Print(" \n");
Log::Print(" \n");
Log::Print(" RED MAXSI OF DEATH \n");
Log::Print(" \n");
Log::Print("A critical error occured within the kernel of the operating system and it has\n");
Log::Print("forcefully shut down as a last resort.\n");
Log::Print("\n");
Log::Print("Technical information:\n");
Log::PrintF(BRAND_PANIC_LONG);
}
static void PanicLogoShort()
{
Log::Print("\e[m\e[31m\e[0J");
Log::Print("RED MAXSI OF DEATH\n");
Log::Print(BRAND_PANIC_SHORT);
}
void PanicInit()

View File

@ -28,6 +28,7 @@
#include <sys/wait.h>
#include <assert.h>
#include <brand.h>
#include <dirent.h>
#include <errno.h>
#include <error.h>
@ -454,7 +455,7 @@ int main(int /*argc*/, char* /*argv*/[])
return 2;
// Reset the terminal's color and the rest of it.
printf("\r\e[m\e[J");
printf(BRAND_INIT_BOOT_MESSAGE);
fflush(stdout);
// Set the default file creation mask.

View File

@ -21,13 +21,15 @@
*******************************************************************************/
#include <sys/kernelinfo.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <brand.h>
#include <errno.h>
#include <error.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(VERSIONSTR)
#define VERSIONSTR "unknown version"
@ -99,7 +101,7 @@ const char* GetHardwarePlatform()
const char* GetOperatingSystem()
{
return GetKernelName();
return BRAND_OPERATING_SYSTEM_NAME;
}
bool has_printed = false;