Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/sysprogs/terminal_server.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 <stdio.h>
0019 #include <string.h>
0020 
0021 static char *pchVideo = (char *) 0x000200000;   /* in middle of page table */
0022 
0023 static int
0024 _putchar (int ch, int attribute)
0025 {
0026 
0027   static int x, y;
0028 
0029   if (ch == '\n') {
0030     x = 0;
0031     y++;
0032 
0033     if (y > 24) {
0034       memcpy (pchVideo, pchVideo + 160, 24 * 160);
0035       memset (pchVideo + (24 * 160), 0, 160);
0036       y = 24;
0037     }
0038     return (int) (unsigned char) ch;
0039   }
0040 
0041   if (y * 160 + x * 2 >= 0x1000) return ch;
0042 
0043   pchVideo[y * 160 + x * 2] = ch;
0044   pchVideo[y * 160 + x * 2 + 1] = attribute;
0045   x++;
0046 
0047   if (y * 160 + x * 2 >= 0x1000) return ch;
0048 
0049   pchVideo[y * 160 + x * 2] = ' ';
0050   pchVideo[y * 160 + x * 2 + 1] = attribute;
0051 
0052   /* Move cursor */
0053   outb (0x0E, 0x3D4);           /* CRTC Cursor location high index */
0054   outb ((y * 80 + x) >> 8, 0x3D5);      /* CRTC Cursor location high data */
0055   outb (0x0F, 0x3D4);           /* CRTC Cursor location low index */
0056   outb ((y * 80 + x) & 0xFF, 0x3D5);    /* CRTC Cursor location low data */
0057 
0058   return (int) (unsigned char) ch;
0059 }
0060 
0061 
0062 void
0063 splash_screen (void)
0064 {
0065 
0066   char line1[80];
0067   char line2[80];
0068   char *p;
0069   int i;
0070 
0071   uname (line2);
0072 
0073   sprintf (line1,
0074            "**** Quest kernel version: %s *****   //---\\ \\\\  \\ //-- //--\\ \\\\---\\ \n",
0075            line2);
0076   for (p = line1; *p; p++)
0077     _putchar (*p, 4);
0078 
0079   sprintf (line1,
0080            "* Copyright Boston University, 2005 *   ||   | ||  | ||-- \\\\--\\   || \n");
0081   for (p = line1; *p; p++)
0082     _putchar (*p, 4);
0083 
0084   sprintf (line1, "%u", meminfo ());
0085   i = strlen (line1);
0086 
0087   for (i = strlen (line1); i < 16; i++)
0088     line2[i - strlen (line1)] = '*';
0089 
0090   sprintf (line1,
0091            "******** %u bytes free %s   \\\\__\\_  \\\\_/ \\\\__ \\\\__/   || \n",
0092            meminfo (), line2);
0093   for (p = line1; *p; p++)
0094     _putchar (*p, 4);
0095 }
0096 
0097 int
0098 main ()
0099 {
0100 
0101   int arg;
0102 
0103   asm volatile ("movl %%ebx, %0":"=m" (arg));
0104 
0105   splash_screen ();
0106 
0107   /* Setup cursor to be a full block in foreground colour */
0108   outb (0x0A, 0x3D4);           /* CRTC Cursor start index */
0109   outb (0x00, 0x3D5);           /* CRTC Cursor start data */
0110   outb (0x0B, 0x3D4);           /* CRTC Cursor end index */
0111   outb (0x0E, 0x3D5);           /* CRTC Cursor end data */
0112 
0113   while (1) {
0114     _putchar (arg, 7);
0115 
0116     asm volatile ("iret");
0117 
0118     asm volatile ("movl %%ebx, %0":"=m" (arg));
0119   }
0120 
0121   return 0;
0122 
0123 }
0124 
0125 /* 
0126  * Local Variables:
0127  * indent-tabs-mode: nil
0128  * mode: C
0129  * c-file-style: "gnu"
0130  * c-basic-offset: 2
0131  * End: 
0132  */
0133 
0134 /* vi: set et sw=2 sts=2: */