⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kern_kernstream.cxx

📁 C++ 编写的EROS RTOS
💻 CXX
字号:
/* * Copyright (C) 2001, Jonathan S. Shapiro. * * This file is part of the EROS Operating System. * * This program 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 2, * or (at your option) any later version. * * This program 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 this program; if not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <kerninc/kernel.hxx>#include <kerninc/util.h>#include <kerninc/KernStream.hxx>#ifdef OPTION_DDBbool KernStream::debuggerIsActive = false;KernStream *KernStream::dbg_stream = 0;#endifKernStream *KernStream::syscon_stream = 0;KernStream *KernStream::log_stream = 0;voidKernStream::InitStreams(){  LogStream->Init();  ConsoleStream->Init();#ifdef OPTION_DDB_ON_TTY0  SerialStream->Init();#endif  syscon_stream = ConsoleStream;  log_stream = LogStream;#if defined(OPTION_DDB_ON_CONSOLE)  dbg_stream = ConsoleStream;#elif defined(OPTION_DDB_ON_TTY0)  dbg_stream = SerialStream;#endif    #ifdef OPTION_DDB  /* If the debugger stream is set to point to the console device,   * turn off the syscon_stream so that we do not see duplicated   * output. */  if (dbg_stream == ConsoleStream)    syscon_stream = 0;#endif /* OPTION_DDB */  printf("Kernel streams initialized...\n");}boolKernStream::IsPrint(uint8_t c){  if (c > 127)    return false;    static uint8_t isPrint[16] = {	/* really a bitmask! */    0x00,			/* BEL ACK ENQ EOT ETX STX SOH NUL */    0x00,			/* SI  SO  CR  FF  VT  LF  TAB BS */    0x00,			/* ETB SYN NAK DC4 DC3 DC2 DC1 DLE */    0x00,			/* US  RS  GS  FS  ESC SUB EM  CAN */    0xff,			/* '   &   %   $   #   "   !   SPC */    0xff,			/* /   .   -   ,   +   *   )   ( */    0xff,			/* 7   6   5   4   3   2   1   0 */    0xff,			/* ?   >   =   <   ;   :   9   8 */    0xff,			/* G   F   E   D   C   B   A   @ */    0xff,			/* O   N   M   L   K   J   I   H */    0xff,			/* W   V   U   T   S   R   Q   P */    0xff,			/* _   ^   ]   \   [   Z   Y   X */    0xff,			/* g   f   e   d   c   b   a   ` */    0xff,			/* o   n   m   l   k   j   i   h */    0xff,			/* w   v   u   t   s   r   q   p */    0x7f,			/* DEL ~   }   |   {   z   y   x */  } ;  uint8_t mask = isPrint[(c >> 3)];  c &= 0x7u;  if (c)    mask >>= c;  if (mask & 1)    return true;  return false;}voidKernStream::do_putc(char c){#ifdef OPTION_DDB  if (dbg_stream) dbg_stream->Put(c);#endif  if (syscon_stream) syscon_stream->Put(c);#ifdef OPTION_DDB  if (log_stream && !debuggerIsActive) log_stream->Put(c);#else  if (log_stream) log_stream->Put(c);#endif}voidKernStream::PutBuf(uint8_t *s, uint32_t len){  for (uint32_t i = 0; i < len; i++)    nl_putc(s[i]);}voidKernStream::nl_putc(char c){  if (c == '\n')    do_putc('\r');  do_putc(c);}#ifdef OPTION_DDBuint8_tKernStream::Get(){  fatal("Fatal call to KernStream::Get() made.\n");  return ASCII::SPC;}voidKernStream::SetDebugging(bool onOff){  fatal("Fatal call to KernStream::SetDebugging() made.\n");}#endifextern "C" void __pure_virtual(void);void__pure_virtual(void){  fatal("pure virtual function called\n");}void KernStream::BeginUserThreads(){  printf("Starting first thread. Console output now disabled...\n");  syscon_stream = 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -