EFI_STATUS EFIAPI InitializeAttrib ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) /*++ Routine Description: Command entry point. Parses command line arguments and calls internal function to perform actual action. Arguments: ImageHandle The image handle. SystemTable The system table. Returns: EFI_SUCCESS - Command completed successfully EFI_INVALID_PARAMETER - Command usage error Other value - Unknown error --*/ { UINTN Index; EFI_LIST_ENTRY FileList; EFI_LIST_ENTRY *Link; SHELL_FILE_ARG *Arg; UINT64 Remove; UINT64 Add; EFI_STATUS Status; SHELL_VAR_CHECK_CODE RetCode; CHAR16 *Useful; SHELL_ARG_LIST *Item; SHELL_VAR_CHECK_PACKAGE ChkPck; ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE)); // // We are no being installed as an internal command driver, initialize // as an nshell app and run // EFI_SHELL_APP_INIT (ImageHandle, SystemTable); // // Enable tab key which can pause the output // EnableOutputTabPause(); Status = LibFilterNullArgs (); if (EFI_ERROR (Status)) { return Status; } // // Register our string package with HII and return the handle to it. // If previously registered we will simply receive the handle // EFI_SHELL_STR_INIT (HiiHandle, STRING_ARRAY_NAME, EfiAttribGuid); if (!EFI_PROPER_VERSION (0, 99)) { PrintToken ( STRING_TOKEN (STR_SHELLENV_GNC_COMMAND_NOT_SUPPORT), HiiHandle, L"attrib", EFI_VERSION_0_99 ); Status = EFI_UNSUPPORTED; goto Quit; } RetCode = LibCheckVariables (SI, AttribCheckList, &ChkPck, &Useful); if (VarCheckOk != RetCode) { switch (RetCode) { case VarCheckConflict: PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_FLAG_CONFLICT), HiiHandle, L"attrib", Useful); break; case VarCheckDuplicate: PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_DUP_FLAG), HiiHandle, L"attrib", Useful); break; case VarCheckUnknown: PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"attrib", Useful); break; default: break; } Status = EFI_INVALID_PARAMETER; goto Quit; } // // Out put help. // if (LibCheckVarGetFlag (&ChkPck, L"-b") != NULL) { EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF); } if (LibCheckVarGetFlag (&ChkPck, L"-?") != NULL) { if (IS_OLD_SHELL) { PrintToken (STRING_TOKEN (STR_NO_HELP), HiiHandle); goto Quit; } if (ChkPck.ValueCount > 0 || ChkPck.FlagCount > 2 || (2 == ChkPck.FlagCount && !LibCheckVarGetFlag (&ChkPck, L"-b")) ) { PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"attrib"); Status = EFI_INVALID_PARAMETER; } else { PrintToken (STRING_TOKEN (STR_ATTRIB_VERBOSE_HELP), HiiHandle); Status = EFI_SUCCESS; } goto Quit; } // // Local Variable Initializations // InitializeListHead (&FileList); Link = NULL; Arg = NULL; Remove = 0; Add = 0; // // Parse command line arguments // Item = GetFirstFlag (&ChkPck); for (Index = 0; Index < ChkPck.FlagCount; Index += 1) { if (Item->FlagStr[0] == '-') { // // Attributes to remove // Status = AttribSet (&Item->FlagStr[1], &Remove); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_ARG), HiiHandle, L"attrib", Item->FlagStr); goto Done; } } else if (Item->FlagStr[0] == '+') { // // Attributes to Add // Status = AttribSet (&Item->FlagStr[1], &Add); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_ARG), HiiHandle, L"attrib", Item->FlagStr); goto Done; } } else { // // we should never get here // ASSERT (FALSE); } Item = GetNextArg (Item); } Item = GetFirstArg (&ChkPck); for (Index = 0; Index < ChkPck.ValueCount; Index += 1) { Status = ShellFileMetaArg (Item->VarStr, &FileList); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_ATTRIB_CANNOT_OPEN), HiiHandle, L"attrib", Item->VarStr, Status); goto Done; } Item = GetNextArg (Item); } // // if no file is specified, get the whole directory // if (IsListEmpty (&FileList)) { Status = ShellFileMetaArg (L"*", &FileList); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_ATTRIB_CANNOT_OPEN_DIR), HiiHandle, L"attrib", Status); goto Done; } } ShellDelDupFileArg (&FileList); // // Attrib each file // for (Link = FileList.Flink; Link != &FileList; Link = Link->Flink) { // // Break the execution? // if (GetExecutionBreak ()) { goto Done; } Arg = CR (Link, SHELL_FILE_ARG, Link, SHELL_FILE_ARG_SIGNATURE); Status = AttribFile (Arg, Remove, Add); } Done: ShellFreeFileList (&FileList); Quit: LibCheckVarFreeVarList (&ChkPck); LibUnInitializeStrings (); return Status; }
/** The function will go through the driver option link list, load and start every driver the driver option device path point to. @param BdsDriverLists The header of the current driver option link list **/ VOID EFIAPI BdsLibLoadDrivers ( IN LIST_ENTRY *BdsDriverLists ) { EFI_STATUS Status; LIST_ENTRY *Link; BDS_COMMON_OPTION *Option; EFI_HANDLE ImageHandle; EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; UINTN ExitDataSize; CHAR16 *ExitData; BOOLEAN ReconnectAll; ReconnectAll = FALSE; // // Process the driver option // for (Link = BdsDriverLists->ForwardLink; Link != BdsDriverLists; Link = Link->ForwardLink) { Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); // // If a load option is not marked as LOAD_OPTION_ACTIVE, // the boot manager will not automatically load the option. // if (!IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_ACTIVE)) { continue; } // // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT, // then all of the EFI drivers in the system will be disconnected and // reconnected after the last driver load option is processed. // if (IS_LOAD_OPTION_TYPE (Option->Attribute, LOAD_OPTION_FORCE_RECONNECT)) { ReconnectAll = TRUE; } // // Make sure the driver path is connected. // BdsLibConnectDevicePath (Option->DevicePath); // // Load and start the image that Driver#### describes // Status = gBS->LoadImage ( FALSE, mBdsImageHandle, Option->DevicePath, NULL, 0, &ImageHandle ); if (!EFI_ERROR (Status)) { gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo); // // Verify whether this image is a driver, if not, // exit it and continue to parse next load option // if (ImageInfo->ImageCodeType != EfiBootServicesCode && ImageInfo->ImageCodeType != EfiRuntimeServicesCode) { gBS->Exit (ImageHandle, EFI_INVALID_PARAMETER, 0, NULL); continue; } if (Option->LoadOptionsSize != 0) { ImageInfo->LoadOptionsSize = Option->LoadOptionsSize; ImageInfo->LoadOptions = Option->LoadOptions; } // // Before calling the image, enable the Watchdog Timer for // the 5 Minute period // #ifndef VBOX gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL); #endif Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData); DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Driver Return Status = %r\n", Status)); // // Clear the Watchdog Timer after the image returns // #ifndef VBOX gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL); #endif } } // // Process the LOAD_OPTION_FORCE_RECONNECT driver option // if (ReconnectAll) { BdsLibDisconnectAllEfi (); BdsLibConnectAll (); } }
inline void Trr2kNTNT ( UpperOrLower uplo, Orientation orientationOfB, Orientation orientationOfD, T alpha, const DistMatrix<T,MC,MR>& A, const DistMatrix<T,MC,MR>& B, const DistMatrix<T,MC,MR>& C, const DistMatrix<T,MC,MR>& D, T beta, DistMatrix<T,MC,MR>& E ) { #ifndef RELEASE PushCallStack("internal::Trr2kNTNT"); if( E.Height() != E.Width() || A.Width() != C.Width() || A.Height() != E.Height() || C.Height() != E.Height() || B.Height() != E.Width() || D.Height() != E.Width() || A.Width() != B.Width() || C.Width() != D.Width() ) throw std::logic_error("Nonconformal Trr2kNTNT"); #endif const Grid& g = E.Grid(); DistMatrix<T,MC,MR> AL(g), AR(g), A0(g), A1(g), A2(g); DistMatrix<T,MC,MR> BL(g), BR(g), B0(g), B1(g), B2(g); DistMatrix<T,MC,MR> CL(g), CR(g), C0(g), C1(g), C2(g); DistMatrix<T,MC,MR> DL(g), DR(g), D0(g), D1(g), D2(g); DistMatrix<T,MC, STAR> A1_MC_STAR(g); DistMatrix<T,VR, STAR> B1_VR_STAR(g); DistMatrix<T,STAR,MR > B1AdjOrTrans_STAR_MR(g); DistMatrix<T,MC, STAR> C1_MC_STAR(g); DistMatrix<T,VR, STAR> D1_VR_STAR(g); DistMatrix<T,STAR,MR > D1AdjOrTrans_STAR_MR(g); A1_MC_STAR.AlignWith( E ); B1_VR_STAR.AlignWith( E ); B1AdjOrTrans_STAR_MR.AlignWith( E ); C1_MC_STAR.AlignWith( E ); D1_VR_STAR.AlignWith( E ); D1AdjOrTrans_STAR_MR.AlignWith( E ); LockedPartitionRight( A, AL, AR, 0 ); LockedPartitionRight( B, BL, BR, 0 ); LockedPartitionRight( C, CL, CR, 0 ); LockedPartitionRight( D, DL, DR, 0 ); while( AL.Width() < A.Width() ) { LockedRepartitionRight ( AL, /**/ AR, A0, /**/ A1, A2 ); LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); LockedRepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); LockedRepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); //--------------------------------------------------------------------// A1_MC_STAR = A1; C1_MC_STAR = C1; B1_VR_STAR = B1; D1_VR_STAR = D1; if( orientationOfB == ADJOINT ) B1AdjOrTrans_STAR_MR.AdjointFrom( B1_VR_STAR ); else B1AdjOrTrans_STAR_MR.TransposeFrom( B1_VR_STAR ); if( orientationOfD == ADJOINT ) D1AdjOrTrans_STAR_MR.AdjointFrom( D1_VR_STAR ); else D1AdjOrTrans_STAR_MR.TransposeFrom( D1_VR_STAR ); LocalTrr2k ( uplo, alpha, A1_MC_STAR, B1AdjOrTrans_STAR_MR, C1_MC_STAR, D1AdjOrTrans_STAR_MR, beta, E ); //--------------------------------------------------------------------// SlideLockedPartitionRight ( DL, /**/ DR, D0, D1, /**/ D2 ); SlideLockedPartitionRight ( CL, /**/ CR, C0, C1, /**/ C2 ); SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlideLockedPartitionRight ( AL, /**/ AR, A0, A1, /**/ A2 ); } #ifndef RELEASE PopCallStack(); #endif }
static int S_render_node(cmark_renderer *renderer, cmark_node *node, cmark_event_type ev_type, int options) { cmark_node *tmp; int list_number; bool entering = (ev_type == CMARK_EVENT_ENTER); bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options); if (node->extension && node->extension->man_render_func) { node->extension->man_render_func(node->extension, renderer, node, ev_type, options); return 1; } switch (node->type) { case CMARK_NODE_DOCUMENT: if (entering) { /* Define a strikethrough macro */ /* Commenting out because this makes tests fail LIT(".de ST"); CR(); LIT(".nr ww \\w'\\\\$1'"); CR(); LIT("\\Z@\\v'-.25m'\\l'\\\\n[ww]u'@\\\\$1"); CR(); LIT(".."); CR(); */ } break; case CMARK_NODE_BLOCK_QUOTE: if (entering) { CR(); LIT(".RS"); CR(); } else { CR(); LIT(".RE"); CR(); } break; case CMARK_NODE_LIST: break; case CMARK_NODE_ITEM: if (entering) { CR(); LIT(".IP "); if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) { LIT("\\[bu] 2"); } else { list_number = cmark_node_get_list_start(node->parent); tmp = node; while (tmp->prev) { tmp = tmp->prev; list_number += 1; } char list_number_s[LIST_NUMBER_SIZE]; snprintf(list_number_s, LIST_NUMBER_SIZE, "\"%d.\" 4", list_number); LIT(list_number_s); } CR(); } else { CR(); } break; case CMARK_NODE_HEADING: if (entering) { CR(); LIT(cmark_node_get_heading_level(node) == 1 ? ".SH" : ".SS"); CR(); } else { CR(); } break; case CMARK_NODE_CODE_BLOCK: CR(); LIT(".IP\n.nf\n\\f[C]\n"); OUT(cmark_node_get_literal(node), false, NORMAL); CR(); LIT("\\f[]\n.fi"); CR(); break; case CMARK_NODE_HTML_BLOCK: break; case CMARK_NODE_CUSTOM_BLOCK: CR(); OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node), false, LITERAL); CR(); break; case CMARK_NODE_THEMATIC_BREAK: CR(); LIT(".PP\n * * * * *"); CR(); break; case CMARK_NODE_PARAGRAPH: if (entering) { // no blank line if first paragraph in list: if (node->parent && node->parent->type == CMARK_NODE_ITEM && node->prev == NULL) { // no blank line or .PP } else { CR(); LIT(".PP"); CR(); } } else { CR(); } break; case CMARK_NODE_TEXT: OUT(cmark_node_get_literal(node), allow_wrap, NORMAL); break; case CMARK_NODE_LINEBREAK: LIT(".PD 0\n.P\n.PD"); CR(); break; case CMARK_NODE_SOFTBREAK: if (options & CMARK_OPT_HARDBREAKS) { LIT(".PD 0\n.P\n.PD"); CR(); } else if (renderer->width == 0 && !(CMARK_OPT_NOBREAKS & options)) { CR(); } else { OUT(" ", allow_wrap, LITERAL); } break; case CMARK_NODE_CODE: LIT("\\f[C]"); OUT(cmark_node_get_literal(node), allow_wrap, NORMAL); LIT("\\f[]"); break; case CMARK_NODE_HTML_INLINE: break; case CMARK_NODE_CUSTOM_INLINE: OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node), false, LITERAL); break; case CMARK_NODE_STRONG: if (entering) { LIT("\\f[B]"); } else { LIT("\\f[]"); } break; case CMARK_NODE_EMPH: if (entering) { LIT("\\f[I]"); } else { LIT("\\f[]"); } break; case CMARK_NODE_LINK: if (!entering) { LIT(" ("); OUT(cmark_node_get_url(node), allow_wrap, URL); LIT(")"); } break; case CMARK_NODE_IMAGE: if (entering) { LIT("[IMAGE: "); } else { LIT("]"); } break; case CMARK_NODE_FOOTNOTE_DEFINITION: case CMARK_NODE_FOOTNOTE_REFERENCE: // TODO break; default: assert(false); break; } return 1; }
EditStyle::EditStyle(Score* s, QWidget* parent) : QDialog(parent) { setupUi(this); setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); cs = s; buttonApplyToAllParts = buttonBox->addButton(tr("Apply to all Parts"), QDialogButtonBox::ApplyRole); buttonApplyToAllParts->setEnabled(cs->parentScore() != nullptr); lstyle = *s->style(); setModal(true); chordDescriptionFileButton->setIcon(*icons[int(Icons::fileOpen_ICON)]); pageList->setCurrentRow(0); //articulationTable->verticalHeader()->setVisible(false); // can get disabled in ui file articulationTable->setSelectionBehavior(QAbstractItemView::SelectRows); QStringList headers; headers << tr("Symbol") << tr("Anchor"); articulationTable->setHorizontalHeaderLabels(headers); articulationTable->setColumnWidth(0, 200); articulationTable->setColumnWidth(1, 180); articulationTable->setRowCount(int(ArticulationType::ARTICULATIONS)); accidentalsGroup->setVisible(false); // disable, not yet implemented musicalSymbolFont->clear(); int idx = 0; for (auto i : ScoreFont::scoreFonts()) { musicalSymbolFont->addItem(i.name(), idx); ++idx; } for (int i = 0; i < int(ArticulationType::ARTICULATIONS); ++i) { ArticulationInfo* ai = &Articulation::articulationList[i]; QPixmap ct = cs->scoreFont()->sym2pixmap(ai->upSym, 3.0); QIcon icon(ct); QTableWidgetItem* item = new QTableWidgetItem(icon, qApp->translate("articulation", qPrintable(ai->description))); item->setFlags(item->flags() & ~Qt::ItemIsEditable); articulationTable->setItem(i, 0, item); QComboBox* cb = new QComboBox(); cb->addItem(tr("Above Staff"), int(ArticulationAnchor::TOP_STAFF)); cb->addItem(tr("Below Staff"), int(ArticulationAnchor::BOTTOM_STAFF)); cb->addItem(tr("Chord Automatic"), int(ArticulationAnchor::CHORD)); cb->addItem(tr("Above Chord"), int(ArticulationAnchor::TOP_CHORD)); cb->addItem(tr("Below Chord"), int(ArticulationAnchor::BOTTOM_CHORD)); articulationTable->setCellWidget(i, 1, cb); } QButtonGroup* bg = new QButtonGroup(this); bg->addButton(editEvenHeaderL, 0); bg->addButton(editEvenHeaderC, 1); bg->addButton(editEvenHeaderR, 2); bg->addButton(editOddHeaderL, 3); bg->addButton(editOddHeaderC, 4); bg->addButton(editOddHeaderR, 5); bg->addButton(editEvenFooterL, 6); bg->addButton(editEvenFooterC, 7); bg->addButton(editEvenFooterR, 8); bg->addButton(editOddFooterL, 9); bg->addButton(editOddFooterC, 10); bg->addButton(editOddFooterR, 11); // figured bass init QList<QString> fbFontNames = FiguredBass::fontNames(); foreach(const QString& family, fbFontNames) comboFBFont->addItem(family); comboFBFont->setCurrentIndex(0); connect(comboFBFont, SIGNAL(currentIndexChanged(int)), SLOT(on_comboFBFont_currentIndexChanged(int))); setValues(); // keep in sync with implementation in Page::replaceTextMacros (page.cpp) // jumping thru hoops here to make the job of translators easier, yet have a nice display QString toolTipHeaderFooter = QString("<html><head></head><body><p><b>") + tr("Special symbols in header/footer") + QString("</b></p>") + QString("<table><tr><td>$p</td><td>-</td><td><i>") + tr("page number, except on first page") + QString("</i></td></tr><tr><td>$P</td><td>-</td><td><i>") + tr("page number, on all pages") + QString("</i></td></tr><tr><td>$n</td><td>-</td><td><i>") + tr("number of pages") + QString("</i></td></tr><tr><td>$f</td><td>-</td><td><i>") + tr("file name") + QString("</i></td></tr><tr><td>$F</td><td>-</td><td><i>") + tr("file path+name") + QString("</i></td></tr><tr><td>$d</td><td>-</td><td><i>") + tr("current date") + QString("</i></td></tr><tr><td>$D</td><td>-</td><td><i>") + tr("creation date") + QString("</i></td></tr><tr><td>$C</td><td>-</td><td><i>") + tr("copyright, on first page only") + QString("</i></td></tr><tr><td>$c</td><td>-</td><td><i>") + tr("copyright, on all pages") + QString("</i></td></tr><tr><td>$$</td><td>-</td><td><i>") + tr("the $ sign itself") + QString("</i></td></tr><tr><td>$:tag:</td><td>-</td><td><i>") + tr("meta data tag") + QString("</i></td></tr></table><p>") + tr("Available tags and their current values:") + QString("</p><table>"); // shown all tags for curent score, see also Score::init() QMapIterator<QString, QString> i(cs->metaTags()); while (i.hasNext()) { i.next(); toolTipHeaderFooter += QString("<tr><td>%1</td><td>-</td><td>%2</td></tr>").arg(i.key()).arg(i.value()); } toolTipHeaderFooter += QString("</table></body></html>"); showHeader->setToolTip(toolTipHeaderFooter); showFooter->setToolTip(toolTipHeaderFooter); connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(buttonClicked(QAbstractButton*))); connect(headerOddEven, SIGNAL(toggled(bool)), SLOT(toggleHeaderOddEven(bool))); connect(footerOddEven, SIGNAL(toggled(bool)), SLOT(toggleFooterOddEven(bool))); connect(chordDescriptionFileButton, SIGNAL(clicked()), SLOT(selectChordDescriptionFile())); connect(chordsStandard, SIGNAL(toggled(bool)), SLOT(setChordStyle(bool))); connect(chordsJazz, SIGNAL(toggled(bool)), SLOT(setChordStyle(bool))); connect(chordsCustom, SIGNAL(toggled(bool)), SLOT(setChordStyle(bool))); connect(SwingOff, SIGNAL(toggled(bool)), SLOT(setSwingParams(bool))); connect(swingEighth, SIGNAL(toggled(bool)), SLOT(setSwingParams(bool))); connect(swingSixteenth, SIGNAL(toggled(bool)), SLOT(setSwingParams(bool))); connect(hideEmptyStaves, SIGNAL(clicked(bool)), dontHideStavesInFirstSystem, SLOT(setEnabled(bool))); connect(bg, SIGNAL(buttonClicked(int)), SLOT(editTextClicked(int))); QSignalMapper* mapper = new QSignalMapper(this); #define CR(W, ID) connect(W, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(W, int(ID)); CR(resetVoltaY, StyleIdx::voltaY); CR(resetVoltaHook, StyleIdx::voltaHook); CR(resetVoltaLineWidth, StyleIdx::voltaLineWidth); CR(resetVoltaLineStyle, StyleIdx::voltaLineStyle); CR(resetOttavaY, StyleIdx::ottavaY); CR(resetOttavaHook, StyleIdx::ottavaHook); CR(resetOttavaLineWidth, StyleIdx::ottavaLineWidth); CR(resetOttavaLineStyle, StyleIdx::ottavaLineStyle); CR(resetOttavaNumbersOnly, StyleIdx::ottavaNumbersOnly); CR(resetHairpinY, StyleIdx::hairpinY); CR(resetHairpinLineWidth, StyleIdx::hairpinLineWidth); CR(resetHairpinHeight, StyleIdx::hairpinHeight); CR(resetHairpinContinueHeight, StyleIdx::hairpinContHeight); #undef CR connect(mapper, SIGNAL(mapped(int)), SLOT(resetStyleValue(int))); }
static int S_render_node(cmark_renderer *renderer, cmark_node *node, cmark_event_type ev_type, int options) { cmark_node *tmp; int list_number; cmark_delim_type list_delim; int numticks; int i; bool entering = (ev_type == CMARK_EVENT_ENTER); const char *info, *code, *title; size_t info_len, code_len; char listmarker[20]; char *emph_delim; bufsize_t marker_width; // Don't adjust tight list status til we've started the list. // Otherwise we loose the blank line between a paragraph and // a following list. if (!(node->type == CMARK_NODE_ITEM && node->prev == NULL && entering)) { tmp = get_containing_block(node); renderer->in_tight_list_item = (tmp->type == CMARK_NODE_ITEM && cmark_node_get_list_tight(tmp->parent)) || (tmp && tmp->parent && tmp->parent->type == CMARK_NODE_ITEM && cmark_node_get_list_tight(tmp->parent->parent)); } switch (node->type) { case CMARK_NODE_DOCUMENT: break; case CMARK_NODE_BLOCK_QUOTE: if (entering) { LIT("> "); cmark_strbuf_puts(renderer->prefix, "> "); } else { cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 2); BLANKLINE(); } break; case CMARK_NODE_LIST: if (!entering && node->next && (node->next->type == CMARK_NODE_CODE_BLOCK || node->next->type == CMARK_NODE_LIST)) { // this ensures 2 blank lines after list, // if before code block or list: LIT("\n"); } break; case CMARK_NODE_ITEM: if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) { marker_width = 2; } else { list_number = cmark_node_get_list_start(node->parent); list_delim = cmark_node_get_list_delim(node->parent); tmp = node; while (tmp->prev) { tmp = tmp->prev; list_number += 1; } // we ensure a width of at least 4 so // we get nice transition from single digits // to double sprintf(listmarker, "%d%s%s", list_number, list_delim == CMARK_PAREN_DELIM ? ")" : ".", list_number < 10 ? " " : " "); marker_width = safe_strlen(listmarker); } if (entering) { if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) { LIT("* "); cmark_strbuf_puts(renderer->prefix, " "); } else { LIT(listmarker); for (i = marker_width; i--;) { cmark_strbuf_putc(renderer->prefix, ' '); } } } else { cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - marker_width); CR(); } break; case CMARK_NODE_HEADER: if (entering) { for (int i = cmark_node_get_header_level(node); i > 0; i--) { LIT("#"); } LIT(" "); renderer->no_wrap = true; } else { renderer->no_wrap = false; BLANKLINE(); } break; case CMARK_NODE_CODE_BLOCK: BLANKLINE(); info = cmark_node_get_fence_info(node); info_len = safe_strlen(info); code = cmark_node_get_literal(node); code_len = safe_strlen(code); // use indented form if no info, and code doesn't // begin or end with a blank line, and code isn't // first thing in a list item if (info_len == 0 && (code_len > 2 && !isspace(code[0]) && !(isspace(code[code_len - 1]) && isspace(code[code_len - 2]))) && !(node->prev == NULL && node->parent && node->parent->type == CMARK_NODE_ITEM)) { LIT(" "); cmark_strbuf_puts(renderer->prefix, " "); OUT(cmark_node_get_literal(node), false, LITERAL); cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 4); } else { numticks = longest_backtick_sequence(code) + 1; if (numticks < 3) { numticks = 3; } for (i = 0; i < numticks; i++) { LIT("`"); } LIT(" "); OUT(info, false, LITERAL); CR(); OUT(cmark_node_get_literal(node), false, LITERAL); CR(); for (i = 0; i < numticks; i++) { LIT("`"); } } BLANKLINE(); break; case CMARK_NODE_HTML: BLANKLINE(); OUT(cmark_node_get_literal(node), false, LITERAL); BLANKLINE(); break; case CMARK_NODE_HRULE: BLANKLINE(); LIT("-----"); BLANKLINE(); break; case CMARK_NODE_PARAGRAPH: if (!entering) { BLANKLINE(); } break; case CMARK_NODE_TEXT: OUT(cmark_node_get_literal(node), true, NORMAL); break; case CMARK_NODE_LINEBREAK: if (!(CMARK_OPT_HARDBREAKS & options)) { LIT("\\"); } CR(); break; case CMARK_NODE_SOFTBREAK: if (renderer->width == 0 && !(CMARK_OPT_HARDBREAKS & options)) { CR(); } else { OUT(" ", true, LITERAL); } break; case CMARK_NODE_CODE: code = cmark_node_get_literal(node); code_len = safe_strlen(code); numticks = shortest_unused_backtick_sequence(code); for (i = 0; i < numticks; i++) { LIT("`"); } if (code_len == 0 || code[0] == '`') { LIT(" "); } OUT(cmark_node_get_literal(node), true, LITERAL); if (code_len == 0 || code[code_len - 1] == '`') { LIT(" "); } for (i = 0; i < numticks; i++) { LIT("`"); } break; case CMARK_NODE_INLINE_HTML: OUT(cmark_node_get_literal(node), false, LITERAL); break; case CMARK_NODE_STRONG: if (entering) { LIT("**"); } else { LIT("**"); } break; case CMARK_NODE_EMPH: // If we have EMPH(EMPH(x)), we need to use *_x_* // because **x** is STRONG(x): if (node->parent && node->parent->type == CMARK_NODE_EMPH && node->next == NULL && node->prev == NULL) { emph_delim = "_"; } else { emph_delim = "*"; } if (entering) { LIT(emph_delim); } else { LIT(emph_delim); } break; case CMARK_NODE_LINK: if (is_autolink(node)) { if (entering) { LIT("<"); if (strncmp(cmark_node_get_url(node), "mailto:", 7) == 0) { LIT((char *)cmark_node_get_url(node) + 7); } else { LIT((char *)cmark_node_get_url(node)); } LIT(">"); // return signal to skip contents of node... return 0; } } else { if (entering) { LIT("["); } else { LIT("]("); OUT(cmark_node_get_url(node), false, URL); title = cmark_node_get_title(node); if (safe_strlen(title) > 0) { LIT(" \""); OUT(title, false, TITLE); LIT("\""); } LIT(")"); } } break; case CMARK_NODE_IMAGE: if (entering) { LIT("!["); } else { LIT("]("); OUT(cmark_node_get_url(node), false, URL); title = cmark_node_get_title(node); if (safe_strlen(title) > 0) { OUT(" \"", true, LITERAL); OUT(title, false, TITLE); LIT("\""); } LIT(")"); } break; default: assert(false); break; } return 1; }
inline void internal::GemmTNA ( Orientation orientationOfA, T alpha, const DistMatrix<T,MC,MR>& A, const DistMatrix<T,MC,MR>& B, T beta, DistMatrix<T,MC,MR>& C ) { #ifndef RELEASE PushCallStack("internal::GemmTNA"); if( A.Grid() != B.Grid() || B.Grid() != C.Grid() ) throw std::logic_error ("{A,B,C} must be distributed over the same grid"); if( orientationOfA == NORMAL ) throw std::logic_error("GemmTNA assumes A is (Conjugate)Transposed"); if( A.Width() != C.Height() || B.Width() != C.Width() || A.Height() != B.Height() ) { std::ostringstream msg; msg << "Nonconformal GemmTNA: \n" << " A ~ " << A.Height() << " x " << A.Width() << "\n" << " B ~ " << B.Height() << " x " << B.Width() << "\n" << " C ~ " << C.Height() << " x " << C.Width() << "\n"; throw std::logic_error( msg.str().c_str() ); } #endif const Grid& g = A.Grid(); // Matrix views DistMatrix<T,MC,MR> BL(g), BR(g), B0(g), B1(g), B2(g); DistMatrix<T,MC,MR> CL(g), CR(g), C0(g), C1(g), C2(g); // Temporary distributions DistMatrix<T,MC,STAR> B1_MC_STAR(g); DistMatrix<T,MR,STAR> D1_MR_STAR(g); DistMatrix<T,MR,MC > D1_MR_MC(g); DistMatrix<T,MC,MR > D1(g); // Start the algorithm Scal( beta, C ); LockedPartitionRight( B, BL, BR, 0 ); PartitionRight( C, CL, CR, 0 ); while( BR.Width() > 0 ) { LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); RepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); B1_MC_STAR.AlignWith( A ); D1_MR_STAR.AlignWith( A ); D1_MR_STAR.ResizeTo( C1.Height(), C1.Width() ); D1.AlignWith( C1 ); //--------------------------------------------------------------------// B1_MC_STAR = B1; // B1[MC,*] <- B1[MC,MR] // D1[MR,*] := alpha (A1[MC,MR])^T B1[MC,*] // = alpha (A1^T)[MR,MC] B1[MC,*] internal::LocalGemm ( orientationOfA, NORMAL, alpha, A, B1_MC_STAR, (T)0, D1_MR_STAR ); // C1[MC,MR] += scattered & transposed D1[MR,*] summed over grid cols D1_MR_MC.SumScatterFrom( D1_MR_STAR ); D1 = D1_MR_MC; Axpy( (T)1, D1, C1 ); //--------------------------------------------------------------------// B1_MC_STAR.FreeAlignments(); D1_MR_STAR.FreeAlignments(); D1.FreeAlignments(); SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlidePartitionRight ( CL, /**/ CR, C0, C1, /**/ C2 ); } #ifndef RELEASE PopCallStack(); #endif }
/** * @brief Assign k-space trajectory * * @param k K-space trajectory */ void KSpace (const Matrix<RT>& k) { m_k = k; if (size(k,1) == KSpaceSize() && m_nmany == 1) { #pragma omp parallel num_threads (m_fts.size()) { m_fts[omp_get_thread_num()].KSpace(k); } } else if (size(m_k,2) == m_nmany) { #pragma omp parallel num_threads (m_fts.size()) { size_t i = omp_get_thread_num(); if (ndims(k)==3) m_fts[i].KSpace(k(CR(),CR(),CR(i))); else if (ndims(k) == 4) m_fts[i].KSpace(k(CR(),CR(),CR(),CR(i))); else throw NCSENSE_KSPACE_DIMENSIONS; } } else if (size(m_k,2)*size(m_k,3) == m_nmany) { #pragma omp parallel num_threads (m_fts.size()) { size_t i = omp_get_thread_num(), l=i%size(m_k,2), n = i/size(m_k,2); if (ndims(k)==4) m_fts[i].KSpace(k(CR(),CR(),CR(l),CR(n))); else if (ndims(k) == 5) m_fts[i].KSpace(k(CR(),CR(),CR(),CR(l),CR(n))); else throw NCSENSE_KSPACE_DIMENSIONS; } } else { throw NCSENSE_KSPACE_DIMENSIONS; } }
bool SparseMatrixTest(const size_t & size, const C_FLOAT64 & sparseness, const unsigned C_INT32 & seed, const bool & RMP, const bool & dgemmFlag, const bool & SMP, const bool & CCMP) { size_t i, j, l, loop = 1; CRandom * pRandom = CRandom::createGenerator(CRandom::mt19937, seed); // If the sparseness is not specified we expect 4 metabolites per reaction C_FLOAT64 Sparseness = sparseness; if (Sparseness == 0.0) Sparseness = 4.0 / size; CMatrix< C_FLOAT64 > M(size - 3, size); CSparseMatrix S(size - 3, size); CMatrix< C_FLOAT64 > MM(size, size + 3); CSparseMatrix Ss(size, size + 3); C_FLOAT64 tmp; for (i = 0; i < size - 3; i++) for (j = 0; j < size; j++) { if (pRandom->getRandomCC() < Sparseness) S(i, j) = (pRandom->getRandomCC() - 0.5) * 100.0; } for (i = 0; i < size; i++) for (j = 0; j < size + 3; j++) { if (pRandom->getRandomCC() < Sparseness) Ss(i, j) = (pRandom->getRandomCC() - 0.5) * 100.0; } M = S; MM = Ss; CCompressedColumnFormat C(S); CCompressedColumnFormat CC(Ss); std::cout << "Memory requirements for sparseness:\t" << Sparseness << std::endl; tmp = (C_FLOAT64) sizeof(CMatrix< C_FLOAT64 >) + size * size * sizeof(C_FLOAT64); std::cout << "Matrix(" << size << "x" << size << "):\t" << tmp << std::endl; C_FLOAT64 tmp2 = (C_FLOAT64) sizeof(CSparseMatrix) + 2 * size * sizeof(std::vector<CSparseMatrixElement *>) + 2 * size * sizeof(C_FLOAT64) + S.numNonZeros() * sizeof(CSparseMatrixElement); std::cout << "Sparse(" << size << "x" << size << "):\t" << tmp2 << std::endl; std::cout << "Sparse/Matrix:\t" << tmp2 / tmp << std::endl; tmp2 = (C_FLOAT64) sizeof(CCompressedColumnFormat) + 2 * C.numNonZeros() * sizeof(C_FLOAT64) + (size + 1) * sizeof(C_FLOAT64); std::cout << "CompressedColumnFormat(" << size << "x" << size << "):\t" << tmp2 << std::endl; std::cout << "CompressedColumnFormat/Matrix:\t" << tmp2 / tmp << std::endl << std::endl; CCopasiTimer CPU(CCopasiTimer::PROCESS); CCopasiTimer WALL(CCopasiTimer::WALL); if (RMP) { // Regular Matrix Product CPU.start(); WALL.start(); for (l = 0; l < loop; l++) { CMatrix< C_FLOAT64 > MR(M.numRows(), MM.numCols()); const C_FLOAT64 *pTmp1, *pTmp2, *pTmp4, *pTmp5; const C_FLOAT64 *pEnd1, *pEnd2, *pEnd4; C_FLOAT64 *pTmp3; size_t LDA = M.numCols(); size_t LDB = MM.numCols(); pTmp1 = M.array(); pEnd1 = pTmp1 + M.numRows() * LDA; pEnd2 = MM.array() + LDB; pTmp3 = MR.array(); for (; pTmp1 < pEnd1; pTmp1 += LDA) for (pTmp2 = MM.array(); pTmp2 < pEnd2; pTmp2++, pTmp3++) { *pTmp3 = 0.0; for (pTmp4 = pTmp1, pTmp5 = pTmp2, pEnd4 = pTmp4 + LDA; pTmp4 < pEnd4; pTmp4++, pTmp5 += LDB) * pTmp3 += *pTmp4 * *pTmp5; } } CPU.refresh(); WALL.refresh(); std::cout << "Matrix * Matrix:\t"; CPU.print(&std::cout); std::cout << "\t"; WALL.print(&std::cout); std::cout << std::endl; } if (dgemmFlag) { CPU.start(); WALL.start(); for (l = 0; l < loop; l++) { CMatrix< C_FLOAT64 > dgemmR(M.numRows(), MM.numCols()); char T = 'N'; C_INT m = (C_INT) MM.numCols(); /* LDA, LDC */ C_INT n = (C_INT) M.numRows(); C_INT k = (C_INT) M.numCols(); /* LDB */ C_FLOAT64 Alpha = 1.0; C_FLOAT64 Beta = 0.0; dgemm_(&T, &T, &m, &n, &k, &Alpha, MM.array(), &m, M.array(), &k, &Beta, dgemmR.array(), &m); } /* for (i = 0; i < MR.numRows(); i++) for (j = 0; j < MR.numCols(); j++) assert(fabs(MR(i, j) - dgemmR(i, j)) <= 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() * fabs(MR(i, j))); */ CPU.refresh(); WALL.refresh(); std::cout << "dgemm(Matrix, Matrix):\t"; CPU.print(&std::cout); std::cout << "\t"; WALL.print(&std::cout); std::cout << std::endl; } // Sparse Matrix Product if (SMP) { CPU.start(); WALL.start(); for (l = 0; l < loop; l++) { CSparseMatrix SR(S.numRows(), Ss.numCols()); C_FLOAT64 Tmp; std::vector< std::vector< CSparseMatrixElement * > >::const_iterator itRow; std::vector< std::vector< CSparseMatrixElement * > >::const_iterator endRow; std::vector< CSparseMatrixElement * >::const_iterator itRowElement; std::vector< CSparseMatrixElement * >::const_iterator endRowElement; std::vector< std::vector< CSparseMatrixElement * > >::const_iterator itCol; std::vector< std::vector< CSparseMatrixElement * > >::const_iterator endCol; std::vector< CSparseMatrixElement * >::const_iterator itColElement; std::vector< CSparseMatrixElement * >::const_iterator endColElement; for (itRow = S.getRows().begin(), endRow = S.getRows().end(); itRow != endRow; ++itRow) { endRowElement = itRow->end(); for (itCol = Ss.getColumns().begin(), endCol = Ss.getColumns().end(); itCol != endCol; ++itCol) { Tmp = 0; itRowElement = itRow->begin(); itColElement = itCol->begin(); endColElement = itCol->end(); while (itRowElement != endRowElement && itColElement != endColElement) { while (itRowElement != endRowElement && (*itRowElement)->col() < (*itColElement)->row()) ++itRowElement; if (itRowElement == endRowElement) break; while (itColElement != endColElement && (*itColElement)->row() < (*itRowElement)->col()) ++itColElement; if (itColElement == endColElement) break; if ((*itRowElement)->col() != (*itColElement)->row()) continue; Tmp += **itRowElement * **itColElement; ++itRowElement; ++itColElement; } if (fabs(Tmp) < SR.getTreshold()) continue; SR.insert((*itRow->begin())->row(), (*itCol->begin())->col(), Tmp); } } } CPU.refresh(); WALL.refresh(); std::cout << "Sparse * Sparse:\t"; CPU.print(&std::cout); std::cout << "\t"; WALL.print(&std::cout); std::cout << std::endl; /* for (i = 0; i < MR.numRows(); i++) for (j = 0; j < MR.numCols(); j++) assert(fabs(MR(i, j) - SR(i, j)) < SR.getTreshold()); */ } // Compressed Column Format Product if (CCMP) { CPU.start(); WALL.start(); for (l = 0; l < loop; l++) { CSparseMatrix TmpR(C.numRows(), CC.numCols()); CCompressedColumnFormat CR(C.numRows(), CC.numCols(), 0); C_FLOAT64 Tmp; size_t imax = CR.numRows(); size_t jmax = CR.numCols(); C_FLOAT64 * pColElement, * pEndColElement; size_t * pColElementRow, * pEndColElementRow; size_t * pColStart; CCompressedColumnFormat::const_row_iterator itRowElement; CCompressedColumnFormat::const_row_iterator endRowElement = C.endRow(0); for (j = 0, pColStart = CC.getColumnStart(); j < jmax; j++, pColStart++) { for (i = 0; i < imax; i++) { Tmp = 0; itRowElement = C.beginRow(i); pColElement = CC.getValues() + *pColStart; pEndColElement = CC.getValues() + *(pColStart + 1); pColElementRow = CC.getRowIndex() + *pColStart; pEndColElementRow = CC.getRowIndex() + *(pColStart + 1); while (itRowElement != endRowElement && pColElement != pEndColElement) { while (itRowElement != endRowElement && itRowElement.getColumnIndex() < *pColElementRow) ++itRowElement; if (!(itRowElement != endRowElement)) break; while (pColElement != pEndColElement && *pColElementRow < itRowElement.getColumnIndex()) { ++pColElement; ++pColElementRow; } if (pColElement == pEndColElement) break; if (itRowElement.getColumnIndex() != *pColElementRow) continue; Tmp += *itRowElement * *pColElement; ++itRowElement; ++pColElement; ++pColElementRow; } if (fabs(Tmp) < TmpR.getTreshold()) continue; TmpR.insert(i, j, Tmp); } } CR = TmpR; } CPU.refresh(); WALL.refresh(); std::cout << "Compressed * Compressed:\t"; CPU.print(&std::cout); std::cout << "\t"; WALL.print(&std::cout); std::cout << std::endl; /* for (i = 0; i < MR.numRows(); i++) for (j = 0; j < MR.numCols(); j++) assert(fabs(MR(i, j) - TmpR(i, j)) < SR.getTreshold()); */ } std::cout << std::endl; std::cout << std::endl; return true; }
/** Set the memory map to new entries, according to one old entry, based upon PE code section and data section in image record @param ImageRecord An image record whose [ImageBase, ImageSize] covered by old memory map entry. @param NewRecord A pointer to several new memory map entries. The caller gurantee the buffer size be 1 + (SplitRecordCount * DescriptorSize) calculated below. @param OldRecord A pointer to one old memory map entry. @param DescriptorSize Size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR. **/ STATIC UINTN SetNewRecord ( IN IMAGE_PROPERTIES_RECORD *ImageRecord, IN OUT EFI_MEMORY_DESCRIPTOR *NewRecord, IN EFI_MEMORY_DESCRIPTOR *OldRecord, IN UINTN DescriptorSize ) { EFI_MEMORY_DESCRIPTOR TempRecord; IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection; LIST_ENTRY *ImageRecordCodeSectionLink; LIST_ENTRY *ImageRecordCodeSectionEndLink; LIST_ENTRY *ImageRecordCodeSectionList; UINTN NewRecordCount; UINT64 PhysicalEnd; UINT64 ImageEnd; CopyMem (&TempRecord, OldRecord, sizeof(EFI_MEMORY_DESCRIPTOR)); PhysicalEnd = TempRecord.PhysicalStart + EfiPagesToSize(TempRecord.NumberOfPages); NewRecordCount = 0; ImageRecordCodeSectionList = &ImageRecord->CodeSegmentList; ImageRecordCodeSectionLink = ImageRecordCodeSectionList->ForwardLink; ImageRecordCodeSectionEndLink = ImageRecordCodeSectionList; while (ImageRecordCodeSectionLink != ImageRecordCodeSectionEndLink) { ImageRecordCodeSection = CR ( ImageRecordCodeSectionLink, IMAGE_PROPERTIES_RECORD_CODE_SECTION, Link, IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE ); ImageRecordCodeSectionLink = ImageRecordCodeSectionLink->ForwardLink; if (TempRecord.PhysicalStart <= ImageRecordCodeSection->CodeSegmentBase) { // // DATA // if (!mPropertiesTableEnable) { NewRecord->Type = TempRecord.Type; } else { NewRecord->Type = EfiRuntimeServicesData; } NewRecord->PhysicalStart = TempRecord.PhysicalStart; NewRecord->VirtualStart = 0; NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentBase - NewRecord->PhysicalStart); NewRecord->Attribute = TempRecord.Attribute | EFI_MEMORY_XP; if (NewRecord->NumberOfPages != 0) { NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize); NewRecordCount ++; } // // CODE // if (!mPropertiesTableEnable) { NewRecord->Type = TempRecord.Type; } else { NewRecord->Type = EfiRuntimeServicesCode; } NewRecord->PhysicalStart = ImageRecordCodeSection->CodeSegmentBase; NewRecord->VirtualStart = 0; NewRecord->NumberOfPages = EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize); NewRecord->Attribute = (TempRecord.Attribute & (~EFI_MEMORY_XP)) | EFI_MEMORY_RO; if (NewRecord->NumberOfPages != 0) { NewRecord = NEXT_MEMORY_DESCRIPTOR (NewRecord, DescriptorSize); NewRecordCount ++; } TempRecord.PhysicalStart = ImageRecordCodeSection->CodeSegmentBase + EfiPagesToSize (EfiSizeToPages(ImageRecordCodeSection->CodeSegmentSize)); TempRecord.NumberOfPages = EfiSizeToPages(PhysicalEnd - TempRecord.PhysicalStart); if (TempRecord.NumberOfPages == 0) { break; } } } ImageEnd = ImageRecord->ImageBase + ImageRecord->ImageSize; // // Final DATA // if (TempRecord.PhysicalStart < ImageEnd) { if (!mPropertiesTableEnable) { NewRecord->Type = TempRecord.Type; } else { NewRecord->Type = EfiRuntimeServicesData; } NewRecord->PhysicalStart = TempRecord.PhysicalStart; NewRecord->VirtualStart = 0; NewRecord->NumberOfPages = EfiSizeToPages (ImageEnd - TempRecord.PhysicalStart); NewRecord->Attribute = TempRecord.Attribute | EFI_MEMORY_XP; NewRecordCount ++; } return NewRecordCount; }
/** Checks the sorted timer list against the current system time. Signals any expired event timer. @param CheckEvent Not used @param Context Not used **/ VOID EFIAPI CoreCheckTimers ( IN EFI_EVENT CheckEvent, IN VOID *Context ) { UINT64 SystemTime; IEVENT *Event; // // Check the timer database for expired timers // CoreAcquireLock (&mEfiTimerLock); SystemTime = CoreCurrentSystemTime (); while (!IsListEmpty (&mEfiTimerList)) { Event = CR (mEfiTimerList.ForwardLink, IEVENT, Timer.Link, EVENT_SIGNATURE); // // If this timer is not expired, then we're done // if (Event->Timer.TriggerTime > SystemTime) { break; } // // Remove this timer from the timer queue // RemoveEntryList (&Event->Timer.Link); Event->Timer.Link.ForwardLink = NULL; // // Signal it // CoreSignalEvent (Event); // // If this is a periodic timer, set it // if (Event->Timer.Period != 0) { // // Compute the timers new trigger time // Event->Timer.TriggerTime = Event->Timer.TriggerTime + Event->Timer.Period; // // If that's before now, then reset the timer to start from now // if (Event->Timer.TriggerTime <= SystemTime) { Event->Timer.TriggerTime = SystemTime; CoreSignalEvent (mEfiCheckTimerEvent); } // // Add the timer // CoreInsertEventTimer (Event); } } CoreReleaseLock (&mEfiTimerLock); }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; unsigned int speed, i; int result; RicohModel model = 0; /* Try to contact the camera. */ CR (gp_port_set_timeout (camera->port, 5000)); CR (gp_port_get_settings (camera->port, &settings)); speed = (settings.serial.speed ? settings.serial.speed : 115200); for (i = 0; speeds[i].speed; i++) { GP_DEBUG ("Trying speed %i...", speeds[i].speed); settings.serial.speed = speeds[i].speed; CR (gp_port_set_settings (camera->port, settings)); /* * Note that ricoh_connect can only be called to * initialize the connection at 2400 bps. At other * speeds, a different function needs to be used. */ result = (speeds[i].rspeed == RICOH_SPEED_2400) ? ricoh_connect (camera, NULL, &model) : ricoh_get_mode (camera, NULL, NULL); if (result == GP_OK) break; } /* Contact made? If not, report error. */ if (!speeds[i].speed) { gp_context_error (context, _("Could not contact camera.")); return (GP_ERROR); } /* Contact made. Do we need to change the speed? */ if (settings.serial.speed != speed) { for (i = 0; speeds[i].speed; i++) if (speeds[i].speed == speed) break; if (!speeds[i].speed) { gp_context_error (context, _("Speed %i is not " "supported!"), speed); return (GP_ERROR); } CR (ricoh_set_speed (camera, context, speeds[i].rspeed)); settings.serial.speed = speed; CR (gp_port_set_settings (camera->port, settings)); /* Check if the camera is still there. */ CR (ricoh_get_mode (camera, context, NULL)); } /* setup the function calls */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->capture = camera_capture; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; CR (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); /* * Remember the model. It could be that there hasn't been the * need to call ricoh_connect. Then we don't have a model. Should * we disconnect and reconnect in this case? */ camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); camera->pl->model = model; return (GP_OK); }
static int camera_get_config (Camera *c, CameraWidget **window, GPContext *co) { CameraWidget *s, *w; const char *copyright; time_t time; CR (gp_widget_new (GP_WIDGET_WINDOW, _("Configuration"), window)); /* General settings */ CR (gp_widget_new (GP_WIDGET_SECTION, _("General"), &s)); CR (gp_widget_append (*window, s)); /* Copyright */ CR (gp_widget_new (GP_WIDGET_TEXT, _("Copyright"), &w)); CR (gp_widget_set_name (w, "copyright")); CR (gp_widget_set_info (w, _("Copyright (max. 20 characters)"))); CR (gp_widget_append (s, w)); CR (ricoh_get_copyright (c, co, ©right)); CR (gp_widget_set_value (w, (void *) copyright)); /* Date */ CR (gp_widget_new (GP_WIDGET_DATE, _("Date & Time"), &w)); CRW (gp_widget_set_name (w, "date"), w); CRW (gp_widget_set_info (w, _("Date & Time")), w); CRW (gp_widget_append (s, w), w); CR (ricoh_get_date (c, co, &time)); CR (gp_widget_set_value (w, &time)); /* Picture related settings */ CR (gp_widget_new (GP_WIDGET_SECTION, _("Pictures"), &s)); CRW (gp_widget_append (*window, s), w); R_ADD_RADIO (c, co, s, RicohResolution, resolution, "Resolution") R_ADD_RADIO (c, co, s, RicohExposure, exposure, "Exposure") R_ADD_RADIO (c, co, s, RicohMacro, macro, "Macro") R_ADD_RADIO (c, co, s, RicohFlash, flash, "Flash") R_ADD_RADIO (c, co, s, RicohZoom, zoom, "Zoom") R_ADD_RADIO (c, co, s, RicohCompression, compression, "Compression") R_ADD_RADIO (c, co, s, RicohWhiteLevel, white_level, "White Level") R_ADD_RADIO (c, co, s, RicohRecMode, rec_mode, "Record Mode") return (GP_OK); }
/** Read a disk from disk into HBufferImage. @param[in] Offset The offset. @param[in] Size The size. @param[in] Recover if is for recover, no information print. @retval EFI_LOAD_ERROR A load error occured. @retval EFI_SUCCESS The operation was successful. @retval EFI_OUT_OF_RESOURCES A memory allocation failed. **/ EFI_STATUS HMemImageRead ( IN UINTN Offset, IN UINTN Size, IN BOOLEAN Recover ) { EFI_STATUS Status; void *Buffer; CHAR16 *Str; HEFI_EDITOR_LINE *Line; HBufferImage.BufferType = FileTypeMemBuffer; Buffer = AllocateZeroPool (Size); if (Buffer == NULL) { StatusBarSetStatusString (L"Read Memory Failed"); return EFI_OUT_OF_RESOURCES; } Status = HMemImage.IoFncs->Mem.Read ( HMemImage.IoFncs, EfiPciWidthUint8, Offset, Size, Buffer ); if (EFI_ERROR (Status)) { FreePool (Buffer); StatusBarSetStatusString (L"Memory Specified Not Accessible"); return EFI_LOAD_ERROR; } HBufferImageFree (); Status = HBufferImageBufferToList (Buffer, Size); FreePool (Buffer); if (EFI_ERROR (Status)) { StatusBarSetStatusString (L"Read Memory Failed"); return Status; } Status = HMemImageSetMemOffsetSize (Offset, Size); HBufferImage.DisplayPosition.Row = 2; HBufferImage.DisplayPosition.Column = 10; HBufferImage.MousePosition.Row = 2; HBufferImage.MousePosition.Column = 10; HBufferImage.LowVisibleRow = 1; HBufferImage.HighBits = TRUE; HBufferImage.BufferPosition.Row = 1; HBufferImage.BufferPosition.Column = 1; if (!Recover) { Str = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines); if (Str == NULL) { StatusBarSetStatusString (L"Read Memory Failed"); return EFI_OUT_OF_RESOURCES; } StatusBarSetStatusString (Str); SHELL_FREE_NON_NULL (Str); HMainEditor.SelectStart = 0; HMainEditor.SelectEnd = 0; } // // has line // if (HBufferImage.Lines != NULL) { HBufferImage.CurrentLine = CR (HBufferImage.ListHead->ForwardLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST); } else { // // create a dummy line // Line = HBufferImageCreateLine (); if (Line == NULL) { StatusBarSetStatusString (L"Read Memory Failed"); return EFI_OUT_OF_RESOURCES; } HBufferImage.CurrentLine = Line; } HBufferImage.Modified = FALSE; HBufferImageNeedRefresh = TRUE; HBufferImageOnlyLineNeedRefresh = FALSE; HBufferImageMouseNeedRefresh = TRUE; return EFI_SUCCESS; }
inline void SUMMA_NNA ( T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B, T beta, DistMatrix<T>& C ) { #ifndef RELEASE CallStackEntry entry("gemm::SUMMA_NNA"); if( A.Grid() != B.Grid() || B.Grid() != C.Grid() ) LogicError("{A,B,C} must have the same grid"); if( A.Height() != C.Height() || B.Width() != C.Width() || A.Width() != B.Height() ) { std::ostringstream msg; msg << "Nonconformal matrices: \n" << " A ~ " << A.Height() << " x " << A.Width() << "\n" << " B ~ " << B.Height() << " x " << B.Width() << "\n" << " C ~ " << C.Height() << " x " << C.Width() << "\n"; LogicError( msg.str() ); } #endif const Grid& g = A.Grid(); // Matrix views DistMatrix<T> BL(g), BR(g), B0(g), B1(g), B2(g); DistMatrix<T> CL(g), CR(g), C0(g), C1(g), C2(g); // Temporary distributions DistMatrix<T,VR,STAR> B1_VR_STAR(g); DistMatrix<T,STAR,MR> B1Trans_STAR_MR(g); DistMatrix<T,MC,STAR> D1_MC_STAR(g); B1_VR_STAR.AlignWith( A ); B1Trans_STAR_MR.AlignWith( A ); D1_MC_STAR.AlignWith( A ); // Start the algorithm Scale( beta, C ); LockedPartitionRight( B, BL, BR, 0 ); PartitionRight( C, CL, CR, 0 ); while( BR.Width() > 0 ) { LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); RepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); //--------------------------------------------------------------------// B1_VR_STAR = B1; B1Trans_STAR_MR.TransposeFrom( B1_VR_STAR ); // D1[MC,*] := alpha A[MC,MR] B1[MR,*] LocalGemm( NORMAL, TRANSPOSE, alpha, A, B1Trans_STAR_MR, D1_MC_STAR ); // C1[MC,MR] += scattered result of D1[MC,*] summed over grid rows C1.SumScatterUpdate( T(1), D1_MC_STAR ); //--------------------------------------------------------------------// SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlidePartitionRight ( CL, /**/ CR, C0, C1, /**/ C2 ); } }
/** Read a disk from disk into HBufferImage. @param[in] DeviceName filename to read. @param[in] Offset The offset. @param[in] Size The size. @param[in] Recover if is for recover, no information print. @retval EFI_SUCCESS The operation was successful. @retval EFI_OUT_OF_RESOURCES A memory allocation failed. @retval EFI_LOAD_ERROR A load error occured. @retval EFI_INVALID_PARAMETER A parameter was invalid. **/ EFI_STATUS HDiskImageRead ( IN CONST CHAR16 *DeviceName, IN UINTN Offset, IN UINTN Size, IN BOOLEAN Recover ) { CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DupDevicePath; EFI_DEVICE_PATH_PROTOCOL *DupDevicePathForFree; EFI_HANDLE Handle; EFI_BLOCK_IO_PROTOCOL *BlkIo; EFI_STATUS Status; VOID *Buffer; CHAR16 *Str; UINTN Bytes; HEFI_EDITOR_LINE *Line; HBufferImage.BufferType = FileTypeDiskBuffer; DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName); if (DevicePath == NULL) { StatusBarSetStatusString (L"Cannot Find Device"); return EFI_INVALID_PARAMETER; } DupDevicePath = DuplicateDevicePath(DevicePath); DupDevicePathForFree = DupDevicePath; // // get blkio interface // Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle); FreePool(DupDevicePathForFree); if (EFI_ERROR (Status)) { StatusBarSetStatusString (L"Read Disk Failed"); return Status; } Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR (Status)) { StatusBarSetStatusString (L"Read Disk Failed"); return Status; } // // if Offset exceeds LastBlock, // return error // if (Offset > BlkIo->Media->LastBlock || Offset + Size > BlkIo->Media->LastBlock) { StatusBarSetStatusString (L"Invalid Offset + Size"); return EFI_LOAD_ERROR; } Bytes = BlkIo->Media->BlockSize * Size; Buffer = AllocateZeroPool (Bytes); if (Buffer == NULL) { StatusBarSetStatusString (L"Read Disk Failed"); return EFI_OUT_OF_RESOURCES; } // // read from disk // Status = BlkIo->ReadBlocks ( BlkIo, BlkIo->Media->MediaId, Offset, Bytes, Buffer ); if (EFI_ERROR (Status)) { FreePool (Buffer); StatusBarSetStatusString (L"Read Disk Failed"); return EFI_LOAD_ERROR; } HBufferImageFree (); // // convert buffer to line list // Status = HBufferImageBufferToList (Buffer, Bytes); FreePool (Buffer); if (EFI_ERROR (Status)) { StatusBarSetStatusString (L"Read Disk Failed"); return Status; } Status = HDiskImageSetDiskNameOffsetSize (DeviceName, Offset, Size); if (EFI_ERROR (Status)) { StatusBarSetStatusString (L"Read Disk Failed"); return EFI_OUT_OF_RESOURCES; } // // initialize some variables // HDiskImage.BlockSize = BlkIo->Media->BlockSize; HBufferImage.DisplayPosition.Row = 2; HBufferImage.DisplayPosition.Column = 10; HBufferImage.MousePosition.Row = 2; HBufferImage.MousePosition.Column = 10; HBufferImage.LowVisibleRow = 1; HBufferImage.HighBits = TRUE; HBufferImage.BufferPosition.Row = 1; HBufferImage.BufferPosition.Column = 1; if (!Recover) { Str = CatSPrint(NULL, L"%d Lines Read", HBufferImage.NumLines); if (Str == NULL) { StatusBarSetStatusString (L"Read Disk Failed"); return EFI_OUT_OF_RESOURCES; } StatusBarSetStatusString (Str); SHELL_FREE_NON_NULL (Str); HMainEditor.SelectStart = 0; HMainEditor.SelectEnd = 0; } // // has line // if (HBufferImage.Lines != NULL) { HBufferImage.CurrentLine = CR ( HBufferImage.ListHead->ForwardLink, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST ); } else { // // create a dummy line // Line = HBufferImageCreateLine (); if (Line == NULL) { StatusBarSetStatusString (L"Read Disk Failed"); return EFI_OUT_OF_RESOURCES; } HBufferImage.CurrentLine = Line; } HBufferImage.Modified = FALSE; HBufferImageNeedRefresh = TRUE; HBufferImageOnlyLineNeedRefresh = FALSE; HBufferImageMouseNeedRefresh = TRUE; return EFI_SUCCESS; }
inline void SUMMA_NNDot ( T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B, T beta, DistMatrix<T>& C ) { #ifndef RELEASE CallStackEntry entry("gemm::SUMMA_NNDot"); if( A.Grid() != B.Grid() || B.Grid() != C.Grid() ) LogicError("{A,B,C} must have the same grid"); if( A.Height() != C.Height() || B.Width() != C.Width() || A.Width() != B.Height() ) { std::ostringstream msg; msg << "Nonconformal matrices: \n" << " A ~ " << A.Height() << " x " << A.Width() << "\n" << " B ~ " << B.Height() << " x " << B.Width() << "\n" << " C ~ " << C.Height() << " x " << C.Width() << "\n"; LogicError( msg.str() ); } #endif const Grid& g = A.Grid(); if( A.Height() > B.Width() ) { // Matrix views DistMatrix<T> AT(g), AB(g), A0(g), A1(g), A2(g); DistMatrix<T> BL(g), B0(g), BR(g), B1(g), B2(g); DistMatrix<T> CT(g), C0(g), C1L(g), C1R(g), CB(g), C1(g), C10(g), C11(g), C12(g), C2(g); // Temporary distributions DistMatrix<T,STAR,VC> A1_STAR_VC(g); DistMatrix<T,VC,STAR> B1_VC_STAR(g); DistMatrix<T,STAR,STAR> C11_STAR_STAR(g); // Star the algorithm Scale( beta, C ); LockedPartitionDown ( A, AT, AB, 0 ); PartitionDown ( C, CT, CB, 0 ); while( AB.Height() > 0 ) { LockedRepartitionDown ( AT, A0, /**/ /**/ A1, AB, A2 ); RepartitionDown ( CT, C0, /**/ /**/ C1, CB, C2 ); A1_STAR_VC = A1; B1_VC_STAR.AlignWith( A1_STAR_VC ); LockedPartitionRight( B, BL, BR, 0 ); PartitionRight( C1, C1L, C1R, 0 ); while( BR.Width() > 0 ) { LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); RepartitionRight ( C1L, /**/ C1R, C10, /**/ C11, C12 ); //------------------------------------------------------------// B1_VC_STAR = B1; LocalGemm ( NORMAL, NORMAL, alpha, A1_STAR_VC, B1_VC_STAR, C11_STAR_STAR ); C11.SumScatterUpdate( T(1), C11_STAR_STAR ); //------------------------------------------------------------// SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlidePartitionRight ( C1L, /**/ C1R, C10, C11, /**/ C12 ); } SlideLockedPartitionDown ( AT, A0, A1, /**/ /**/ AB, A2 ); SlidePartitionDown ( CT, C0, C1, /**/ /**/ CB, C2 ); } } else { // Matrix views DistMatrix<T> AT(g), AB(g), A0(g), A1(g), A2(g); DistMatrix<T> BL(g), B0(g), BR(g), B1(g), B2(g); DistMatrix<T> CL(g), CR(g), C1T(g), C01(g), C0(g), C1(g), C2(g), C1B(g), C11(g), C21(g); // Temporary distributions DistMatrix<T,STAR,VR> A1_STAR_VR(g); DistMatrix<T,VR,STAR> B1_VR_STAR(g); DistMatrix<T,STAR,STAR> C11_STAR_STAR(g); // Star the algorithm Scale( beta, C ); LockedPartitionRight( B, BL, BR, 0 ); PartitionRight( C, CL, CR, 0 ); while( BR.Width() > 0 ) { LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); RepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); B1_VR_STAR = B1; A1_STAR_VR.AlignWith( B1_VR_STAR ); LockedPartitionDown ( A, AT, AB, 0 ); PartitionDown ( C1, C1T, C1B, 0 ); while( AB.Height() > 0 ) { LockedRepartitionDown ( AT, A0, /**/ /**/ A1, AB, A2 ); RepartitionDown ( C1T, C01, /***/ /***/ C11, C1B, C21 ); //------------------------------------------------------------// A1_STAR_VR = A1; LocalGemm ( NORMAL, NORMAL, alpha, A1_STAR_VR, B1_VR_STAR, C11_STAR_STAR ); C11.SumScatterUpdate( T(1), C11_STAR_STAR ); //------------------------------------------------------------// SlideLockedPartitionDown ( AT, A0, A1, /**/ /**/ AB, A2 ); SlidePartitionDown ( C1T, C01, C11, /***/ /***/ C1B, C21 ); } SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlidePartitionRight ( CL, /**/ CR, C0, C1, /**/ C2 ); } } }
VOID EFIAPI PlatformBdsPolicyBehavior ( IN OUT LIST_ENTRY *DriverOptionList, IN OUT LIST_ENTRY *BootOptionList, IN PROCESS_CAPSULES ProcessCapsules, IN BASEM_MEMORY_TEST BaseMemoryTest ) /*++ Routine Description: The function will excute with as the platform policy, current policy is driven by boot mode. IBV/OEM can customize this code for their specific policy action. Arguments: DriverOptionList - The header of the driver option link list BootOptionList - The header of the boot option link list ProcessCapsules - A pointer to ProcessCapsules() BaseMemoryTest - A pointer to BaseMemoryTest() Returns: None. --*/ { EFI_STATUS Status; UINT16 Timeout; EFI_EVENT UserInputDurationTime; LIST_ENTRY *Link; BDS_COMMON_OPTION *BootOption; UINTN Index; EFI_INPUT_KEY Key; EFI_TPL OldTpl; EFI_BOOT_MODE BootMode; DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n")); ConnectRootBridge (); // // Try to restore variables from the hard disk early so // they can be used for the other BDS connect operations. // PlatformBdsRestoreNvVarsFromHardDisk (); // // Init the time out value // Timeout = PcdGet16 (PcdPlatformBootTimeOut); // // Load the driver option as the driver option list // PlatformBdsGetDriverOption (DriverOptionList); // // Get current Boot Mode // Status = BdsLibGetBootMode (&BootMode); DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode)); // // Go the different platform policy with different boot mode // Notes: this part code can be change with the table policy // ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION); // // Connect platform console // Status = PlatformBdsConnectConsole (gPlatformConsole); if (EFI_ERROR (Status)) { // // Here OEM/IBV can customize with defined action // PlatformBdsNoConsoleAction (); } // // Create a 300ms duration event to ensure user has enough input time to enter Setup // Status = gBS->CreateEvent ( EVT_TIMER, 0, NULL, NULL, &UserInputDurationTime ); ASSERT (Status == EFI_SUCCESS); Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000); ASSERT (Status == EFI_SUCCESS); // // Memory test and Logo show // PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest); // // Perform some platform specific connect sequence // PlatformBdsConnectSequence (); // // Give one chance to enter the setup if we // have the time out // if (Timeout != 0) { //PlatformBdsEnterFrontPage (Timeout, FALSE); } DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n")); BdsLibConnectAll (); BdsLibEnumerateAllBootOption (BootOptionList); // // Please uncomment above ConnectAll and EnumerateAll code and remove following first boot // checking code in real production tip. // // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device // and do enumerate all the default boot options. But in development system board, the boot mode // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot. // Status = BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder"); if (EFI_ERROR(Status)) { // // If cannot find "BootOrder" variable, it may be first boot. // Try to connect all devices and enumerate all boot options here. // BdsLibConnectAll (); BdsLibEnumerateAllBootOption (BootOptionList); } // // To give the User a chance to enter Setup here, if user set TimeOut is 0. // BDS should still give user a chance to enter Setup // // Connect first boot option, and then check user input before exit // for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) { BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) { // // skip the header of the link list, becuase it has no boot option // continue; } else { // // Make sure the boot option device path connected, but ignore the BBS device path // if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) { BdsLibConnectDevicePath (BootOption->DevicePath); } break; } } // // Check whether the user input after the duration time has expired // OldTpl = EfiGetCurrentTpl(); gBS->RestoreTPL (TPL_APPLICATION); gBS->WaitForEvent (1, &UserInputDurationTime, &Index); gBS->CloseEvent (UserInputDurationTime); Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); gBS->RaiseTPL (OldTpl); if (!EFI_ERROR (Status)) { // // Enter Setup if user input // Timeout = 0xffff; PlatformBdsEnterFrontPage (Timeout, FALSE); } return ; }
/** This function attempts to boot for the boot order specified by platform policy. **/ VOID BdsBootDeviceSelect ( VOID ) { EFI_STATUS Status; LIST_ENTRY *Link; BDS_COMMON_OPTION *BootOption; UINTN ExitDataSize; CHAR16 *ExitData; UINT16 Timeout; LIST_ENTRY BootLists; CHAR16 Buffer[20]; BOOLEAN BootNextExist; LIST_ENTRY *LinkBootNext; EFI_EVENT ConnectConInEvent; // // Got the latest boot option // BootNextExist = FALSE; LinkBootNext = NULL; ConnectConInEvent = NULL; InitializeListHead (&BootLists); // // First check the boot next option // ZeroMem (Buffer, sizeof (Buffer)); // // Create Event to signal ConIn connection request // if (PcdGetBool (PcdConInConnectOnDemand)) { Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, BdsEmptyCallbackFunction, NULL, &gConnectConInEventGuid, &ConnectConInEvent ); if (EFI_ERROR(Status)) { ConnectConInEvent = NULL; } } if (mBootNext != NULL) { // // Indicate we have the boot next variable, so this time // boot will always have this boot option // BootNextExist = TRUE; // // Clear the this variable so it's only exist in this time boot // Status = gRT->SetVariable ( L"BootNext", &gEfiGlobalVariableGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, 0, NULL ); // // Deleting variable with current variable implementation shouldn't fail. // ASSERT_EFI_ERROR (Status); // // Add the boot next boot option // UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *mBootNext); BootOption = BdsLibVariableToOption (&BootLists, Buffer); // // If fail to get boot option from variable, just return and do nothing. // if (BootOption == NULL) { return; } BootOption->BootCurrent = *mBootNext; } // // Parse the boot order to get boot option // BdsLibBuildOptionFromVar (&BootLists, L"BootOrder"); // // When we didn't have chance to build boot option variables in the first // full configuration boot (e.g.: Reset in the first page or in Device Manager), // we have no boot options in the following mini configuration boot. // Give the last chance to enumerate the boot options. // if (IsListEmpty (&BootLists)) { BdsLibEnumerateAllBootOption (&BootLists); } Link = BootLists.ForwardLink; // // Parameter check, make sure the loop will be valid // if (Link == NULL) { return ; } // // Here we make the boot in a loop, every boot success will // return to the front page // for (;;) { // // Check the boot option list first // if (Link == &BootLists) { // // When LazyConIn enabled, signal connect ConIn event before enter UI // if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) { gBS->SignalEvent (ConnectConInEvent); } // // There are two ways to enter here: // 1. There is no active boot option, give user chance to // add new boot option // 2. All the active boot option processed, and there is no // one is success to boot, then we back here to allow user // add new active boot option // Timeout = 0xffff; PlatformBdsEnterFrontPage (Timeout, FALSE); InitializeListHead (&BootLists); BdsLibBuildOptionFromVar (&BootLists, L"BootOrder"); Link = BootLists.ForwardLink; continue; } // // Get the boot option from the link list // BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); // // According to EFI Specification, if a load option is not marked // as LOAD_OPTION_ACTIVE, the boot manager will not automatically // load the option. // if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) { // // skip the header of the link list, because it has no boot option // Link = Link->ForwardLink; continue; } // // Make sure the boot option device path connected, // but ignore the BBS device path // if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) { // // Notes: the internal shell can not been connected with device path // so we do not check the status here // BdsLibConnectDevicePath (BootOption->DevicePath); } // // Restore to original mode before launching boot option. // BdsSetConsoleMode (FALSE); // // All the driver options should have been processed since // now boot will be performed. // Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData); if (Status != EFI_SUCCESS) { // // Call platform action to indicate the boot fail // BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED)); PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize); // // Check the next boot option // Link = Link->ForwardLink; } else { // // Call platform action to indicate the boot success // BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED)); PlatformBdsBootSuccess (BootOption); // // Boot success, then stop process the boot order, and // present the boot manager menu, front page // // // When LazyConIn enabled, signal connect ConIn Event before enter UI // if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) { gBS->SignalEvent (ConnectConInEvent); } Timeout = 0xffff; PlatformBdsEnterFrontPage (Timeout, FALSE); // // Rescan the boot option list, avoid potential risk of the boot // option change in front page // if (BootNextExist) { LinkBootNext = BootLists.ForwardLink; } InitializeListHead (&BootLists); if (LinkBootNext != NULL) { // // Reserve the boot next option // InsertTailList (&BootLists, LinkBootNext); } BdsLibBuildOptionFromVar (&BootLists, L"BootOrder"); Link = BootLists.ForwardLink; } } }
friend constexpr meta::rebind_t<Final, common_type_t<UT, UT2>> operator%(Final const& x, UT2 const& y) noexcept { using CR = common_type_t<UT, UT2>; using CT = meta::rebind_t<Final, CR>; return CT(CT(x)._backdoor()._underlying() % CR(y)); }
/** This function invokes Boot Manager. If all devices have not a chance to be connected, the connect all will be triggered. It then enumerate all boot options. If a boot option from the Boot Manager page is selected, Boot Manager will boot from this boot option. **/ VOID CallBootManager ( VOID ) { EFI_STATUS Status; BDS_COMMON_OPTION *Option; LIST_ENTRY *Link; CHAR16 *ExitData; UINTN ExitDataSize; EFI_STRING_ID Token; EFI_INPUT_KEY Key; CHAR16 *HelpString; EFI_STRING_ID HelpToken; UINT16 *TempStr; EFI_HII_HANDLE HiiHandle; EFI_BROWSER_ACTION_REQUEST ActionRequest; UINTN TempSize; VOID *StartOpCodeHandle; VOID *EndOpCodeHandle; EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; UINT16 DeviceType; BOOLEAN IsLegacyOption; BOOLEAN NeedEndOp; DeviceType = (UINT16) -1; gOption = NULL; InitializeListHead (&mBootOptionsList); // // Connect all prior to entering the platform setup menu. // if (!gConnectAllHappened) { BdsLibConnectAllDriversToAllControllers (); gConnectAllHappened = TRUE; } BdsLibEnumerateAllBootOption (&mBootOptionsList); // // Group the legacy boot options for the same device type // GroupMultipleLegacyBootOption4SameType (); InitializeListHead (&mBootOptionsList); BdsLibBuildOptionFromVar (&mBootOptionsList, L"BootOrder"); HiiHandle = gBootManagerPrivate.HiiHandle; // // Allocate space for creation of UpdateData Buffer // StartOpCodeHandle = HiiAllocateOpCodeHandle (); ASSERT (StartOpCodeHandle != NULL); EndOpCodeHandle = HiiAllocateOpCodeHandle (); ASSERT (EndOpCodeHandle != NULL); // // Create Hii Extend Label OpCode as the start opcode // StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; StartLabel->Number = LABEL_BOOT_OPTION; // // Create Hii Extend Label OpCode as the end opcode // EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; EndLabel->Number = LABEL_BOOT_OPTION_END; mKeyInput = 0; NeedEndOp = FALSE; for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); // // At this stage we are creating a menu entry, thus the Keys are reproduceable // mKeyInput++; // // Don't display the hidden/inactive boot option // if (((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) || ((Option->Attribute & LOAD_OPTION_ACTIVE) == 0)) { continue; } // // Group the legacy boot option in the sub title created dynamically // IsLegacyOption = (BOOLEAN) ( (DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) && (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP) ); if (!IsLegacyOption && NeedEndOp) { NeedEndOp = FALSE; HiiCreateEndOpCode (StartOpCodeHandle); } if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType) { if (NeedEndOp) { HiiCreateEndOpCode (StartOpCodeHandle); } DeviceType = ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType; Token = HiiSetString ( HiiHandle, 0, mDeviceTypeStr[ MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1) ], NULL ); HiiCreateSubTitleOpCode (StartOpCodeHandle, Token, 0, 0, 1); NeedEndOp = TRUE; } ASSERT (Option->Description != NULL); Token = HiiSetString (HiiHandle, 0, Option->Description, NULL); TempStr = DevicePathToStr (Option->DevicePath); TempSize = StrSize (TempStr); HelpString = AllocateZeroPool (TempSize + StrSize (L"Device Path : ")); ASSERT (HelpString != NULL); StrCat (HelpString, L"Device Path : "); StrCat (HelpString, TempStr); HelpToken = HiiSetString (HiiHandle, 0, HelpString, NULL); HiiCreateActionOpCode ( StartOpCodeHandle, mKeyInput, Token, HelpToken, EFI_IFR_FLAG_CALLBACK, 0 ); } if (NeedEndOp) { HiiCreateEndOpCode (StartOpCodeHandle); } HiiUpdateForm ( HiiHandle, &gBootManagerFormSetGuid, BOOT_MANAGER_FORM_ID, StartOpCodeHandle, EndOpCodeHandle ); HiiFreeOpCodeHandle (StartOpCodeHandle); HiiFreeOpCodeHandle (EndOpCodeHandle); ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; Status = gFormBrowser2->SendForm ( gFormBrowser2, &HiiHandle, 1, &gBootManagerFormSetGuid, 0, NULL, &ActionRequest ); if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) { EnableResetRequired (); } if (gOption == NULL) { return ; } // // Will leave browser, check any reset required change is applied? if yes, reset system // SetupResetReminder (); // // Restore to original mode before launching boot option. // BdsSetConsoleMode (FALSE); // // parse the selected option // Status = BdsLibBootViaBootOption (gOption, gOption->DevicePath, &ExitDataSize, &ExitData); if (!EFI_ERROR (Status)) { gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED)); PlatformBdsBootSuccess (gOption); } else { gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED)); PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize); gST->ConOut->OutputString ( gST->ConOut, GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE)) ); gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); } }
inline void SymmRUC ( T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B, T beta, DistMatrix<T>& C, bool conjugate=false ) { #ifndef RELEASE PushCallStack("internal::SymmRUC"); if( A.Grid() != B.Grid() || B.Grid() != C.Grid() ) throw std::logic_error("{A,B,C} must be distributed on the same grid"); #endif const Grid& g = A.Grid(); const Orientation orientation = ( conjugate ? ADJOINT : TRANSPOSE ); // Matrix views DistMatrix<T> ATL(g), ATR(g), A00(g), A01(g), A02(g), AColPan(g), ABL(g), ABR(g), A10(g), A11(g), A12(g), ARowPan(g), A20(g), A21(g), A22(g); DistMatrix<T> BL(g), BR(g), B0(g), B1(g), B2(g); DistMatrix<T> CL(g), CR(g), C0(g), C1(g), C2(g), CLeft(g), CRight(g); // Temporary distributions DistMatrix<T,MC, STAR> B1_MC_STAR(g); DistMatrix<T,VR, STAR> AColPan_VR_STAR(g); DistMatrix<T,STAR,MR > AColPanTrans_STAR_MR(g); DistMatrix<T,MR, STAR> ARowPanTrans_MR_STAR(g); B1_MC_STAR.AlignWith( C ); // Start the algorithm Scale( beta, C ); LockedPartitionDownDiagonal ( A, ATL, ATR, ABL, ABR, 0 ); LockedPartitionRight( B, BL, BR, 0 ); PartitionRight( C, CL, CR, 0 ); while( CR.Width() > 0 ) { LockedRepartitionDownDiagonal ( ATL, /**/ ATR, A00, /**/ A01, A02, /*************/ /******************/ /**/ A10, /**/ A11, A12, ABL, /**/ ABR, A20, /**/ A21, A22 ); LockedRepartitionRight ( BL, /**/ BR, B0, /**/ B1, B2 ); RepartitionRight ( CL, /**/ CR, C0, /**/ C1, C2 ); LockedView1x2( ARowPan, A11, A12 ); LockedView2x1 ( AColPan, A01, A11 ); View1x2( CLeft, C0, C1 ); View1x2( CRight, C1, C2 ); AColPan_VR_STAR.AlignWith( CLeft ); AColPanTrans_STAR_MR.AlignWith( CLeft ); ARowPanTrans_MR_STAR.AlignWith( CRight ); //--------------------------------------------------------------------// B1_MC_STAR = B1; AColPan_VR_STAR = AColPan; AColPanTrans_STAR_MR.TransposeFrom( AColPan_VR_STAR, conjugate ); ARowPanTrans_MR_STAR.TransposeFrom( ARowPan, conjugate ); MakeTriangular( LOWER, ARowPanTrans_MR_STAR ); MakeTrapezoidal( RIGHT, LOWER, -1, AColPanTrans_STAR_MR ); LocalGemm ( NORMAL, orientation, alpha, B1_MC_STAR, ARowPanTrans_MR_STAR, T(1), CRight ); LocalGemm ( NORMAL, NORMAL, alpha, B1_MC_STAR, AColPanTrans_STAR_MR, T(1), CLeft ); //--------------------------------------------------------------------// AColPan_VR_STAR.FreeAlignments(); AColPanTrans_STAR_MR.FreeAlignments(); ARowPanTrans_MR_STAR.FreeAlignments(); SlideLockedPartitionDownDiagonal ( ATL, /**/ ATR, A00, A01, /**/ A02, /**/ A10, A11, /**/ A12, /*************/ /******************/ ABL, /**/ ABR, A20, A21, /**/ A22 ); SlideLockedPartitionRight ( BL, /**/ BR, B0, B1, /**/ B2 ); SlidePartitionRight ( CL, /**/ CR, C0, C1, /**/ C2 ); } #ifndef RELEASE PopCallStack(); #endif }