Example #1
0
void
task1_main(void)
{
   /*
    * This is the bootstrap task- start up the scheduler and load the
    * second task.  Our scheduler is driven by the PIT timer IRQ at
    * 100 Hz.
    */

   Timer_InitPIT(PIT_HZ / 100);
   Intr_SetMask(0, TRUE);
   Intr_SetHandler(IRQ_VECTOR(IRQ_TIMER), schedulerIRQ);

   /*
    * Create the second task. It can start running at any time now.
    */

   task_init(&task2, task2_main);

   while (1) {
      Intr_Disable();
      Console_WriteString("Task 1\n");
      Console_Flush();
      Intr_Enable();
   }
}
Example #2
0
int
main(void)
{
   static VMTCLOState tclo;
   Bool resendCapabilities = FALSE;

   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);
   SVGA_Init();
   SVGA_SetMode(640, 480, 32);

   /* Use the PIT to set TCLO polling rate. */
   Timer_InitPIT(PIT_HZ / 30);
   Intr_SetMask(0, TRUE);

   sendCapabilities();

   while (1) {
      Intr_Halt();

      if (!VMBackdoor_PollTCLO(&tclo, FALSE)) {

         if (resendCapabilities) {
            resendCapabilities = FALSE;
            sendCapabilities();
         }
         continue;
      }

      if (VMBackdoor_CheckPrefixTCLO(&tclo, "Capabilities_Register")) {
         /* Send the capabilities after we get a chance to send the reply. */
         resendCapabilities = TRUE;
         VMBackdoor_ReplyTCLO(&tclo, TCLO_SUCCESS);

      } else if (VMBackdoor_CheckPrefixTCLO(&tclo, "Resolution_Set")) {
         int width = VMBackdoor_IntParamTCLO(&tclo, 1);
         int height = VMBackdoor_IntParamTCLO(&tclo, 2);

         resize(width, height);

         VMBackdoor_ReplyTCLO(&tclo, TCLO_SUCCESS);

      } else {
         /* Unknown command */
         VMBackdoor_ReplyTCLO(&tclo, TCLO_UNKNOWN_CMD);
      }
   }

   return 0;
}
Example #3
0
int
main(void)
{
   uint32 frame = 0;
   uint32 lastTick = 0;

   Intr_Init();
   Intr_SetFaultHandlers(SVGA_DefaultFaultHandler);

   Timer_InitPIT(PIT_HZ / FRAME_RATE);
   Intr_SetMask(PIT_IRQ, TRUE);
   Intr_SetHandler(IRQ_VECTOR(PIT_IRQ), timerISR);

   SVGA_Init();
   GMR_Init();
   Heap_Reset();
   SVGA_SetMode(0, 0, 32);
   Screen_Init();
   ScreenDraw_Init(GMRID_SCREEN_DRAW);

   allocNoise();

   /*
    * Define a screen.
     */

   SVGAScreenObject myScreen = {
      .structSize = sizeof(SVGAScreenObject),
      .id = SCREEN_ID,
      .flags = SVGA_SCREEN_HAS_ROOT | SVGA_SCREEN_IS_PRIMARY,
      .size = { 800, 600 },
      .root = { 0, 0 },
   };
   Screen_Define(&myScreen);

   /*
    * Draw some explanatory text.
    */

   char docString[] =
      "Annotated Blit Sample:"
      "\n\n"
      "You should see two moving rectangles. The left one is animated "
      "using a fill-annotated blit. The blit itself contains random "
      "noise, but the annotation is a blue fill. If your host is "
      "using the annotation, you will see the blue. If not, you'll "
      "see noise. Either one is correct, but it is often more efficient "
      "to use the fill."
      "\n\n"
      "The right one is a copy-annotated blit. The blit data is again "
      "random noise, and the copy is a screen-to-screen copy which "
      "moves the rectangle from its old position to the new position. "
      "We drew a checkerboard pattern to the screen once, and that "
      "pattern should be preserved indefinitely if the annotation is "
      "being executed correctly."
      "\n\n"
      "Both rectangles should have a 1-pixel solid white border, and "
      "in both cases we use a fill-annotated blit to clear the screen "
      "behind each rectangle. This annotation doesn't lie, its blit data "
      "matches the advertised fill color.";

   ScreenDraw_SetScreen(myScreen.id, myScreen.size.width, myScreen.size.height);
   Console_Clear();
   ScreenDraw_WrapText(docString, 770);
   Console_WriteString(docString);

   /*
    * Animate the two rectangles indefinitely, sleeping between frames.
    */

   while (1) {
      SVGASignedRect oldRect1, oldRect2;
      SVGASignedRect newRect1, newRect2;

      /*
       * Move them around in a circle.
       */

      float theta = frame * 0.01;

      newRect1.left = 190 + cosf(theta) * 60;
      newRect1.top = 350 + sinf(theta) * 60;
      newRect1.right = newRect1.left + 80;
      newRect1.bottom = newRect1.top + 120;

      newRect2.left = 530 + sinf(theta) * 60;
      newRect2.top = 350 + cosf(theta) * 60;
      newRect2.right = newRect2.left + 80;
      newRect2.bottom = newRect2.top + 120;

      /*
       * Update the position of each.
       */

      updateFillRect(frame ? &oldRect1 : NULL, &newRect1);
      updateCopyRect(frame ? &oldRect2 : NULL, &newRect2);

      oldRect1 = newRect1;
      oldRect2 = newRect2;

      /*
       * Wait for the next timer tick.
       */

      while (timerTick == lastTick) {
         Intr_Halt();
      }
      lastTick = timerTick;
      frame++;
   }

   return 0;
}