128 lines
4.2 KiB
C
128 lines
4.2 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Desc: Terminal-related functions //
|
|
// //
|
|
// //
|
|
// Copyright © 2018-2019 The OS/K Team //
|
|
// //
|
|
// This file is part of OS/K. //
|
|
// //
|
|
// OS/K is free software: you can redistribute it and/or modify //
|
|
// it under the terms of the GNU General Public License as published by //
|
|
// the Free Software Foundation, either version 3 of the License, or //
|
|
// any later version. //
|
|
// //
|
|
// OS/K 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 General Public License for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU General Public License //
|
|
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#ifndef _KALKERN_PROC_H
|
|
#include <kernel/proc.h> // for GetCurProc() and Process_t
|
|
#endif
|
|
|
|
#ifndef _KALKERN_TERM_H
|
|
#define _KALKERN_TERM_H
|
|
|
|
//------------------------------------------//
|
|
|
|
//
|
|
// Size of a tabulation in spaces
|
|
// Default: 4 spaces/tab
|
|
//
|
|
enum { KTABSIZE = 4 };
|
|
|
|
//
|
|
// Upper bound on what a single KernLog() can write
|
|
//
|
|
enum { KLOG_MAX_BUFSIZE = 4096 };
|
|
|
|
//
|
|
// The VGA colors
|
|
//
|
|
enum TermColor_t
|
|
{
|
|
KTERM_COLOR_BLACK, KTERM_COLOR_BLUE,
|
|
KTERM_COLOR_GREEN, KTERM_COLOR_CYAN,
|
|
KTERM_COLOR_RED, KTERM_COLOR_MAGENTA,
|
|
KTERM_COLOR_BROWN, KTERM_COLOR_LGREY,
|
|
KTERM_COLOR_DARK_GREY, KTERM_COLOR_LBLUE,
|
|
KTERM_COLOR_LGREEN, KTERM_COLOR_LCYAN,
|
|
KTERM_COLOR_LRED, KTERM_COLOR_LMAGENTA,
|
|
KTERM_COLOR_LBROWN, KTERM_COLOR_WHITE
|
|
};
|
|
|
|
//
|
|
// Terminal structure, right now VGA and output only
|
|
//
|
|
struct Terminal_t
|
|
{
|
|
uint initDone;
|
|
Lock_t lock;
|
|
|
|
const char *name;
|
|
const char *type;
|
|
|
|
void *data;
|
|
|
|
size_t width;
|
|
size_t height;
|
|
off_t currentX;
|
|
off_t currentY;
|
|
|
|
uint tabSize;
|
|
TermColor_t fgColor;
|
|
TermColor_t bgColor;
|
|
|
|
// Defined in driver
|
|
error_t (*ClearTermUnlocked)(Terminal_t *);
|
|
error_t (*PutOnTermUnlocked)(Terminal_t *, char);
|
|
error_t (*PrintOnTermUnlocked)(Terminal_t *, const char *);
|
|
};
|
|
|
|
//------------------------------------------//
|
|
|
|
void InitTerms(void);
|
|
error_t ClearTerm(Terminal_t *);
|
|
error_t PutOnTerm(Terminal_t *, char);
|
|
error_t PrintOnTerm(Terminal_t *, const char *);
|
|
error_t ChTermColor(Terminal_t *, TermColor_t, TermColor_t);
|
|
|
|
error_t KernLog(const char *, ...);
|
|
|
|
//------------------------------------------//
|
|
|
|
extern Terminal_t *stdOut;
|
|
#define GetStdOut() (stdOut)
|
|
#define SetStdOut(x) (stdOut = (x))
|
|
|
|
// Debug purposes
|
|
volatile ushort *vga;
|
|
|
|
//------------------------------------------//
|
|
|
|
#ifndef _NO_DEBUG
|
|
|
|
extern Terminal_t *stdDbg;
|
|
#define GetStdDbg() (stdDbg)
|
|
#define SetStdDbg(x) (stdDbg = (x))
|
|
|
|
error_t DebugLog(const char *, ...);
|
|
|
|
#else // _NO_DEBUG
|
|
|
|
#define GetStdDbg() NULL
|
|
#define SetStdDbg(x) ((void)0)
|
|
#define DebugLog(fmt, ...) EOK
|
|
|
|
#endif
|
|
|
|
//------------------------------------------//
|
|
|
|
#endif
|