Exemple #1
0
void
Crosstable::PrintSwiss (DString * dstr, uint playerLimit)
{
    char stemp [1000];
    uint player;

    const char * resultStr [NUM_RESULT_TYPES];
    if (OutputFormat == CROSSTABLE_LaTeX) {
        resultStr[RESULT_White] = "{\\tt +}";
        resultStr[RESULT_Draw]  = "{\\tt =}";
        resultStr[RESULT_Black] = "{\\tt -}";
        resultStr[RESULT_None] = "{\\tt *}";
    } else {
        resultStr[RESULT_White] = "+";
        resultStr[RESULT_Draw]  = "=";
        resultStr[RESULT_Black] = "-";
        resultStr[RESULT_None] = "*";
    }

    dstr->Append (StartTable);
    if (OutputFormat == CROSSTABLE_LaTeX) {
        dstr->Append ("\\begin{tabular}{rl");
        if (PrintRatings) { dstr->Append ("r"); }
        if (PrintTitles) { dstr->Append ("r"); }
        if (PrintAges) { dstr->Append ("r"); }
        if (PrintCountries) { dstr->Append ("l"); }
        dstr->Append ("r@{ / }r");
        if (PrintTiebreaks) { dstr->Append ("r"); }
        for (uint i=0; i < MaxRound; i++) {
            dstr->Append ("r");
            if (i < MaxRound-1) { dstr->Append ("@{ }"); }
        }
        if (PrintRatings) { dstr->Append ("r"); }
        dstr->Append ("r}\n");
    }
    dstr->Append (StartRow);
    if (OutputFormat == CROSSTABLE_Html) {
        dstr->Append ("<th></th> <th>Player</th> ");
    } else if (OutputFormat == CROSSTABLE_LaTeX) {
        dstr->Append ("  & \\bf Player & ");
    } else {
        strPad (stemp, "", LongestNameLen + 2 + PlayerNumWidth, ' ');
        dstr->Append (stemp);
    }
    if (PrintRatings) {
        dstr->Append (StartBoldCol, " Rtng", EndBoldCol);
    }
    if (PrintTitles) {
        dstr->Append (StartBoldCol, "  Ti", EndBoldCol);
    }
    if (PrintAges) {
        dstr->Append (StartBoldCol, " Age", EndBoldCol);
    }
    if (PrintCountries) {
        dstr->Append (StartBoldCol, " Nat", EndBoldCol);
    }
    if (OutputFormat == CROSSTABLE_LaTeX) {
        dstr->Append (" \\multicolumn{2}{c}{\\bf Score} & ");
    } else {
        if (ThreeWin) 
	  dstr->Append ("  ", StartBoldCol, "Score", EndBoldCol, " ");
        else
	  dstr->Append ("   ", StartBoldCol, " Score ", EndBoldCol, "   ");
    }
    if (PrintTiebreaks) {
        dstr->Append (StartBoldCol, "(Tie)", EndBoldCol);
    }

    for (uint round = 1; round <= MaxRound; round++) {
        if (OutputFormat == CROSSTABLE_LaTeX) {
            dstr->Append (" \\multicolumn{1}{c}{\\bf ", round, "} & ");
        } else {
            sprintf (stemp, " %s%*d ", SwissColors ? " " : "",
                     PlayerNumWidth, round);
            dstr->Append (StartBoldCol, stemp, EndBoldCol);
        }
    }
    if (PrintRatings) {
        dstr->Append ("   ", StartBoldCol, "Perf Chg", EndBoldCol);
    }
    if (PrintTallies && OutputFormat == CROSSTABLE_Html) {
        dstr->Append ("   ", StartBoldCol, "+/-/=", EndBoldCol);
    }
    dstr->Append (EndRow, NewLine);

    PrintDashesLine (dstr);

    // Print the rows of players and results:
    uint previousScore = 0;
    for (player = 0; player < playerLimit; player++) {
        uint index = SortedIndex[player];
        playerDataT * pdata = PlayerData[index];

        // Print a blank line if we are at a new score group:
        if (SeparateScoreGroups  &&  SortOption == CROSSTABLE_SortScore) {
            if (player > 0  &&  pdata->score != previousScore) {
                dstr->Append (BlankRowLine);
            }
        }
        previousScore = pdata->score;

        sprintf (stemp, "%*u: ", PlayerNumWidth, player+1);
        dstr->Append (StartRow, StartRightCol, stemp, EndRightCol);

        PrintPlayer (dstr, pdata);

        if (OutputFormat == CROSSTABLE_LaTeX) {
            sprintf (stemp, " %2u%c%c ", pdata->score / 2, DecimalPointChar,
                     (pdata->score & 1 ? '5' : '0'));
            dstr->Append (StartRightCol, stemp, EndRightCol);
            sprintf (stemp, " %2u  ", pdata->gameCount);
            dstr->Append (StartRightCol, stemp, EndRightCol);
        } else {
            if (ThreeWin) {
	      sprintf (stemp, " %2u%c%c  ",
		       pdata->score / 2, DecimalPointChar,
		       (pdata->score & 1 ? '5' : '0'));
            } else {
	      sprintf (stemp, " %2u%c%c / %2u  ",
		       pdata->score / 2, DecimalPointChar,
		       (pdata->score & 1 ? '5' : '0'), pdata->gameCount);
            }
            dstr->Append (StartRightCol, stemp, EndRightCol);
        }
        if (PrintTiebreaks) {
            sprintf (stemp, "%2u%c%c ", pdata->tiebreak / 2,
                     DecimalPointChar, (pdata->tiebreak & 1 ? '5' : '0'));
            dstr->Append (StartRightCol, stemp, EndRightCol);
        }

        uint r_won = 0, r_loss = 0, r_draw = 0;
        for (uint round = 1; round <= MaxRound; round++) {
            clashT * clash = pdata->roundClash[round];
            dstr->AddChar (' ');
            dstr->Append (StartRightCol);
            if (clash == NULL) {
                dstr->Append ("...");
                if (PlayerNumWidth == 3) { dstr->AddChar ('.'); }
                if (SwissColors) { dstr->AddChar ('.'); }
            } else {
                if (OutputFormat == CROSSTABLE_Hypertext) {
                    if (CurrentGame == clash->gameNum)
                      sprintf (stemp, "<green><g_%u>", clash->gameNum);
                    else
                      sprintf (stemp, "<blue><g_%u>", clash->gameNum);
                    dstr->Append (stemp);
                }
                if (SwissColors) {
                    sprintf (stemp, "%*d%c%s", PlayerNumWidth,
                             InvertedIndex[clash->opponent] + 1,
                             clash->color == WHITE ? 'w' : 'b',
                             resultStr[clash->result]);
                } else {
                    sprintf (stemp, "%*d%s", PlayerNumWidth,
                             InvertedIndex[clash->opponent] + 1,
                             resultStr[clash->result]);
                }
                dstr->Append (stemp);
                if (OutputFormat == CROSSTABLE_Hypertext) {
                    if (CurrentGame == clash->gameNum)
                      dstr->Append ("</g></green>");
                    else
                      dstr->Append ("</g></blue>");
                }
                switch (clash->result) {
		  case 1:
		      r_won++; break;
		  case 2:
		      r_loss++; break;
		  case 3:
		      r_draw++; break;
                }
            }
            dstr->Append (EndCol);
        }
        PrintPerformance (dstr, pdata);

        if (PrintTallies) {
	  dstr->Append (StartCol);
	  sprintf (stemp, "  (+%u -%u =%u)", r_won, r_loss, r_draw);
	  dstr->Append (stemp);
	  dstr->Append (EndCol);
        }

        dstr->Append (EndRow, NewLine);
    }

    PrintDashesLine (dstr);
    dstr->Append (EndTable);
}
Exemple #2
0
STATIC
EFI_STATUS
StartLinux (
  IN  EFI_PHYSICAL_ADDRESS  LinuxImage,
  IN  UINTN                 LinuxImageSize,
  IN  EFI_PHYSICAL_ADDRESS  KernelParamsAddress,
  IN  UINTN                 KernelParamsSize,
  IN  UINT32                MachineType
  )
{
  EFI_STATUS            Status;
  LINUX_KERNEL          LinuxKernel;

  // Shut down UEFI boot services. ExitBootServices() will notify every driver that created an event on
  // ExitBootServices event. Example the Interrupt DXE driver will disable the interrupts on this event.
  Status = ShutdownUefiBootServices ();
  if(EFI_ERROR(Status)) {
    DEBUG((EFI_D_ERROR,"ERROR: Can not shutdown UEFI boot services. Status=0x%X\n", Status));
    goto Exit;
  }

  // Move the kernel parameters to any address inside the first 1MB.
  // This is necessary because the ARM Linux kernel requires
  // the FTD / ATAG List to reside entirely inside the first 1MB of
  // physical memory.
  //Note: There is no requirement on the alignment
  if (MachineType != ARM_FDT_MACHINE_TYPE) {
    if (((UINTN)KernelParamsAddress > LINUX_ATAG_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxAtagMaxOffset))) {
      KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_ATAG_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
    }
  } else {
    if (((UINTN)KernelParamsAddress > LINUX_FDT_MAX_OFFSET) && (KernelParamsSize < PcdGet32(PcdArmLinuxFdtMaxOffset))) {
      KernelParamsAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)CopyMem (ALIGN32_BELOW(LINUX_FDT_MAX_OFFSET - KernelParamsSize), (VOID*)(UINTN)KernelParamsAddress, KernelParamsSize);
    }
  }

  if ((UINTN)LinuxImage > LINUX_KERNEL_MAX_OFFSET) {
    //Note: There is no requirement on the alignment
    LinuxKernel = (LINUX_KERNEL)CopyMem (ALIGN32_BELOW(LINUX_KERNEL_MAX_OFFSET - LinuxImageSize), (VOID*)(UINTN)LinuxImage, LinuxImageSize);
  } else {
    LinuxKernel = (LINUX_KERNEL)(UINTN)LinuxImage;
  }

  // Check if the Linux Image is a uImage
  if (*(UINT32*)LinuxKernel == LINUX_UIMAGE_SIGNATURE) {
    // Assume the Image Entry Point is just after the uImage header (64-byte size)
    LinuxKernel = (LINUX_KERNEL)((UINTN)LinuxKernel + 64);
    LinuxImageSize -= 64;
  }

  // Check there is no overlapping between kernel and its parameters
  // We can only assert because it is too late to fallback to UEFI (ExitBootServices has been called).
  ASSERT (!IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress) &&
          !IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress + KernelParamsSize));

  //
  // Switch off interrupts, caches, mmu, etc
  //
  Status = PreparePlatformHardware ();
  ASSERT_EFI_ERROR(Status);

  // Register and print out performance information
  PERF_END (NULL, "BDS", NULL, 0);
  if (PerformanceMeasurementEnabled ()) {
    PrintPerformance ();
  }

  //
  // Start the Linux Kernel
  //

  // Outside BootServices, so can't use Print();
  DEBUG((EFI_D_ERROR, "\nStarting the kernel:\n\n"));

  // Jump to kernel with register set
  LinuxKernel ((UINTN)0, MachineType, (UINTN)KernelParamsAddress);

  // Kernel should never exit
  // After Life services are not provided
  ASSERT(FALSE);

Exit:
  // Only be here if we fail to start Linux
  Print (L"ERROR  : Can not start the kernel. Status=0x%X\n", Status);

  // Free Runtimee Memory (kernel and FDT)
  return Status;
}
Exemple #3
0
void
Crosstable::PrintAllPlayAll (DString * dstr, uint playerLimit)
{
    char stemp [1000];
    uint player;

    dstr->Append (StartTable);
    if (OutputFormat == CROSSTABLE_LaTeX) {
        dstr->Append ("\\begin{tabular}{rl");
        if (PrintRatings) { dstr->Append ("r"); }
        if (PrintTitles) { dstr->Append ("r"); }
        if (PrintAges) { dstr->Append ("r"); }
        if (PrintCountries) { dstr->Append ("l"); }
        dstr->Append ("r@{ / }r");
        if (PrintTiebreaks) { dstr->Append ("r"); }
        for (uint i=0; i < playerLimit; i++) {
            dstr->Append ("c");
            if (i < playerLimit-1) { dstr->Append ("@{ }"); }
        }
        if (PrintRatings) { dstr->Append ("r"); }
        dstr->Append ("r}\n");
    }
    dstr->Append (StartRow);
    if (OutputFormat == CROSSTABLE_Html) {
        dstr->Append ("<th></th> <th>Player</th> ");
    } else if (OutputFormat == CROSSTABLE_LaTeX) {
        dstr->Append ("  & \\bf Player & ");
    } else {
        strPad (stemp, "", LongestNameLen + 2 + PlayerNumWidth, ' ');
        dstr->Append (stemp);
    }
    if (PrintRatings) {
        dstr->Append (StartBoldCol, " Rtng", EndBoldCol);
    }
    if (PrintTitles) {
        dstr->Append (StartBoldCol, "  Ti", EndBoldCol);
    }
    if (PrintAges) {
        dstr->Append (StartBoldCol, " Age", EndBoldCol);
    }
    if (PrintCountries) {
        dstr->Append (StartBoldCol, " Nat", EndBoldCol);
    }
    if (OutputFormat == CROSSTABLE_LaTeX) {
        // Todo : fix LateX Score column allignment with 3 points for win.
        dstr->Append (" \\multicolumn{2}{c}{\\bf Score} & ");
    } else {
        if (ThreeWin) 
	  dstr->Append ("  ", StartBoldCol, "Score", EndBoldCol, " ");
        else
	  dstr->Append ("   ", StartBoldCol, " Score ", EndBoldCol, "   ");
    }
    if (PrintTiebreaks) {
        dstr->Append (StartBoldCol, " (Tie) ", EndBoldCol);
    }

    for (player = 0; player < playerLimit; player++) {
        strPad (stemp, PlayerData[SortedIndex[player]]->name, MaxClashes, ' ');
        if (APAColumnNums) {
            // Print numbers instead of names over columns:
            strPad (stemp, "", MaxClashes, ' ');
            uint pnum = player + 1;
            stemp[MaxClashes-1] = (pnum % 10) + '0';
            if (MaxClashes >= 2  &&  pnum >= 10) {
                stemp[MaxClashes-2] = ((pnum / 10) % 10) + '0';
            }
            if (MaxClashes >= 3  &&  pnum >= 100) {
                stemp[MaxClashes-3] = ((pnum / 10) % 10) + '0';
            }
        }
        if (playerLimit == 2) {
            // Make two-player crosstable look better:
            player = 1;
            strPad (stemp,
                    "12345678901234567890123456789012345678901234567890",
                    MaxClashes, ' ');
        }
        if (OutputFormat == CROSSTABLE_LaTeX) {
            dstr->Append (" \\tt ", stemp, " &");
        } else {
            dstr->Append (" ", StartBoldCol, stemp, EndBoldCol);
        }
    }
    if (PrintRatings) {
        dstr->Append ("   ", StartBoldCol, "Perf Chg", EndBoldCol);
    }
    if (PrintTallies && OutputFormat == CROSSTABLE_Html) {
        dstr->Append ("   ", StartBoldCol, "+/-/=", EndBoldCol);
    }
    dstr->Append (EndRow, NewLine);

    PrintDashesLine (dstr);

    // Print the rows of players and results:
    uint previousScore = 0;
    for (player = 0; player < playerLimit; player++) {
        uint index = SortedIndex[player];
        playerDataT * pdata = PlayerData[index];

        // Print a blank line if we are at a new score group:
        if (SeparateScoreGroups  &&  SortOption == CROSSTABLE_SortScore) {
            if (player > 0  &&  pdata->score != previousScore) {
                dstr->Append (BlankRowLine);
            }
        }
        previousScore = pdata->score;

        sprintf (stemp, "%*u: ", PlayerNumWidth, player+1);
        dstr->Append (StartRow, StartRightCol, stemp, EndRightCol);

        PrintPlayer (dstr, pdata);

        if (OutputFormat == CROSSTABLE_LaTeX) {
            sprintf (stemp, " %2u%c%c ", pdata->score / 2, DecimalPointChar,
                     (pdata->score & 1 ? '5' : '0'));
            dstr->Append (StartRightCol, stemp, EndRightCol);
            sprintf (stemp, " %2u  ", pdata->gameCount);
            dstr->Append (StartRightCol, stemp, EndRightCol);
        } else {
            if (ThreeWin) {
	      sprintf (stemp, " %2u%c%c  ",
		       pdata->score / 2, DecimalPointChar,
		       (pdata->score & 1 ? '5' : '0'));
            } else {
	      sprintf (stemp, " %2u%c%c / %2u  ",
		       pdata->score / 2, DecimalPointChar,
		       (pdata->score & 1 ? '5' : '0'), pdata->gameCount);
            }
            dstr->Append (StartRightCol, stemp, EndRightCol);
        }
        if (PrintTiebreaks) {
            sprintf (stemp, "%3u%c%02u ", pdata->tiebreak / 4,
                     DecimalPointChar, (pdata->tiebreak % 4) * 25);
            dstr->Append (StartRightCol, stemp, EndRightCol);
        }

        uint r_won = 0, r_loss = 0, r_draw = 0;
        for (uint oppCount = 0; oppCount < playerLimit; oppCount++) {
            if (playerLimit == 2  &&  oppCount == player) { continue; }
            uint opp = SortedIndex[oppCount];
            dstr->AddChar (' ');
            dstr->Append (StartRightCol);
            clashT * clash = pdata->firstClash[opp];

            for (uint count = 0; count < MaxClashes; count++) {
                if (clash != NULL) {
                    if (OutputFormat == CROSSTABLE_Hypertext) {
                      if (CurrentGame == clash->gameNum)
                        sprintf (stemp, "<green><g_%u>%c</g></green>",
                                 clash->gameNum,
                                 RESULT_CHAR[clash->result]);
                      else
                        sprintf (stemp, "<blue><g_%u>%c</g></blue>",
                                 clash->gameNum,
                                 RESULT_CHAR[clash->result]);
                        dstr->Append (stemp);
                    } else {
                        dstr->AddChar (RESULT_CHAR[clash->result]);
                    }
		    switch (clash->result) {
		      case 1:
			  r_won++; break;
		      case 2:
			  r_loss++; break;
		      case 3:
			  r_draw++; break;
		    }
                    clash = clash->next;
                } else {
                    dstr->AddChar (index == opp ? 'X' : '.');
                }
            }
            dstr->Append (EndCol);
        }

        PrintPerformance (dstr, pdata);

        if (PrintTallies) {
	  dstr->Append (StartCol);
	  sprintf (stemp, "  (+%u -%u =%u)", r_won, r_loss, r_draw);
	  dstr->Append (stemp);
	  dstr->Append (EndCol);
        }

        dstr->Append (EndRow, NewLine);
    }
    PrintDashesLine (dstr);
    dstr->Append (EndTable);
}