Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/util/screen.c need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #include "smp/spinlock.h"
0019 #include "util/screen.h"
0020 #include "util/debug.h"
0021 
0022 spinlock screen_lock = { 0 };
0023 
0024 int
0025 _putchar (int ch)
0026 {
0027 
0028   static int x, y;
0029 
0030   if (ch == '\n') {
0031     x = 0;
0032     y++;
0033 
0034     if (y > 24)
0035       y = 0;
0036 
0037     return (int) (uint8) ch;
0038   }
0039 
0040   pchVideo[y * 160 + x * 2] = ch;
0041   pchVideo[y * 160 + x * 2 + 1] = 7;
0042   x++;
0043 
0044   return (int) (uint8) ch;
0045 }
0046 
0047 int
0048 putchar (int ch)
0049 {
0050   int x;
0051   spinlock_lock (&screen_lock);
0052   x = _putchar (ch);
0053   spinlock_unlock (&screen_lock);
0054   return x;
0055 }
0056 
0057 int
0058 print (char *pch)
0059 {
0060   spinlock_lock (&screen_lock);
0061   while (*pch)
0062     _putchar (*pch++);
0063   spinlock_unlock (&screen_lock);
0064   return 0;
0065 }
0066 
0067 
0068 void
0069 putx (uint32 l)
0070 {
0071 
0072   int i, li;
0073 
0074   spinlock_lock (&screen_lock);
0075   for (i = 7; i >= 0; i--)
0076     if ((li = (l >> (i << 2)) & 0x0F) > 9)
0077       _putchar ('A' + li - 0x0A);
0078     else
0079       _putchar ('0' + li);
0080   spinlock_unlock (&screen_lock);
0081 }
0082 
0083 int
0084 _print (char *pch)
0085 {
0086   while (*pch)
0087     _putchar (*pch++);
0088   return 0;
0089 }
0090 
0091 
0092 void
0093 _putx (uint32 l)
0094 {
0095 
0096   int i, li;
0097 
0098   for (i = 7; i >= 0; i--)
0099     if ((li = (l >> (i << 2)) & 0x0F) > 9)
0100       _putchar ('A' + li - 0x0A);
0101     else
0102       _putchar ('0' + li);
0103 }
0104 
0105 /* 
0106  * Local Variables:
0107  * indent-tabs-mode: nil
0108  * mode: C
0109  * c-file-style: "gnu"
0110  * c-basic-offset: 2
0111  * End: 
0112  */
0113 
0114 /* vi: set et sw=2 sts=2: */