[eros-cvs] cvs commit: eros/src/base/sys/kerninc BootInfo.h Machine.hxx

mhilsdale@eros.cs.jhu.edu mhilsdale@eros.cs.jhu.edu
Tue, 21 Aug 2001 18:52:42 -0400


mhilsdale    01/08/21 18:52:42

  Modified:    src/base/sys/arch/i486/kernel Machine.cxx
               src/base/sys/console cons_VESA.cxx
               src/base/sys/kerninc BootInfo.h Machine.hxx
  Log:
  Minor updates to get the frame buffer remapped in the right place.

Revision  Changes    Path
1.122     +13 -3     eros/src/base/sys/arch/i486/kernel/Machine.cxx

Index: Machine.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/arch/i486/kernel/Machine.cxx,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- Machine.cxx	2001/08/21 22:08:47	1.121
+++ Machine.cxx	2001/08/21 22:52:41	1.122
@@ -56,6 +56,8 @@
 }
 
 kva_t Machine::frameBuffer = 0;
+kva_t Machine::mappedFrameBuffer = 0;
+
 static void MapKernel();
 
 /* Machine::BootInit() -- first routine called by main() if we
@@ -106,17 +108,21 @@
   
   MapKernel();
   
+  /* DANGER! No console use permitted between the mapping enable and
+     the GDT enable! */
+
   (void) Machine::SetMappingTable(KERNPAGEDIR); /* Well known address! */
   (void) Machine::EnableVirtualMapping();
 
+  GDT::Init();
+  
+  Machine::frameBuffer = Machine::mappedFrameBuffer;
 
   if (BootInfoPtr->consInfo)
     MsgLog::printf("FB at 0x%08x\n", (unsigned long) BootInfoPtr->consInfo);
   else
     MsgLog::printf("No FB console found.");
 
-  GDT::Init();
-  
   /*    MsgLog::printf("main(): loaded GDT\n");
    * Commented out to avoid missing symbol complaints
    */
@@ -580,8 +586,12 @@
       PTE_SET(pageTab[tabndx], PTE_V|globalPage);
     }
 
-    Machine::frameBuffer = fb_start;
+#if 1
+    MsgLog::dprintf(true, "Framebuffer (pa = 0x%08x) mapped at 0x%08x\n",
+		   (unsigned long) ci->frameBuffer, (unsigned long) fb_start);
+#endif
 
+    Machine::mappedFrameBuffer = fb_start;
   }
 
   /* BELOW THIS POINT we do not use the /globalPage/ bit, as



1.6       +80 -35    eros/src/base/sys/console/cons_VESA.cxx

Index: cons_VESA.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/console/cons_VESA.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cons_VESA.cxx	2001/08/21 22:08:48	1.5
+++ cons_VESA.cxx	2001/08/21 22:52:41	1.6
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, Jonathan S. Shapiro.
+ * Copyright (C) 2001, Jonathan S. Shapiro, Michael Hilsdale.
  *
  * This file is part of the EROS Operating System.
  *
@@ -32,6 +32,9 @@
 #include <kerninc/kernel.hxx>
 #include <kerninc/Console.hxx>
 #include <kerninc/MsgLog.hxx>
+#include <disk/DiskKey.hxx>
+#include <kerninc/BootInfo.h>
+#include <kerninc/Machine.hxx>
 #include "oslogo.h"
 #include "logosm.h"
 
@@ -42,9 +45,17 @@
 #define BPSL 6400
 #define BASE 0x40151C80;
 
+#define CURSOR 177
+/*#define CURSOR 1*/
+#define cursor() Put(CURSOR, col, row)
+
+#ifdef OLD_SCREEN
 static uint8_t *screen = (uint8_t *) PTOV(0xA0000u);
 
 #define PIX(x, y, c) (*((uint32_t *) (screen + ((uint32_t) (y) * BPSL + (x) * ((BPP + 7) / 8)))) = c)
+#else
+#define PIX(x, y, c) (*((uint32_t *) (Machine::frameBuffer + ((uint32_t) (y) * BPSL + (x) * ((BPP + 7) / 8)))) = c)
+#endif
 
 void drawHeader();
 void drawLogo(const uint16_t x, const uint16_t y);
@@ -62,14 +73,15 @@
 
   /* screen borders */
   /* not hard-coding them allows future flexibility */
-  uint8_t baseCol;
-  uint8_t baseRow;
-  uint8_t maxCol;
-  uint8_t maxRow; 
+  uint16_t baseCol;
+  uint16_t baseRow;
+  uint16_t maxCol;
+  uint16_t maxRow; 
 
   void Clear();
 
   void Put(uint8_t c);
+  void Put(uint8_t c, uint16_t c, uint16_t r);
   void SetFrameBuffer(kva_t);
 };
 
@@ -91,19 +103,25 @@
   TheConsVESA.col = TheConsVESA.baseCol;
   TheConsVESA.row = TheConsVESA.baseRow;
 
+#ifdef OLD_SCREEN
   /* Do something here to set the video mode?... */
   screen = (unsigned char *) BASE;
   /* mh: ...that works, for now. */
+#else
+  Machine::frameBuffer = BootInfoPtr->consInfo->frameBuffer;
+#endif
 
   TheConsVESA.Clear();
 
   drawHeader();
 
+#if 0
   /* run through the entire font */
-  /*for (a = 0; a < 0xff; a++)
+  for (a = 0; a < 0xff; a++)
     {
       TheConsVESA.Put(a);
-      }*/
+    }
+#endif
 
   MsgLog::RegisterSink(&TheConsVESA);
 
@@ -116,27 +134,28 @@
 void
 ConsVESA::Put(uint8_t c)
 {
-  uint16_t i, j;
-  uint16_t x, y;
-
   /*  unsigned long line = offset / 80;
       unsigned long col = offset % 80; */
 
-  signed long int l;
-
   /*  x = (offset / 80) * 8;
       y = (offset % 80) * 16; */
 
+  /* Erase cursor */
+  Put(32, col, row);
+
   /* Handle special chars here */
   switch(c)
     {
     case 0:  /* NUL */
+      cursor();
       return;
     case 7:  /* BEL */
       /* TODO: handle BEL */
+      cursor();
       return;
     case 8:  /* BS */
       /* TODO: handle BS */
+      cursor();
       return;
     case 9:  /* HT */
       col += 5;
@@ -146,25 +165,70 @@
 	  row++;
 	  /* TODO: handle scrolling */
 	}
+      cursor();
       return;
     case 10: /* LF */
       col = TheConsVESA.baseCol;
       /* TODO: handle scrolling */
+      cursor();
       return;
     case 13: /* CR */
       row++;
       /* TODO: handle scrolling */
+      cursor();
       return;
     case 255: /* why the heck is ASCII 255 a space?  You are the weakest link...goodbye. (tm) */
+      cursor();
       return;
     default:
       if(c < 32 || c > 255) /* should probably not keep this in code */
-	return;
+	{
+	  cursor();
+	  return;
+	}
+    }
+
+  /* Draw the actual character */
+  Put(c, col, row);
+
+  /* Increment cursor position */
+  col++;
+  /* col should never be > (TheConsVESA.maxCol + 1) at this point */
+  if(col == TheConsVESA.maxCol+1)
+    {
+      col = TheConsVESA.baseCol;
+      row++;
+      /* TODO: handle scrolling */
     }
 
+  /* Print cursor */
+  cursor();
+
+  /* Old */
+  /* offset = offset == 80 ? 0 : offset++; */
+  /* uint8_t *where = screen + (line * 16) + col;*/
+  /* for (i = 0; i < 16; i++) { */
+  /*   FIX: set the color to write! */
+  /*   *where = console_font[c * 16 + i]; */
+  /*   where += 80; */
+  /* }*/
+}
+
+void
+ConsVESA::Put(uint8_t c, uint16_t cl, uint16_t rw)
+{
+  uint16_t i, j;
+  uint16_t x, y;
+
+  signed long int l;
+
+  if(col < TheConsVESA.baseCol || col > TheConsVESA.maxCol ||
+     row < TheConsVESA.baseRow || row > TheConsVESA.maxRow)
+    return; /* out of bounds */
+
   /* remember that col & row use 1-based indexing */
-  x = (col - 1) * 8;
-  y = (row - 1) * 16;
+  x = (cl - 1) * 8;
+  y = (rw - 1) * 16;
 
   for (i = 0; i < 16; i++)
     {
@@ -183,28 +247,9 @@
 	  x++;
 	}
       /*x = offset;*/
-      x = (col - 1) * 8;
+      x = (cl - 1) * 8;
       y++;
     }
-
-  /* Increment cursor position */
-  col++;
-  /* col should never be > (TheConsVESA.maxCol + 1) at this point */
-  if(col == TheConsVESA.maxCol+1)
-    {
-      col = TheConsVESA.baseCol;
-      row++;
-      /* TODO: handle scrolling */
-    }
-
-  /* Old */
-  /* offset = offset == 80 ? 0 : offset++; */
-  /* uint8_t *where = screen + (line * 16) + col;*/
-  /* for (i = 0; i < 16; i++) { */
-  /*   FIX: set the color to write! */
-  /*   *where = console_font[c * 16 + i]; */
-  /*   where += 80; */
-  /* }*/
 }
 
 void



1.8       +1 -1      eros/src/base/sys/kerninc/BootInfo.h

Index: BootInfo.h
===================================================================
RCS file: /cvs/eros/src/base/sys/kerninc/BootInfo.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BootInfo.h	2001/08/21 22:08:48	1.7
+++ BootInfo.h	2001/08/21 22:52:42	1.8
@@ -89,7 +89,7 @@
   uint32_t  len;		/* length of ConsoleInfo, in bytes
 				 * (for versioning) */
   uint32_t  videoMode;		/* machine specific value */
-  kpa_t     *frameBuffer;	/* frame buffer pointer */
+  kpa_t     frameBuffer;	/* frame buffer pointer */
   uint32_t  Xlimit;		/* X dimension, in bytes */
   uint32_t  Ylimit;		/* Y dimension, in bytes */
   uint32_t  winSize;		/* size of window, in bytes */



1.59      +1 -0      eros/src/base/sys/kerninc/Machine.hxx

Index: Machine.hxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kerninc/Machine.hxx,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- Machine.hxx	2001/08/21 22:08:48	1.58
+++ Machine.hxx	2001/08/21 22:52:42	1.59
@@ -25,6 +25,7 @@
  */
 class Machine {
 public:
+  static kva_t mappedFrameBuffer; /* null if none! */
   static kva_t frameBuffer;	/* null if none! */