Mini Shell

Direktori : /proc/thread-self/root/usr/share/doc/grub2-common/
Upload File :
Current File : //proc/thread-self/root/usr/share/doc/grub2-common/grub-dev.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This developer manual is for GNU GRUB (version 2.06,
2 October 2024).

Copyright (C) 1999,2000,2001,2002,2004,2005,2006,2008,2009,2010,2011 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections. -->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>GNU GRUB Developers Manual 2.06</title>

<meta name="description" content="GNU GRUB Developers Manual 2.06">
<meta name="keywords" content="GNU GRUB Developers Manual 2.06">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="#Top" rel="start" title="Top">
<link href="#Index" rel="index" title="Index">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<h1 class="settitle" align="center">GNU GRUB Developers Manual 2.06</h1>






<span id="SEC_Contents"></span>
<h2 class="contents-heading">Table of Contents</h2>

<div class="contents">

<ul class="no-bullet">
  <li><a id="toc-Getting-the-source-code-1" href="#Getting-the-source-code">1 Getting the source code</a></li>
  <li><a id="toc-Coding-style-1" href="#Coding-style">2 Coding style</a>
  <ul class="no-bullet">
    <li><a id="toc-Naming-Conventions-1" href="#Naming-Conventions">2.1 Naming Conventions</a></li>
    <li><a id="toc-Functions-1" href="#Functions">2.2 Functions</a></li>
    <li><a id="toc-Variables-1" href="#Variables">2.3 Variables</a></li>
    <li><a id="toc-Types-1" href="#Types">2.4 Types</a></li>
    <li><a id="toc-Macros-1" href="#Macros">2.5 Macros</a></li>
    <li><a id="toc-Comments-1" href="#Comments">2.6 Comments</a></li>
    <li><a id="toc-Multi_002dLine-Comments-1" href="#Multi_002dLine-Comments">2.7 Multi-Line Comments</a></li>
  </ul></li>
  <li><a id="toc-Finding-your-way-around-1" href="#Finding-your-way-around">3 Finding your way around</a></li>
  <li><a id="toc-Contributing-changes" href="#Contributing-Changes">4 Contributing changes</a>
  <ul class="no-bullet">
    <li><a id="toc-Getting-started-1" href="#Getting-started">4.1 Getting started</a></li>
    <li><a id="toc-Typical-Developer-Experience-1" href="#Typical-Developer-Experience">4.2 Typical Developer Experience</a></li>
    <li><a id="toc-When-you-are-approved-for-write-access-to-project_0027s-files-1" href="#When-you-are-approved-for-write-access-to-project_0027s-files">4.3 When you are approved for write access to project&rsquo;s files</a></li>
  </ul></li>
  <li><a id="toc-Updating-external-code" href="#Updating-External-Code">5 Updating external code</a>
  <ul class="no-bullet">
    <li><a id="toc-Gnulib-1" href="#Gnulib">5.1 Gnulib</a></li>
    <li><a id="toc-jsmn-1" href="#jsmn">5.2 jsmn</a></li>
    <li><a id="toc-minilzo-1" href="#minilzo">5.3 minilzo</a></li>
  </ul></li>
  <li><a id="toc-Porting-1" href="#Porting">6 Porting</a></li>
  <li><a id="toc-Error-Handling-1" href="#Error-Handling">7 Error Handling</a></li>
  <li><a id="toc-Stack-and-heap-size-1" href="#Stack-and-heap-size">8 Stack and heap size</a></li>
  <li><a id="toc-BIOS-port-memory-map-1" href="#BIOS-port-memory-map">9 BIOS port memory map</a></li>
  <li><a id="toc-Video-Subsystem-1" href="#Video-Subsystem">10 Video Subsystem</a>
  <ul class="no-bullet">
    <li><a id="toc-Video-API-1" href="#Video-API">10.1 Video API</a>
    <ul class="no-bullet">
      <li><a id="toc-grub_005fvideo_005fsetup" href="#grub_005fvideo_005fsetup">10.1.1 grub_video_setup</a></li>
      <li><a id="toc-grub_005fvideo_005frestore" href="#grub_005fvideo_005frestore">10.1.2 grub_video_restore</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005finfo" href="#grub_005fvideo_005fget_005finfo">10.1.3 grub_video_get_info</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005fblit_005fformat" href="#grub_005fvideo_005fget_005fblit_005fformat">10.1.4 grub_video_get_blit_format</a></li>
      <li><a id="toc-grub_005fvideo_005fset_005fpalette" href="#grub_005fvideo_005fset_005fpalette">10.1.5 grub_video_set_palette</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005fpalette" href="#grub_005fvideo_005fget_005fpalette">10.1.6 grub_video_get_palette</a></li>
      <li><a id="toc-grub_005fvideo_005fset_005farea_005fstatus" href="#grub_005fvideo_005fset_005farea_005fstatus">10.1.7 grub_video_set_area_status</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005farea_005fstatus" href="#grub_005fvideo_005fget_005farea_005fstatus">10.1.8 grub_video_get_area_status</a></li>
      <li><a id="toc-grub_005fvideo_005fset_005fviewport" href="#grub_005fvideo_005fset_005fviewport">10.1.9 grub_video_set_viewport</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005fviewport" href="#grub_005fvideo_005fget_005fviewport">10.1.10 grub_video_get_viewport</a></li>
      <li><a id="toc-grub_005fvideo_005fset_005fregion" href="#grub_005fvideo_005fset_005fregion">10.1.11 grub_video_set_region</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005fregion" href="#grub_005fvideo_005fget_005fregion">10.1.12 grub_video_get_region</a></li>
      <li><a id="toc-grub_005fvideo_005fmap_005fcolor" href="#grub_005fvideo_005fmap_005fcolor">10.1.13 grub_video_map_color</a></li>
      <li><a id="toc-grub_005fvideo_005fmap_005frgb" href="#grub_005fvideo_005fmap_005frgb">10.1.14 grub_video_map_rgb</a></li>
      <li><a id="toc-grub_005fvideo_005fmap_005frgba" href="#grub_005fvideo_005fmap_005frgba">10.1.15 grub_video_map_rgba</a></li>
      <li><a id="toc-grub_005fvideo_005funmap_005fcolor" href="#grub_005fvideo_005funmap_005fcolor">10.1.16 grub_video_unmap_color</a></li>
      <li><a id="toc-grub_005fvideo_005ffill_005frect" href="#grub_005fvideo_005ffill_005frect">10.1.17 grub_video_fill_rect</a></li>
      <li><a id="toc-grub_005fvideo_005fblit_005fglyph" href="#grub_005fvideo_005fblit_005fglyph">10.1.18 grub_video_blit_glyph</a></li>
      <li><a id="toc-grub_005fvideo_005fblit_005fbitmap" href="#grub_005fvideo_005fblit_005fbitmap">10.1.19 grub_video_blit_bitmap</a></li>
      <li><a id="toc-grub_005fvideo_005fblit_005frender_005ftarget" href="#grub_005fvideo_005fblit_005frender_005ftarget">10.1.20 grub_video_blit_render_target</a></li>
      <li><a id="toc-grub_005fvideo_005fscroll" href="#grub_005fvideo_005fscroll">10.1.21 grub_video_scroll</a></li>
      <li><a id="toc-grub_005fvideo_005fswap_005fbuffers" href="#grub_005fvideo_005fswap_005fbuffers">10.1.22 grub_video_swap_buffers</a></li>
      <li><a id="toc-grub_005fvideo_005fcreate_005frender_005ftarget" href="#grub_005fvideo_005fcreate_005frender_005ftarget">10.1.23 grub_video_create_render_target</a></li>
      <li><a id="toc-grub_005fvideo_005fdelete_005frender_005ftarget" href="#grub_005fvideo_005fdelete_005frender_005ftarget">10.1.24 grub_video_delete_render_target</a></li>
      <li><a id="toc-grub_005fvideo_005fset_005factive_005frender_005ftarget" href="#grub_005fvideo_005fset_005factive_005frender_005ftarget">10.1.25 grub_video_set_active_render_target</a></li>
      <li><a id="toc-grub_005fvideo_005fget_005factive_005frender_005ftarget" href="#grub_005fvideo_005fget_005factive_005frender_005ftarget">10.1.26 grub_video_get_active_render_target</a></li>
    </ul></li>
    <li><a id="toc-Example-usage-of-Video-API-1" href="#Example-usage-of-Video-API">10.2 Example usage of Video API</a>
    <ul class="no-bullet">
      <li><a id="toc-Example-of-screen-setup" href="#Example-of-screen-setup">10.2.1 Example of screen setup</a></li>
      <li><a id="toc-Example-of-setting-up-console-viewport" href="#Example-of-setting-up-console-viewport">10.2.2 Example of setting up console viewport</a></li>
    </ul></li>
    <li><a id="toc-Bitmap-API-1" href="#Bitmap-API">10.3 Bitmap API</a>
    <ul class="no-bullet">
      <li><a id="toc-grub_005fvideo_005fbitmap_005fcreate" href="#grub_005fvideo_005fbitmap_005fcreate">10.3.1 grub_video_bitmap_create</a></li>
      <li><a id="toc-grub_005fvideo_005fbitmap_005fdestroy" href="#grub_005fvideo_005fbitmap_005fdestroy">10.3.2 grub_video_bitmap_destroy</a></li>
      <li><a id="toc-grub_005fvideo_005fbitmap_005fload" href="#grub_005fvideo_005fbitmap_005fload">10.3.3 grub_video_bitmap_load</a></li>
      <li><a id="toc-grub_005fvideo_005fbitmap_005fget_005fwidth" href="#grub_005fvideo_005fbitmap_005fget_005fwidth">10.3.4 grub_video_bitmap_get_width</a></li>
      <li><a id="toc-grub_005fvideo_005fbitmap_005fget_005fheight" href="#grub_005fvideo_005fbitmap_005fget_005fheight">10.3.5 grub_video_bitmap_get_height</a></li>
      <li><a id="toc-grub_005fvideo_005fbitmap_005fget_005fmode_005finfo" href="#grub_005fvideo_005fbitmap_005fget_005fmode_005finfo">10.3.6 grub_video_bitmap_get_mode_info</a></li>
      <li><a id="toc-grub_005fvideo_005fbitmap_005fget_005fdata" href="#grub_005fvideo_005fbitmap_005fget_005fdata">10.3.7 grub_video_bitmap_get_data</a></li>
    </ul></li>
  </ul></li>
  <li><a id="toc-PFF2-Font-File-Format-1" href="#PFF2-Font-File-Format">11 PFF2 Font File Format</a>
  <ul class="no-bullet">
    <li><a id="toc-Introduction-1" href="#Introduction">11.1 Introduction</a>
    <ul class="no-bullet">
      <li><a id="toc-Goals-of-the-GRUB-Font-Format" href="#Goals-of-the-GRUB-Font-Format">11.1.1 Goals of the GRUB Font Format</a></li>
      <li><a id="toc-Why-Another-Font-Format_003f" href="#Why-Another-Font-Format_003f">11.1.2 Why Another Font Format?</a></li>
    </ul></li>
    <li><a id="toc-File-Structure-1" href="#File-Structure">11.2 File Structure</a>
    <ul class="no-bullet">
      <li><a id="toc-Section-Types" href="#Section-Types">11.2.1 Section Types</a></li>
    </ul></li>
    <li><a id="toc-Font-Metrics-1" href="#Font-Metrics">11.3 Font Metrics</a></li>
  </ul></li>
  <li><a id="toc-Graphical-Menu-Software-Design-1" href="#Graphical-Menu-Software-Design">12 Graphical Menu Software Design</a>
  <ul class="no-bullet">
    <li><a id="toc-Introduction-2" href="#Introduction_005f2">12.1 Introduction</a></li>
    <li><a id="toc-Startup-Sequence-1" href="#Startup-Sequence">12.2 Startup Sequence</a></li>
    <li><a id="toc-GUI-Components-1" href="#GUI-Components">12.3 GUI Components</a></li>
    <li><a id="toc-Command-Line-Window-1" href="#Command-Line-Window">12.4 Command Line Window</a></li>
  </ul></li>
  <li><a id="toc-Verifiers-framework-1" href="#Verifiers-framework">13 Verifiers framework</a></li>
  <li><a id="toc-Lockdown-framework-1" href="#Lockdown-framework">14 Lockdown framework</a></li>
  <li><a id="toc-Copying-This-Manual-1" href="#Copying-This-Manual">Appendix A Copying This Manual</a>
  <ul class="no-bullet">
    <li><a id="toc-GNU-Free-Documentation-License-1" href="#GNU-Free-Documentation-License">A.1 GNU Free Documentation License</a>
    <ul class="no-bullet">
      <li><a id="toc-ADDENDUM_003a-How-to-use-this-License-for-your-documents" href="#ADDENDUM_003a-How-to-use-this-License-for-your-documents">A.1.1 ADDENDUM: How to use this License for your documents</a></li>
    </ul></li>
  </ul></li>
  <li><a id="toc-Index-1" href="#Index" rel="index">Index</a></li>
</ul>
</div>



<span id="Top"></span><div class="header">
<p>
Next: <a href="#Getting-the-source-code" accesskey="n" rel="next">Getting the source code</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="GNU-GRUB-developer-manual"></span><h1 class="top">GNU GRUB developer manual</h1>

<p>This is the developer documentation of GNU GRUB, the GRand Unified Bootloader,
a flexible and powerful boot loader program for a wide range of
architectures.
</p>
<p>This edition documents version 2.06.
</p>
<p>This developer manual is for GNU GRUB (version 2.06,
2 October 2024).
</p>
<p>Copyright &copy; 1999,2000,2001,2002,2004,2005,2006,2008,2009,2010,2011 Free Software Foundation, Inc.
</p>
<blockquote>
<p>Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections.
</p></blockquote>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Getting-the-source-code" accesskey="1">Getting the source code</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Coding-style" accesskey="2">Coding style</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Finding-your-way-around" accesskey="3">Finding your way around</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Contributing-Changes" accesskey="4">Contributing Changes</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Updating-External-Code" accesskey="5">Updating External Code</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Porting" accesskey="6">Porting</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Error-Handling" accesskey="7">Error Handling</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Stack-and-heap-size" accesskey="8">Stack and heap size</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#BIOS-port-memory-map" accesskey="9">BIOS port memory map</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Video-Subsystem">Video Subsystem</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#PFF2-Font-File-Format">PFF2 Font File Format</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Graphical-Menu-Software-Design">Graphical Menu Software Design</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Verifiers-framework">Verifiers framework</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Lockdown-framework">Lockdown framework</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Copying-This-Manual">Copying This Manual</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Copying This Manual
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Index" rel="index">Index</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>


<hr>
<span id="Getting-the-source-code"></span><div class="header">
<p>
Next: <a href="#Coding-style" accesskey="n" rel="next">Coding style</a>, Previous: <a href="#Top" accesskey="p" rel="prev">Top</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Getting-the-source-code-1"></span><h2 class="chapter">1 Getting the source code</h2>

<p>GRUB is maintained using the <a href="GIT revision
control system">GIT revision
control system</a>.  To fetch:
</p>
<div class="example">
<pre class="example">git clone git://git.sv.gnu.org/grub.git
</pre></div>

<p>Web access is available under
</p><div class="example">
<pre class="example">http://git.savannah.gnu.org/cgit/grub.git/
</pre></div>

<p>The branches available are:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>master</samp>&rsquo;</dt>
<dd><p>Main development branch.
</p></dd>
<dt>&lsquo;<samp>grub-legacy</samp>&rsquo;</dt>
<dd><p>GRUB 0.97 codebase. Kept for reference and legal reasons
</p></dd>
<dt>&lsquo;<samp>multiboot</samp>&rsquo;</dt>
<dd><p>Multiboot specfication
</p></dd>
<dt>&lsquo;<samp>multiboot2</samp>&rsquo;</dt>
<dd><p>Multiboot2 specfication
</p></dd>
<dt>&lsquo;<samp>developer branches</samp>&rsquo;</dt>
<dd><p>Prefixed with developer name. Every developer of a team manages his own branches.
      Developer branches do not need changelog entries.
</p></dd>
</dl>

<p>Once you have used <kbd>git clone</kbd> to fetch an initial copy of a branch, you
can use <kbd>git pull</kbd> to keep it up to date.  If you have modified your
local version, you may need to resolve conflicts when pulling.
</p>
<hr>
<span id="Coding-style"></span><div class="header">
<p>
Next: <a href="#Finding-your-way-around" accesskey="n" rel="next">Finding your way around</a>, Previous: <a href="#Getting-the-source-code" accesskey="p" rel="prev">Getting the source code</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Coding-style-1"></span><h2 class="chapter">2 Coding style</h2>

<p>Basically we follow the <a href="http://www.gnu.org/prep/standards_toc.html">GNU Coding Standards</a>. We define additional conventions for GRUB here.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Naming-Conventions" accesskey="1">Naming Conventions</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Functions" accesskey="2">Functions</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Variables" accesskey="3">Variables</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Types" accesskey="4">Types</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Macros" accesskey="5">Macros</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Comments" accesskey="6">Comments</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Multi_002dLine-Comments" accesskey="7">Multi-Line Comments</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<span id="Naming-Conventions"></span><div class="header">
<p>
Next: <a href="#Functions" accesskey="n" rel="next">Functions</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Naming-Conventions-1"></span><h3 class="section">2.1 Naming Conventions</h3>

<p>All global symbols (i.e. functions, variables, types, and macros) must have the prefix grub_ or GRUB_. The all capital form is used only by macros.
</p>
<hr>
<span id="Functions"></span><div class="header">
<p>
Next: <a href="#Variables" accesskey="n" rel="next">Variables</a>, Previous: <a href="#Naming-Conventions" accesskey="p" rel="prev">Naming Conventions</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Functions-1"></span><h3 class="section">2.2 Functions</h3>

<p>If a function is global, its name must be prefixed with grub_ and must consist of only small letters. If the function belongs to a specific function module, the name must also be prefixed with the module name. For example, if a function is for file systems, its name is prefixed with grub_fs_. If a function is for FAT file system but not for all file systems, its name is prefixed with grub_fs_fat_. The hierarchy is noted this way.
</p>
<p>After a prefix, a function name must start with a verb (such as get or is). It must not be a noun. Some kind of abbreviation is permitted, as long as it wouldn&rsquo;t make code less readable (e.g. init).
</p>
<p>If a function is local, its name may not start with any prefix. It must start with a verb.
</p>
<hr>
<span id="Variables"></span><div class="header">
<p>
Next: <a href="#Types" accesskey="n" rel="next">Types</a>, Previous: <a href="#Functions" accesskey="p" rel="prev">Functions</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Variables-1"></span><h3 class="section">2.3 Variables</h3>

<p>The rule is mostly the same as functions, as noted above. If a variable is global, its name must be prefixed with grub_ and must consist of only small letters. If the variable belongs to a specific function module, the name must also be prefixed with the module name. For example, if a function is for dynamic loading, its name is prefixed with grub_dl_. If a variable is for ELF but not for all dynamic loading systems, its name is prefixed with grub_dl_elf_.
</p>
<p>After a prefix, a variable name must start with a noun or an adjective (such as name or long) and it should end with a noun. Some kind of abbreviation is permitted, as long as it wouldn&rsquo;t make code less readable (e.g. i18n).
</p>
<p>If a variable is global in the scope of a single file (i.e. it is declared with static), its name may not start with any prefix. It must start with a noun or an adjective.
</p>
<p>If a variable is local, you may choose any shorter name, as long as it wouldn&rsquo;t make code less readable (e.g. i).
</p>
<hr>
<span id="Types"></span><div class="header">
<p>
Next: <a href="#Macros" accesskey="n" rel="next">Macros</a>, Previous: <a href="#Variables" accesskey="p" rel="prev">Variables</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Types-1"></span><h3 class="section">2.4 Types</h3>

<p>The name of a type must be prefixed with grub_ and must consist of only small letters. If the type belongs to a specific function module, the name must also be prefixed with the module name. For example, if a type is for OS loaders, its name is prefixed with grub_loader_. If a type is for Multiboot but not for all OS loaders, its name is prefixed with grub_loader_linux_.
</p>
<p>The name must be suffixed with _t, to emphasize the fact that it is a type but not a variable or a function.
</p>
<hr>
<span id="Macros"></span><div class="header">
<p>
Next: <a href="#Comments" accesskey="n" rel="next">Comments</a>, Previous: <a href="#Types" accesskey="p" rel="prev">Types</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Macros-1"></span><h3 class="section">2.5 Macros</h3>

<p>If a macro is global, its name must be prefixed with GRUB_ and must consist of only large letters. Other rules are the same as functions or variables, depending on whether a macro is used like a function or a variable.
</p>
<hr>
<span id="Comments"></span><div class="header">
<p>
Next: <a href="#Multi_002dLine-Comments" accesskey="n" rel="next">Multi-Line Comments</a>, Previous: <a href="#Macros" accesskey="p" rel="prev">Macros</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Comments-1"></span><h3 class="section">2.6 Comments</h3>

<p>All comments shall be C-style comments, of the form &lsquo;<samp>/* &hellip; */</samp>&rsquo;.
A comment can be placed immediately preceding the entity it describes or it
can be placed together with code, variable declarations, or other non-comment
entities. However, it is recommended to not mix various forms especially in
types/structs descriptions.
</p>
<p>Acceptable:
</p><div class="example">
<pre class="example">/* The page # that is the front buffer. */
int displayed_page;
</pre></div>

<div class="example">
<pre class="example">int render_page; /* The page # that is the back buffer. */
</pre></div>

<hr>
<span id="Multi_002dLine-Comments"></span><div class="header">
<p>
Previous: <a href="#Comments" accesskey="p" rel="prev">Comments</a>, Up: <a href="#Coding-style" accesskey="u" rel="up">Coding style</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Multi_002dLine-Comments-1"></span><h3 class="section">2.7 Multi-Line Comments</h3>

<p>Comments spanning multiple lines shall be formatted with all lines after the
first aligned with the first line. Asterisk characters should be repeated at
the start of each subsequent line.
</p>
<p>Acceptable:
</p><div class="example">
<pre class="example">/*
 * This is a comment
 * which spans multiple lines.
 * It is long.
 */
</pre></div>

<p>Unacceptable:
</p><div class="example">
<pre class="example">/* This is a comment
   which spans multiple lines.
   It is long. */
</pre></div>

<div class="example">
<pre class="example">/*
 * This is a comment
 * which spans multiple lines.
 * It is long. */
</pre></div>

<div class="example">
<pre class="example">/* This is a comment
 * which spans multiple lines.
 * It is long.
 */
</pre></div>

<p>In particular first unacceptable form makes comment difficult to distinguish
from the code itself. Especially if it contains the code snippets and/or is
long. So, its usage is disallowed.
</p>
<hr>
<span id="Finding-your-way-around"></span><div class="header">
<p>
Next: <a href="#Contributing-Changes" accesskey="n" rel="next">Contributing Changes</a>, Previous: <a href="#Coding-style" accesskey="p" rel="prev">Coding style</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Finding-your-way-around-1"></span><h2 class="chapter">3 Finding your way around</h2>

<p>Here is a brief map of the GRUB code base.
</p>
<p>GRUB uses Autoconf and Automake, with most of the Automake input generated
by a Python script.  The top-level build rules are in <samp>configure.ac</samp>,
<samp>grub-core/Makefile.core.def</samp>, and <samp>Makefile.util.def</samp>.  Each
block in a <samp>*.def</samp> file represents a build target, and specifies the
source files used to build it on various platforms.  The <samp>*.def</samp> files
are processed into Automake input by <samp>gentpl.py</samp> (which you only need
to look at if you are extending the build system).  If you are adding a new
module which follows an existing pattern, such as a new command or a new
filesystem implementation, it is usually easiest to grep
<samp>grub-core/Makefile.core.def</samp> and <samp>Makefile.util.def</samp> for an
existing example of that pattern to find out where it should be added.
</p>
<p>In general, code that may be run at boot time is in a subdirectory of
<samp>grub-core</samp>, while code that is only run from within a full operating
system is in a subdirectory of the top level.
</p>
<p>Low-level boot code, such as the MBR implementation on PC BIOS systems, is
in the <samp>grub-core/boot/</samp> directory.
</p>
<p>The GRUB kernel is in <samp>grub-core/kern/</samp>.  This contains core facilities
such as the device, disk, and file frameworks, environment variable
handling, list processing, and so on.  The kernel should contain enough to
get up to a rescue prompt.  Header files for kernel facilities, among
others, are in <samp>include/</samp>.
</p>
<p>Terminal implementations are in <samp>grub-core/term/</samp>.
</p>
<p>Disk access code is spread across <samp>grub-core/disk/</samp> (for accessing the
disk devices themselves), <samp>grub-core/partmap/</samp> (for interpreting
partition table data), and <samp>grub-core/fs/</samp> (for accessing filesystems).
Note that, with the odd specialised exception, GRUB only contains code to
<em>read</em> from filesystems and tries to avoid containing any code to
<em>write</em> to filesystems; this lets us confidently assure users that GRUB
cannot be responsible for filesystem corruption.
</p>
<p>PCI and USB bus handling is in <samp>grub-core/bus/</samp>.
</p>
<p>Video handling code is in <samp>grub-core/video/</samp>.  The graphical menu
system uses this heavily, but is in a separate directory,
<samp>grub-core/gfxmenu/</samp>.
</p>
<p>Most commands are implemented by files in <samp>grub-core/commands/</samp>, with
the following exceptions:
</p>
<ul>
<li> A few core commands live in <samp>grub-core/kern/corecmd.c</samp>.

</li><li> Commands related to normal mode live under <samp>grub-core/normal/</samp>.

</li><li> Commands that load and boot kernels live under <samp>grub-core/loader/</samp>.

</li><li> The &lsquo;<samp>loopback</samp>&rsquo; command is really a disk device, and so lives in
<samp>grub-core/disk/loopback.c</samp>.

</li><li> The &lsquo;<samp>gettext</samp>&rsquo; command lives under <samp>grub-core/gettext/</samp>.

</li><li> The &lsquo;<samp>loadfont</samp>&rsquo; and &lsquo;<samp>lsfonts</samp>&rsquo; commands live under
<samp>grub-core/font/</samp>.

</li><li> The &lsquo;<samp>serial</samp>&rsquo;, &lsquo;<samp>terminfo</samp>&rsquo;, and &lsquo;<samp>background_image</samp>&rsquo; commands
live under <samp>grub-core/term/</samp>.

</li><li> The &lsquo;<samp>efiemu_*</samp>&rsquo; commands live under <samp>grub-core/efiemu/</samp>.

</li><li> OS-dependent code should be under <samp>grub-core/osdep/</samp>

</li><li> Utility programs meant to be run from a full operating system
(except OS-dependent code mentioned previously) are in <samp>util/</samp>.

</li></ul>

<p>There are a few other special-purpose exceptions; grep for them if they
matter to you.
</p>
<hr>
<span id="Contributing-Changes"></span><div class="header">
<p>
Next: <a href="#Updating-External-Code" accesskey="n" rel="next">Updating External Code</a>, Previous: <a href="#Finding-your-way-around" accesskey="p" rel="prev">Finding your way around</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Contributing-changes"></span><h2 class="chapter">4 Contributing changes</h2>

<p>Contributing changes to GRUB 2 is welcomed activity. However we have a
bit of control what kind of changes will be accepted to GRUB 2.
Therefore it is important to discuss your changes on grub-devel mailing list
(see MailingLists). On this page there are some basic details on the
development process and activities.
</p>
<p>First of all you should come up with the idea yourself what you want to
contribute. If you do not have that beforehand you are advised to study this
manual and try GRUB 2 out to see what you think is missing from there.
</p>
<p>Here are additional pointers:
</p><ul>
<li> <a href="https://savannah.gnu.org/task/?group=grub GRUB's Task Tracker">https://savannah.gnu.org/task/?group=grub GRUB's Task Tracker</a>
</li><li> <a href="https://savannah.gnu.org/bugs/?group=grub GRUB's Bug Tracker">https://savannah.gnu.org/bugs/?group=grub GRUB's Bug Tracker</a>
</li></ul>

<p>If you intended to make changes to GRUB Legacy (&lt;=0.97) those are not accepted
anymore.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Getting-started" accesskey="1">Getting started</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Typical-Developer-Experience" accesskey="2">Typical Developer Experience</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#When-you-are-approved-for-write-access-to-project_0027s-files" accesskey="3">When you are approved for write access to project's files</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<span id="Getting-started"></span><div class="header">
<p>
Next: <a href="#Typical-Developer-Experience" accesskey="n" rel="next">Typical Developer Experience</a>, Up: <a href="#Contributing-Changes" accesskey="u" rel="up">Contributing Changes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Getting-started-1"></span><h3 class="section">4.1 Getting started</h3>

<ul>
<li> Always use latest GRUB 2 source code. So get that first.

<p>For developers it is recommended always to use the newest development version of GRUB 2. If development takes a long period of time, please remember to keep in sync with newest developments regularly so it is much easier to integrate your change in the future. GRUB 2 is being developed in a GIT repository.
</p>
<p>Please check Savannah&rsquo;s GRUB project page for details how to get newest git:
<a href="https://savannah.gnu.org/git/?group=grub">GRUB 2 git Repository</a>
</p>
</li><li> Compile it and try it out.

<p>It is always good idea to first see that things work somehow and after that
to start to implement new features or develop fixes to bugs.
</p>
</li><li> Study the code.

<p>There are sometimes odd ways to do things in GRUB 2 code base.
This is mainly related to limited environment where GRUB 2 is being executed.
You usually do not need to understand it all so it is better to only try to
look at places that relates to your work. Please do not hesitate to ask for
help if there is something that you do not understand.
</p>
</li><li> Develop a new feature.

<p>Now that you know what to do and how it should work in GRUB 2 code base, please
be free to develop it. If you have not so far announced your idea on grub-devel
mailing list, please do it now. This is to make sure you are not wasting your
time working on the solution that will not be integrated to GRUB 2 code base.
</p>
<p>You might want to study our coding style before starting development so you
do not need to change much of the code when your patch is being reviewed.
(see <a href="#Coding-style">Coding style</a>)
</p>
<p>For every accepted patch there has to exist a ChangeLog entry. Our ChangeLog
consist of changes within source code and are not describing about what the
change logically does. Please see examples from previous entries.
</p>
<p>Also remember that GRUB 2 is licensed under GPLv3 license and that usually
means that you are not allowed to copy pieces of code from other projects.
Even if the source project&rsquo;s license would be compatible with GPLv3, please
discuss it beforehand on grub-devel mailing list.
</p>
</li><li> Test your change.

<p>Test that your change works properly. Try it out a couple of times, preferably on different systems, and try to find problems with it.
</p>
</li><li> Publish your change.

<p>When you are happy with your change, first make sure it is compilable with
latest development version of GRUB 2. After that please send a patch to
grub-devel for review. Please describe in your email why you made the change,
what it changes and so on. Please be prepared to receive even discouraging
comments about your patch. There is usually at least something that needs
to be improved in every patch.
</p>
<p>Please use unified diff to make your patch (good match of arguments for diff is &lsquo;<samp>-pruN</samp>&rsquo;).
</p>
</li><li> Respond to received feedback.

<p>If you are asked to modify your patch, please do that and resubmit it for
review. If your change is large you are required to submit a copyright
agreement to FSF. Please keep in mind that if you are asked to submit
for copyright agreement, process can take some time and is mandatory
in order to get your changes integrated.
</p>
<p>If you are not on grub-devel to respond to questions, most likely your patch
will not be accepted. Also if problems arise from your changes later on,
it would be preferable that you also fix the problem. So stay around
for a while.
</p>
</li><li> Your patch is accepted.

<p>Good job! Your patch will now be integrated into GRUB 2 mainline, and if it didn&rsquo;t break anything it will be publicly available in the next release.
</p>
<p>Now you are welcome to do further improvements :)
</p></li></ul>

<hr>
<span id="Typical-Developer-Experience"></span><div class="header">
<p>
Next: <a href="#When-you-are-approved-for-write-access-to-project_0027s-files" accesskey="n" rel="next">When you are approved for write access to project's files</a>, Previous: <a href="#Getting-started" accesskey="p" rel="prev">Getting started</a>, Up: <a href="#Contributing-Changes" accesskey="u" rel="up">Contributing Changes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Typical-Developer-Experience-1"></span><h3 class="section">4.2 Typical Developer Experience</h3>

<p>The typical experience for a developer in this project is the following:
</p>
<ol>
<li> You find yourself wanting to do something (e.g. fixing a bug).
</li><li> You show some result in the mailing list or the IRC.
</li><li> You are getting to be known to other developers.
</li><li> You accumulate significant amount of contribution, so copyright assignment is processed.
</li><li> You are free to check in your changes on your own, legally speaking.
</li></ol>

<p>At this point, it is rather annoying that you ought to ask somebody else every
change to be checked in. For efficiency, it is far better, if you can commit
it yourself. Therefore, our policy is to give you the write permission to our
official repository, once you have shown your skill and will,
and the FSF clerks have dealt with your copyright assignment.
</p>
<hr>
<span id="When-you-are-approved-for-write-access-to-project_0027s-files"></span><div class="header">
<p>
Previous: <a href="#Typical-Developer-Experience" accesskey="p" rel="prev">Typical Developer Experience</a>, Up: <a href="#Contributing-Changes" accesskey="u" rel="up">Contributing Changes</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="When-you-are-approved-for-write-access-to-project_0027s-files-1"></span><h3 class="section">4.3 When you are approved for write access to project&rsquo;s files</h3>

<p>As you might know, GRUB is hosted on
<a href="https://savannah.gnu.org/projects/grub Savannah">https://savannah.gnu.org/projects/grub Savannah</a>, thus the membership
is managed by Savannah. This means that, if you want to be a member of this
project:
</p>
<ol>
<li> You need to create your own account on Savannah.
</li><li> You can submit &ldquo;Request for Inclusion&rdquo; from &ldquo;My Groups&rdquo; on Savannah.
</li></ol>

<p>Then, one of the admins can approve your request, and you will be a member.
If you don&rsquo;t want to use the Savannah interface to submit a request, you can
simply notify the admins by email or something else, alternatively. But you
still need to create an account beforehand.
</p>
<p>NOTE: we sometimes receive a &ldquo;Request for Inclusion&rdquo; from an unknown person.
In this case, the request would be just discarded, since it is too dangerous
to allow a stranger to be a member, which automatically gives him a commit
right to the repository, both for a legal reason and for a technical reason. 
</p>
<p>If your intention is to just get started, please do not submit a inclusion
request. Instead, please subscribe to the mailing list, and communicate first
(e.g. sending a patch, asking a question, commenting on another message...).
</p>
<hr>
<span id="Updating-External-Code"></span><div class="header">
<p>
Next: <a href="#Porting" accesskey="n" rel="next">Porting</a>, Previous: <a href="#Contributing-Changes" accesskey="p" rel="prev">Contributing Changes</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Updating-external-code"></span><h2 class="chapter">5 Updating external code</h2>

<p>GRUB includes some code from other projects, and it is sometimes necessary
to update it.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Gnulib" accesskey="1">Gnulib</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#jsmn" accesskey="2">jsmn</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#minilzo" accesskey="3">minilzo</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<span id="Gnulib"></span><div class="header">
<p>
Next: <a href="#jsmn" accesskey="n" rel="next">jsmn</a>, Up: <a href="#Updating-External-Code" accesskey="u" rel="up">Updating External Code</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Gnulib-1"></span><h3 class="section">5.1 Gnulib</h3>

<p>Gnulib is a source code library that provides basic functionality to
programs and libraries.  Many software packages make use of Gnulib
to avoid reinventing the portability wheel.
</p>
<p>GRUB imports Gnulib using its <code>bootstrap</code> utility, identifying a
particular Git commit in <samp>bootstrap.conf</samp>.  To upgrade to a new Gnulib
commit, set <code>GNULIB_REVISION</code> in <samp>bootstrap.conf</samp> to the new commit
ID, then run <kbd>./bootstrap</kbd> and whatever else you need to make sure it
works.  Check for changes to Gnulib&rsquo;s <samp>NEWS</samp> file between the old and new
commits; in some cases it will be necessary to adjust GRUB to match.  You may
also need to update the patches in <samp>grub-core/lib/gnulib-patches/</samp>.
</p>
<p>To add a new Gnulib module or remove one that is no longer needed, change
<code>gnulib_modules</code> in <samp>bootstrap.conf</samp>.  Again, run <kbd>./bootstrap</kbd>
and whatever else you need to make sure it works.
</p>
<p>Bootstrapping from an older distribution containing gettext version &lt; 0.18.3,
will require a patch similar to this to be applied first before running the
<code>./bootstrap</code> utility:
</p>
<div class="example">
<pre class="example">diff --git a/bootstrap.conf b/bootstrap.conf
index 988dda0..a3193a9 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@ -67,7 +67,7 @ SKIP_PO=t
buildreq=&quot;\
autoconf   2.63
automake   1.11
-gettext    0.18.3
+gettext    0.17
git        1.5.5
tar        -
&quot;
diff --git a/configure.ac b/configure.ac
index 08b518f..99f5b36 100644
--- a/configure.ac
+++ b/configure.ac
@ -362,7 +362,7 @ AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)

AC_GNU_SOURCE
AM_GNU_GETTEXT([external])
-AM_GNU_GETTEXT_VERSION([0.18.3])
+AM_GNU_GETTEXT_VERSION([0.17])
AC_SYS_LARGEFILE

# Identify characteristics of the host architecture.

</pre></div>

<p>It will also be necessary to adjust the patches in
<samp>po/gettext-patches/</samp> to apply to an older version of gettext.
</p>
<hr>
<span id="jsmn"></span><div class="header">
<p>
Next: <a href="#minilzo" accesskey="n" rel="next">minilzo</a>, Previous: <a href="#Gnulib" accesskey="p" rel="prev">Gnulib</a>, Up: <a href="#Updating-External-Code" accesskey="u" rel="up">Updating External Code</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="jsmn-1"></span><h3 class="section">5.2 jsmn</h3>

<p>jsmn is a minimalistic JSON parser which is implemented in a single header file
<samp>jsmn.h</samp>. To import a different version of the jsmn parser, you may simply
download the <samp>jsmn.h</samp> header from the desired tag or commit to the target
directory:
</p>
<div class="example">
<pre class="example">curl -L https://raw.githubusercontent.com/zserge/jsmn/v1.1.0/jsmn.h \
    -o grub-core/lib/json/jsmn.h
</pre></div>

<hr>
<span id="minilzo"></span><div class="header">
<p>
Previous: <a href="#jsmn" accesskey="p" rel="prev">jsmn</a>, Up: <a href="#Updating-External-Code" accesskey="u" rel="up">Updating External Code</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="minilzo-1"></span><h3 class="section">5.3 minilzo</h3>

<p>miniLZO is a very lightweight subset of the LZO library intended for easy
inclusion in other projects. It is generated automatically from the LZO
source code and contains the most important LZO functions.
</p>
<p>To upgrade to a new version of the miniLZO library, download the release
tarball and copy the files into the target directory:
</p>
<div class="example">
<pre class="example">curl -L -O http://www.oberhumer.com/opensource/lzo/download/minilzo-2.08.tar.gz
tar -zxf minilzo-2.08.tar.gz
rm minilzo-2.08/testmini.c
rm -r grub-core/lib/minilzo/*
cp minilzo-2.08/*.[hc] grub-core/lib/minilzo
rm -r minilzo-2.08*
</pre></div>

<hr>
<span id="Porting"></span><div class="header">
<p>
Next: <a href="#Error-Handling" accesskey="n" rel="next">Error Handling</a>, Previous: <a href="#Updating-External-Code" accesskey="p" rel="prev">Updating External Code</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Porting-1"></span><h2 class="chapter">6 Porting</h2>

<p>GRUB2 is designed to be easily portable accross platforms. But because of the
nature of bootloader every new port must be done separately. Here is how I did
MIPS (loongson and ARC) and Xen ports. Note than this is more of suggestions,
not absolute truth.
</p>
<p>First of all grab any architecture specifications you can find in public
(please avoid NDA).
</p>
<p>First stage is &ldquo;Hello world&rdquo;. I&rsquo;ve done it outside of GRUB for simplicity.
Your task is to have a small program which is loadable as bootloader and
clearly shows its presence to you. If you have easily accessible console
you can just print a message. If you have a mapped framebuffer you know address
of, you can draw a square. If you have a debug facility, just hanging without
crashing might be enough. For the first stage you can choose to load the
bootloader across the network since format for network image is often easier
than for local boot and it skips the need of small intermediary stages and
nvram handling. Additionally you can often have a good idea of the needed
format by running &ldquo;file&rdquo; on any netbootable executable for given platform.
</p>
<p>This program should probably have 2 parts: an assembler and C one. Assembler one
handles BSS cleaning and other needed setup (on some platforms you may need
to switch modes or copy the executable to its definitive position). So your code
may look like (x86 assembly for illustration purposes)
</p>
<div class="example">
<pre class="example">        .globl _start
_start:
	movl	$_bss_start, %edi
	movl	$_end, %ecx
	subl	%edi, %ecx
	xorl	%eax, %eax
	cld
	rep
	stosb
        call main
</pre></div>

<div class="example">
<pre class="example">

static const char msg[] = &quot;Hello, world&quot;;

void
putchar (int c)
{
  ...
}

void
main (void)
{
  const char *ptr = msg;
  while (*ptr)
    putchar (*ptr++);
  while (1);
}
</pre></div>

<p>Sometimes you need a third file: assembly stubs for ABI-compatibility.
</p>
<p>Once this file is functional it&rsquo;s time to move it into GRUB2. The startup
assembly file goes to grub-core/kern/$cpu/$platform/startup.S. You should also
include grub/symbol.h and replace call to entry point with call to
EXT_C(grub_main). The C file goes to grub-core/kern/$cpu/$platform/init.c
and its entry point is renamed to void grub_machine_init (void). Keep final
infinite loop for now. Stubs file if any goes to
grub-core/kern/$cpu/$platform/callwrap.S. Sometimes either $cpu or $platform
is dropped if file is used on several cpus respectivelyplatforms.
Check those locations if they already have what you&rsquo;re looking for.
</p>
<p>Then modify in configure.ac the following parts:
</p>
<p>CPU names:
</p>
<div class="example">
<pre class="example">case &quot;$target_cpu&quot; in
  i[[3456]]86)	target_cpu=i386 ;;
  amd64)	target_cpu=x86_64 ;;
  sparc)	target_cpu=sparc64 ;;
  s390x)	target_cpu=s390 ;;
  ...
esac
</pre></div>

<p>Sometimes CPU have additional architecture names which don&rsquo;t influence booting.
You might want to have some canonical name to avoid having bunch of identical
platforms with different names.
</p>
<p>NOTE: it doesn&rsquo;t influence compile optimisations which depend solely on
chosen compiler and compile options.
</p>
<div class="example">
<pre class="example">if test &quot;x$with_platform&quot; = x; then
  case &quot;$target_cpu&quot;-&quot;$target_vendor&quot; in
    i386-apple) platform=efi ;;
    i386-*) platform=pc ;;
    x86_64-apple) platform=efi ;;
    x86_64-*) platform=pc ;;
    powerpc-*) platform=ieee1275 ;;
    ...
  esac
else
  ...
fi
</pre></div>

<p>This part deals with guessing the platform from CPU and vendor. Sometimes you
need to use 32-bit mode for booting even if OS runs in 64-bit one. If so add
your platform to:
</p>
<div class="example">
<pre class="example">case &quot;$target_cpu&quot;-&quot;$platform&quot; in
  x86_64-efi) ;;
  x86_64-emu) ;;
  x86_64-*) target_cpu=i386 ;;
  powerpc64-ieee1275) target_cpu=powerpc ;;
esac
</pre></div>

<p>Add your platform to the list of supported ones:
</p>
<div class="example">
<pre class="example">case &quot;$target_cpu&quot;-&quot;$platform&quot; in
  i386-efi) ;;
  x86_64-efi) ;;
  i386-pc) ;;
  i386-multiboot) ;;
  i386-coreboot) ;;
  ...
esac
</pre></div>

<p>If explicit -m32 or -m64 is needed add it to:
</p>
<div class="example">
<pre class="example">case &quot;$target_cpu&quot; in
  i386 | powerpc) target_m32=1 ;;
  x86_64 | sparc64) target_m64=1 ;;
esac
</pre></div>

<p>Finally you need to add a conditional to the following block:
</p>
<div class="example">
<pre class="example">AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
</pre></div>

<p>Next stop is gentpl.py. You need to add your platform to the list of supported
ones (sorry that this list is duplicated):
</p>
<div class="example">
<pre class="example">GRUB_PLATFORMS = [ &quot;emu&quot;, &quot;i386_pc&quot;, &quot;i386_efi&quot;, &quot;i386_qemu&quot;, &quot;i386_coreboot&quot;,
                   &quot;i386_multiboot&quot;, &quot;i386_ieee1275&quot;, &quot;x86_64_efi&quot;,
                   &quot;mips_loongson&quot;, &quot;sparc64_ieee1275&quot;,
                   &quot;powerpc_ieee1275&quot;, &quot;mips_arc&quot;, &quot;ia64_efi&quot;,
                   &quot;mips_qemu_mips&quot;, &quot;s390_mainframe&quot; ]
</pre></div>

<p>You may also want already to add new platform to one or several of available
groups. In particular we always have a group for each CPU even when only
one platform for given CPU is available.
</p>
<p>Then comes grub-core/Makefile.core.def. In the block &ldquo;kernel&rdquo; you&rsquo;ll need
to define ldflags for your platform ($cpu_$platform_ldflags). You also need to
declare startup asm file ($cpu_$platform_startup) as well as any other files
(e.g. init.c and callwrap.S) (e.g. $cpu_$platform = kern/$cpu/$platform/init.c).
At this stage you will also need to add dummy dl.c and cache.S with functions
grub_err_t grub_arch_dl_check_header (void *ehdr), grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr) (dl.c), grub_uint32_t
grub_arch_dl_min_alignment (void), and void grub_arch_sync_caches (void
*address, grub_size_t len) (cache.S). They won&rsquo;t be used for now.
</p>
<p>You will need to create directory include/$cpu/$platform and a file
include/$cpu/types.h. The later folowing this template:
</p>
<div class="example">
<pre class="example">#ifndef GRUB_TYPES_CPU_HEADER
#define GRUB_TYPES_CPU_HEADER	1

/* The size of void *.  */
#define GRUB_TARGET_SIZEOF_VOID_P	4

/* The size of long.  */
#define GRUB_TARGET_SIZEOF_LONG		4

/* mycpu is big-endian.  */
#define GRUB_TARGET_WORDS_BIGENDIAN	1
/* Alternatively: mycpu is little-endian.  */
#undef GRUB_TARGET_WORDS_BIGENDIAN

#endif /* ! GRUB_TYPES_CPU_HEADER */
</pre></div>

<p>You will also need to add a dummy file to datetime and setjmp modules to
avoid any of it having no files. It can be just completely empty at this stage.
</p>
<p>You&rsquo;ll need to make grub-mkimage.c (util/grub_mkimage.c) aware of the needed
format. For most commonly used formats like ELF, PE, aout or raw the support
is already present and you&rsquo;ll need to make it follow the existant code paths
for your platform adding adjustments if necessary. When done compile:
</p>
<div class="example">
<pre class="example">./bootstrap
./configure --target=$cpu --with-platform=$platform TARGET_CC=.. OBJCOPY=... STRIP=...
make &gt; /dev/null
</pre></div>

<p>And create image
</p>
<div class="example">
<pre class="example">./grub-mkimage -d grub-core -O $format_id -o test.img
</pre></div>

<p>And it&rsquo;s time to test your test.img.
</p>
<p>If it works next stage is to have heap, console and timer.
</p>
<p>To have the heap working you need to determine which regions are suitable for
heap usage, allocate them from firmware and map (if applicable). Then call
grub_mm_init_region (vois *start, grub_size_t s) for every of this region.
As a shortcut for early port you can allocate right after _end or have
a big static array for heap. If you do you&rsquo;ll probably need to come back to
this later. As for output console you should distinguish between an array of
text, terminfo or graphics-based console. Many of real-world examples don&rsquo;t
fit perfectly into any of these categories but one of the models is easier
to be used as base. In second and third case you should add your platform to 
terminfokernel respectively videoinkernel group. A good example of array of
text is i386-pc (kern/i386/pc/init.c and term/i386/pc/console.c).
Of terminfo is ieee1275 (kern/ieee1275/init.c and term/ieee1275/console.c).
Of video is loongson (kern/mips/loongson/init.c). Note that terminfo has
to be inited in 2 stages: one before (to get at least rudimentary console
as early as possible) and another after the heap (to get full-featured console).
For the input there are string of keys, terminfo and direct hardware. For string
of keys look at i386-pc (same files), for terminfo ieee1275 (same files) and for
hardware loongson (kern/mips/loongson/init.c and term/at_keyboard.c).
</p>
<p>For the timer you&rsquo;ll need to call grub_install_get_time_ms (...) with as sole
argument a function returning a grub_uint64_t of a number of milliseconds
elapsed since arbitrary point in the past.
</p>
<p>Once these steps accomplished you can remove the inifinite loop and you should
be able to get to the minimal console. Next step is to have module loading
working. For this you&rsquo;ll need to fill kern/$cpu/dl.c and kern/$cpu/cache.S
with real handling of relocations and respectively the real sync of I and D
caches. Also you&rsquo;ll need to decide where in the image to store the modules.
Usual way is to have it concatenated at the end. In this case you&rsquo;ll need to
modify startup.S to copy modules out of bss to let&rsquo;s say ALIGN_UP (_end, 8)
before cleaning out bss. You&rsquo;ll probably find useful to add total_module_size
field to startup.S. In init.c you need to set grub_modbase to the address
where modules can be found. You may need grub_modules_get_end () to avoid
declaring the space occupied by modules as usable for heap. You can test modules
with:
</p>
<div class="example">
<pre class="example">./grub-mkimage -d grub-core -O $format_id -o test.img hello
</pre></div>

<p>and then running &ldquo;hello&rdquo; in the shell.
</p>
<p>Once this works, you should think of implementing disk access. Look around
disk/ for examples.
</p>
<p>Then, very importantly, you probably need to implement the actual loader
(examples available in loader/)
</p>
<p>Last step to have minimally usable port is to add support to grub-install to
put GRUB in a place where firmware or platform will pick it up.
</p>
<p>Next steps are: filling datetime.c, setjmp.S, network (net/drivers),
video (video/), halt (lib/), reboot (lib/).
</p>
<p>Please add your platform to Platform limitations and Supported kernels chapter
in user documentation and mention any steps you skipped which result in reduced
features or performance. Here is the quick checklist of features. Some of them
are less important than others and skipping them is completely ok, just needs
to be mentioned in user documentation.
</p>
<p>Checklist:
</p><ul>
<li> Is heap big enough?
</li><li> Which charset is supported by console?
</li><li> Does platform have disk driver?
</li><li> Do you have network card support?
</li><li> Are you able to retrieve datetime (with date)?
</li><li> Are you able to set datetime (with date)?
</li><li> Is serial supported?
</li><li> Do you have direct disk support?
</li><li> Do you have direct keyboard support?
</li><li> Do you have USB support?
</li><li> Do you support loading through network?
</li><li> Do you support loading from disk?
</li><li> Do you support chainloading?
</li><li> Do you support network chainloading?
</li><li> Does cpuid command supports checking all
CPU features that the user might want conditionalise on
(64-bit mode, hypervisor,...)
</li><li> Do you support hints? How reliable are they?
</li><li> Does platform have ACPI? If so do &ldquo;acpi&rdquo; and &ldquo;lsacpi&rdquo; modules work?
</li><li> Do any of platform-specific operations mentioned in the relevant section of
user manual makes sense on your platform?
</li><li> Does your platform support PCI? If so is there an appropriate driver for
GRUB?
</li><li> Do you support badram?
</li></ul>

<hr>
<span id="Error-Handling"></span><div class="header">
<p>
Next: <a href="#Stack-and-heap-size" accesskey="n" rel="next">Stack and heap size</a>, Previous: <a href="#Porting" accesskey="p" rel="prev">Porting</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Error-Handling-1"></span><h2 class="chapter">7 Error Handling</h2>

<p>Error handling in GRUB 2 is based on exception handling model. As C language
doesn&rsquo;t directly support exceptions, exception handling behavior is emulated
in software. 
</p>
<p>When exception is raised, function must return to calling function. If calling
function does not provide handling of the exception it must return back to its
calling function and so on, until exception is handled. If exception is not
handled before prompt is displayed, error message will be shown to user.
</p>
<p>Exception information is stored on <code>grub_errno</code> global variable. If
<code>grub_errno</code> variable contains value <code>GRUB_ERR_NONE</code>, there is no active
exception and application can continue normal processing. When <code>grub_errno</code> has
other value, it is required that application code either handles this error or
returns instantly to caller. If function is with return type <code>grub_err_t</code> is
about to return <code>GRUB_ERR_NONE</code>, it should not set <code>grub_errno</code> to that
value. Only set <code>grub_errno</code> in cases where there is error situation. 
</p>
<p>Simple exception forwarder.
</p><div class="example">
<pre class="example">grub_err_t
forwarding_example (void)
{
  /* Call function that might cause exception.  */
  foobar ();

  /* No special exception handler, just forward possible exceptions.  */
  if (grub_errno != GRUB_ERR_NONE)
    {
      return grub_errno;
    }

  /* All is OK, do more processing.  */

  /* Return OK signal, to caller.  */
  return GRUB_ERR_NONE;
}
</pre></div>

<p>Error reporting has two components, the actual error code (of type
<code>grub_err_t</code>) and textual message that will be displayed to user. List of
valid error codes is listed in header file <samp>include/grub/err.h</samp>. Textual
error message can contain any textual data. At time of writing, error message
can contain up to 256 characters (including terminating NUL). To ease error
reporting there is a helper function <code>grub_error</code> that allows easier
formatting of error messages and should be used instead of writing directly to
global variables.
</p>
<p>Example of error reporting.
</p><div class="example">
<pre class="example">grub_err_t
failing_example ()
{
  return grub_error (GRUB_ERR_FILE_NOT_FOUND, 
                     &quot;Failed to read %s, tried %d times.&quot;,
                     &quot;test.txt&quot;,
                     10);
}
</pre></div>

<p>If there is a special reason that error code does not need to be taken account,
<code>grub_errno</code> can be zeroed back to <code>GRUB_ERR_NONE</code>. In cases like this all
previous error codes should have been handled correctly. This makes sure that
there are no unhandled exceptions.
</p>
<p>Example of zeroing <code>grub_errno</code>.
</p><div class="example">
<pre class="example">grub_err_t
probe_example ()
{
  /* Try to probe device type 1.  */
  probe_for_device ();
  if (grub_errno == GRUB_ERR_NONE)
    {
      /* Device type 1 was found on system.  */
      register_device ();
      return GRUB_ERR_NONE;
    }
  /* Zero out error code.  */
  grub_errno = GRUB_ERR_NONE;

  /* No device type 1 found, try to probe device type 2.  */
  probe_for_device2 ();
  if (grub_errno == GRUB_ERR_NONE)
    {
      /* Device type 2 was found on system.  */
      register_device2 ();
      return GRUB_ERR_NONE;
    }
  /* Zero out error code.  */
  grub_errno = GRUB_ERR_NONE;

  /* Return custom error message.  */
  return grub_error (GRUB_ERR_UNKNOWN_DEVICE, &quot;No device type 1 or 2 found.&quot;);
}
</pre></div>

<p>Some times there is a need to continue processing even if there is a error
state in application. In situations like this, there is a needed to save old
error state and then call other functions that might fail. To aid in this,
there is a error stack implemented. Error state can be pushed to error stack
by calling function <code>grub_error_push ()</code>. When processing has been completed,
<code>grub_error_pop ()</code> can be used to pop error state from stack. Error stack
contains predefined amount of error stack items. Error stack is protected for
overflow and marks these situations so overflow error does not get unseen.
If there is no space available to store error message, it is simply discarded
and overflow will be marked as happened. When overflow happens, it most likely
will corrupt error stack consistency as for pushed error there is no matching
pop, but overflow message will be shown to inform user about the situation.
Overflow message will be shown at time when prompt is about to be drawn.
</p>
<p>Example usage of error stack.
</p><div class="example">
<pre class="example">/* Save possible old error message.  */
grub_error_push ();

/* Do your stuff here.  */
call_possibly_failing_function ();

if (grub_errno != GRUB_ERR_NONE)
  {
    /* Inform rest of the code that there is error (grub_errno
       is set). There is no pop here as we want both error states 
       to be displayed.  */
    return;
  }

/* Restore old error state by popping previous item from stack. */
grub_error_pop ();
</pre></div>

<hr>
<span id="Stack-and-heap-size"></span><div class="header">
<p>
Next: <a href="#BIOS-port-memory-map" accesskey="n" rel="next">BIOS port memory map</a>, Previous: <a href="#Error-Handling" accesskey="p" rel="prev">Error Handling</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Stack-and-heap-size-1"></span><h2 class="chapter">8 Stack and heap size</h2>

<p>On emu stack and heap are just normal host OS stack and heap. Stack is typically
8 MiB although it&rsquo;s OS-dependent.
</p>
<p>On i386-pc, i386-coreboot, i386-qemu and i386-multiboot the stack is 60KiB.
All available space between 1MiB and 4GiB marks is part of heap.
</p>
<p>On *-xen stack is 4MiB. If compiled for x86-64 with GCC 4.4 or later adressable
space is unlimited. When compiled for x86-64 with older GCC version adressable
space is limited to 2GiB. When compiling for i386 adressable space is limited
to 4GiB. All adressable pages except the ones for stack, GRUB binary, special
pages and page table are in the heap.
</p>
<p>On *-efi GRUB uses same stack as EFI. If compiled for x86-64 with GCC 4.4 or
later adressable space is unlimited. When compiled for x86-64 with older GCC
version adressable space is limited to 2GiB. For all other platforms adressable
space is limited to 4GiB. GRUB allocates pages from EFI for its heap, at most
1.6 GiB.
</p>
<p>On i386-ieee1275 and powerpc-ieee1275 GRUB uses same stack as IEEE1275.
</p>
<p>On i386-ieee1275 and powerpc-ieee1275, GRUB will allocate 32MiB for its heap on
startup. It may allocate more at runtime, as long as at least 128MiB remain free
in OpenFirmware.
</p>
<p>On sparc64-ieee1275 stack is 256KiB and heap is 2MiB.
</p>
<p>On mips(el)-qemu_mips and mipsel-loongson stack is 2MiB (everything below
GRUB image) and everything above GRUB image (from 2MiB + kernel size)
until 256MiB is part of heap.
</p>
<p>On mips-arc stack is 2MiB (everything below GRUB image) and everything above
GRUB image(from 2MiB + kernel size) until 128MiB is part of heap.
</p>
<p>On mipsel-arc stack is 2MiB (everything below GRUB image which is not part
of ARC) and everything above GRUB image (from 7MiB + kernel size)
until 256MiB is part of heap.
</p>
<p>On arm-uboot stack is 256KiB and heap is 2MiB.
</p>
<p>In short:
</p>
<table>
<thead><tr><th width="15%">Platform</th><th width="25%">Stack</th><th width="50%">Heap</th></tr></thead>
<tr><td width="15%">emu</td><td width="25%">8 MiB</td><td width="50%">?</td></tr>
<tr><td width="15%">i386-pc</td><td width="25%">60 KiB</td><td width="50%">&lt; 4 GiB</td></tr>
<tr><td width="15%">i386-coreboot</td><td width="25%">60 KiB</td><td width="50%">&lt; 4 GiB</td></tr>
<tr><td width="15%">i386-multiboot</td><td width="25%">60 KiB</td><td width="50%">&lt; 4 GiB</td></tr>
<tr><td width="15%">i386-qemu</td><td width="25%">60 KiB</td><td width="50%">&lt; 4 GiB</td></tr>
<tr><td width="15%">*-efi</td><td width="25%">?</td><td width="50%">&lt; 1.6 GiB</td></tr>
<tr><td width="15%">i386-ieee1275</td><td width="25%">?</td><td width="50%">&lt; 32 MiB</td></tr>
<tr><td width="15%">powerpc-ieee1275</td><td width="25%">?</td><td width="50%">available memory - 128MiB</td></tr>
<tr><td width="15%">sparc64-ieee1275</td><td width="25%">256KiB</td><td width="50%">2 MiB</td></tr>
<tr><td width="15%">arm-uboot</td><td width="25%">256KiB</td><td width="50%">2 MiB</td></tr>
<tr><td width="15%">mips(el)-qemu_mips</td><td width="25%">2MiB</td><td width="50%">253 MiB</td></tr>
<tr><td width="15%">mipsel-loongson</td><td width="25%">2MiB</td><td width="50%">253 MiB</td></tr>
<tr><td width="15%">mips-arc</td><td width="25%">2MiB</td><td width="50%">125 MiB</td></tr>
<tr><td width="15%">mipsel-arc</td><td width="25%">2MiB</td><td width="50%">248 MiB</td></tr>
<tr><td width="15%">x86_64-xen (GCC &gt;= 4.4)</td><td width="25%">4MiB</td><td width="50%">unlimited</td></tr>
<tr><td width="15%">x86_64-xen (GCC &lt; 4.4)</td><td width="25%">4MiB</td><td width="50%">&lt; 2GiB</td></tr>
<tr><td width="15%">i386-xen</td><td width="25%">4MiB</td><td width="50%">&lt; 4GiB</td></tr>
</table>


<hr>
<span id="BIOS-port-memory-map"></span><div class="header">
<p>
Next: <a href="#Video-Subsystem" accesskey="n" rel="next">Video Subsystem</a>, Previous: <a href="#Stack-and-heap-size" accesskey="p" rel="prev">Stack and heap size</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="BIOS-port-memory-map-1"></span><h2 class="chapter">9 BIOS port memory map</h2>

<table>
<thead><tr><th width="15%">Start</th><th width="25%">End</th><th width="50%">Usage</th></tr></thead>
<tr><td width="15%">0</td><td width="25%">0x1000 - 1</td><td width="50%">BIOS and real mode interrupts</td></tr>
<tr><td width="15%">0x07BE</td><td width="25%">0x07FF</td><td width="50%">Partition table passed to another boot loader</td></tr>
<tr><td width="15%">?</td><td width="25%">0x2000 - 1</td><td width="50%">Real mode stack</td></tr>
<tr><td width="15%">0x7C00</td><td width="25%">0x7D00 - 1</td><td width="50%">Boot sector</td></tr>
<tr><td width="15%">0x8000</td><td width="25%">?</td><td width="50%">GRUB kernel</td></tr>
<tr><td width="15%">0x68000</td><td width="25%">0x71000 - 1</td><td width="50%">Disk buffer</td></tr>
<tr><td width="15%">?</td><td width="25%">0x80000 - 1</td><td width="50%">Protected mode stack</td></tr>
<tr><td width="15%">?</td><td width="25%">0xA0000 - 1</td><td width="50%">Extended BIOS Data Area</td></tr>
<tr><td width="15%">0xA0000</td><td width="25%">0xC0000 - 1</td><td width="50%">Video RAM</td></tr>
<tr><td width="15%">0xC0000</td><td width="25%">0x100000 - 1</td><td width="50%">BIOS</td></tr>
<tr><td width="15%">0x100000</td><td width="25%">?</td><td width="50%">Heap and module code</td></tr>
</table>

<hr>
<span id="Video-Subsystem"></span><div class="header">
<p>
Next: <a href="#PFF2-Font-File-Format" accesskey="n" rel="next">PFF2 Font File Format</a>, Previous: <a href="#BIOS-port-memory-map" accesskey="p" rel="prev">BIOS port memory map</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Video-Subsystem-1"></span><h2 class="chapter">10 Video Subsystem</h2>
<p>This document contains specification for Video Subsystem for GRUB2.
Currently only the usage interface is described in this document.
Internal structure of how video drivers are registering and how video
driver manager works are not included here.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Video-API" accesskey="1">Video API</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Example-usage-of-Video-API" accesskey="2">Example usage of Video API</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Bitmap-API" accesskey="3">Bitmap API</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<span id="Video-API"></span><div class="header">
<p>
Next: <a href="#Example-usage-of-Video-API" accesskey="n" rel="next">Example usage of Video API</a>, Up: <a href="#Video-Subsystem" accesskey="u" rel="up">Video Subsystem</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Video-API-1"></span><h3 class="section">10.1 Video API</h3>

<span id="grub_005fvideo_005fsetup"></span><h4 class="subsection">10.1.1 grub_video_setup</h4>

<ul>
<li> Prototype:
<div class="example">
<pre class="example">grub_err_t
grub_video_setup (unsigned int width, unsigned int height, unsigned int mode_type);
</pre></div>
</li><li> Description:

<p>Driver will use information provided to it to select best possible video mode and switch to it. Supported values for <code>mode_type</code> are <code>GRUB_VIDEO_MODE_TYPE_INDEX_COLOR</code> for index color modes, <code>GRUB_VIDEO_MODE_TYPE_RGB</code> for direct RGB color modes and <code>GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED</code> for double buffering. When requesting RGB mode, highest bits per pixel mode will be selected. When requesting Index color mode, mode with highest number of colors will be selected. If all parameters are specified as zero, video adapter will try to figure out best possible mode and initialize it, platform specific differences are allowed here. If there is no mode matching request, error X will be returned. If there are no problems, function returns <code>GRUB_ERR_NONE</code>.
</p>
<p>This function also performs following task upon succesful mode switch. Active rendering target is changed to screen and viewport is maximized to allow whole screen to be used when performing graphics operations. In RGB modes, emulated palette gets 16 entries containing default values for VGA palette, other colors are defined as black. When switching to Indexed Color mode, driver may set default VGA palette to screen if the video card allows the operation.
</p>
</li></ul>

<span id="grub_005fvideo_005frestore"></span><h4 class="subsection">10.1.2 grub_video_restore</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_restore (void);
</pre></div>
</li><li> Description:

<p>Video subsystem will deinitialize activated video driver to restore old state of video device. This can be used to switch back to text mode.
</p></li></ul>

<span id="grub_005fvideo_005fget_005finfo"></span><h4 class="subsection">10.1.3 grub_video_get_info</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_get_info (struct grub_video_mode_info *mode_info);
</pre></div>
<div class="example">
<pre class="example">struct grub_video_mode_info
{
  /* Width of the screen.  */
  unsigned int width;
  /* Height of the screen.  */
  unsigned int height;
  /* Mode type bitmask.  Contains information like is it Index color or
     RGB mode.  */
  unsigned int mode_type;
  /* Bits per pixel.  */
  unsigned int bpp;
  /* Bytes per pixel.  */
  unsigned int bytes_per_pixel;
  /* Pitch of one scanline.  How many bytes there are for scanline.  */
  unsigned int pitch;
  /* In index color mode, number of colors.  In RGB mode this is 256.  */
  unsigned int number_of_colors;
  /* Optimization hint how binary data is coded.  */
  enum grub_video_blit_format blit_format;
  /* How many bits are reserved for red color.  */
  unsigned int red_mask_size;
  /* What is location of red color bits.  In Index Color mode, this is 0.  */
  unsigned int red_field_pos;
  /* How many bits are reserved for green color.  */
  unsigned int green_mask_size;
  /* What is location of green color bits.  In Index Color mode, this is 0.  */
  unsigned int green_field_pos;
  /* How many bits are reserved for blue color.  */
  unsigned int blue_mask_size;
  /* What is location of blue color bits.  In Index Color mode, this is 0.  */
  unsigned int blue_field_pos;
  /* How many bits are reserved in color.  */
  unsigned int reserved_mask_size;
  /* What is location of reserved color bits.  In Index Color mode,
     this is 0.  */
  unsigned int reserved_field_pos;
};
</pre></div>
</li><li> Description:

<p>Software developer can use this function to query properties of active rendering taget. Information provided here can be used by other parts of GRUB, like image loaders to convert loaded images to correct screen format to allow more optimized blitters to be used. If there there is no configured video driver with active screen, error <code>GRUB_ERR_BAD_DEVICE</code> is returned, otherwise <code>mode_info</code> is filled with valid information and <code>GRUB_ERR_NONE</code> is returned.
</p></li></ul>

<span id="grub_005fvideo_005fget_005fblit_005fformat"></span><h4 class="subsection">10.1.4 grub_video_get_blit_format</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">enum grub_video_blit_format
grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
</pre></div>
<div class="example">
<pre class="example">enum grub_video_blit_format
  {
    /* Follow exactly field &amp; mask information.  */
    GRUB_VIDEO_BLIT_FORMAT_RGBA,
    /* Make optimization assumption.  */
    GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8,
    /* Follow exactly field &amp; mask information.  */
    GRUB_VIDEO_BLIT_FORMAT_RGB,
    /* Make optimization assumption.  */
    GRUB_VIDEO_BLIT_FORMAT_R8G8B8,
    /* When needed, decode color or just use value as is.  */
    GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR
  };
</pre></div>
</li><li> Description:

<p>Used to query how data could be optimized to suit specified video mode. Returns exact video format type, or a generic one if there is no definition for the type. For generic formats, use <code>grub_video_get_info</code> to query video color coding settings.
</p></li></ul>

<span id="grub_005fvideo_005fset_005fpalette"></span><h4 class="subsection">10.1.5 grub_video_set_palette</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_set_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data);
</pre></div>
<div class="example">
<pre class="example">struct grub_video_palette_data
{
    grub_uint8_t r; /* Red color value (0-255). */
    grub_uint8_t g; /* Green color value (0-255). */
    grub_uint8_t b; /* Blue color value (0-255). */
    grub_uint8_t a; /* Reserved bits value (0-255). */
};
</pre></div>
</li><li> Description:

<p>Used to setup indexed color palettes. If mode is RGB mode, colors will be set to emulated palette data. In Indexed Color modes, palettes will be set to hardware. Color values will be converted to suit requirements of the video mode. <code>start</code> will tell what hardware color index (or emulated color index) will be set to according information in first indice of <code>palette_data</code>, after that both hardware color index and <code>palette_data</code> index will be incremented until <code>count</code> number of colors have been set.
</p></li></ul>

<span id="grub_005fvideo_005fget_005fpalette"></span><h4 class="subsection">10.1.6 grub_video_get_palette</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_get_palette (unsigned int start, unsigned int count, struct grub_video_palette_data *palette_data);
</pre></div>
<div class="example">
<pre class="example">struct grub_video_palette_data
{
    grub_uint8_t r; /* Red color value (0-255). */
    grub_uint8_t g; /* Green color value (0-255). */
    grub_uint8_t b; /* Blue color value (0-255). */
    grub_uint8_t a; /* Reserved bits value (0-255). */
};
</pre></div>
</li><li> Description:

<p>Used to query indexed color palettes. If mode is RGB mode, colors will be copied from emulated palette data. In Indexed Color modes, palettes will be read from hardware. Color values will be converted to suit structure format. <code>start</code> will tell what hardware color index (or emulated color index) will be used as a source for first indice of <code>palette_data</code>, after that both hardware color index and <code>palette_data</code> index will be incremented until <code>count</code> number of colors have been read.
</p></li></ul>

<span id="grub_005fvideo_005fset_005farea_005fstatus"></span><h4 class="subsection">10.1.7 grub_video_set_area_status</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">grub_err_t
grub_video_set_area_status (grub_video_area_status_t area_status);
</pre></div>
<div class="example">
<pre class="example">enum grub_video_area_status_t
  {
    GRUB_VIDEO_AREA_DISABLED,
    GRUB_VIDEO_AREA_ENABLED
  };
</pre></div>

</li><li> Description:

<p>Used to set area drawing mode for redrawing the specified region. Draw commands
are performed in the intersection of the viewport and the region called area.
Coordinates remain related to the viewport. If draw commands try to draw over
the area, they are clipped.
Set status to DISABLED if you need to draw everything.
Set status to ENABLED and region to the desired rectangle to redraw everything
inside the region leaving everything else intact.
Should be used for redrawing of active elements.
</p></li></ul>

<span id="grub_005fvideo_005fget_005farea_005fstatus"></span><h4 class="subsection">10.1.8 grub_video_get_area_status</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">grub_err_r
grub_video_get_area_status (grub_video_area_status_t *area_status);
</pre></div>

</li><li> Description:
Used to query the area status.
</li></ul>

<span id="grub_005fvideo_005fset_005fviewport"></span><h4 class="subsection">10.1.9 grub_video_set_viewport</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_set_viewport (unsigned int x, unsigned int y, unsigned int width, unsigned int height);
</pre></div>
</li><li> Description:

<p>Used to specify viewport where draw commands are performed. When viewport is set, all draw commands coordinates relate to those specified by <code>x</code> and <code>y</code>. If draw commands try to draw over viewport, they are clipped. If developer requests larger than possible viewport, width and height will be clamped to fit screen. If <code>x</code> and <code>y</code> are out of bounds, all functions drawing to screen will not be displayed. In order to maximize viewport, use <code>grub_video_get_info</code> to query actual screen dimensions and provide that information to this function.
</p></li></ul>

<span id="grub_005fvideo_005fget_005fviewport"></span><h4 class="subsection">10.1.10 grub_video_get_viewport</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_get_viewport (unsigned int *x, unsigned int *y, unsigned int *width, unsigned int *height);
</pre></div>
</li><li> Description:

<p>Used to query current viewport dimensions. Software developer can use this to choose best way to render contents of the viewport.
</p></li></ul>

<span id="grub_005fvideo_005fset_005fregion"></span><h4 class="subsection">10.1.11 grub_video_set_region</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_set_region (unsigned int x, unsigned int y, unsigned int width, unsigned int height);
</pre></div>
</li><li> Description:

<p>Used to specify the region of the screen which should be redrawn. Use absolute
values. When the region is set and area status is ENABLE all draw commands will
be performed inside the interseption of region and viewport named area.
If draw commands try to draw over viewport, they are clipped. If developer
requests larger than possible region, width and height will be clamped to fit
screen. Should be used for redrawing of active elements.
</p></li></ul>

<span id="grub_005fvideo_005fget_005fregion"></span><h4 class="subsection">10.1.12 grub_video_get_region</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_get_region (unsigned int *x, unsigned int *y, unsigned int *width, unsigned int *height);
</pre></div>
</li><li> Description:

<p>Used to query current region dimensions.
</p></li></ul>

<span id="grub_005fvideo_005fmap_005fcolor"></span><h4 class="subsection">10.1.13 grub_video_map_color</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_video_color_t
grub_video_map_color (grub_uint32_t color_name);
</pre></div>
</li><li> Description:

<p>Map color can be used to support color themes in GRUB. There will be collection of color names that can be used to query actual screen mapped color data. Examples could be <code>GRUB_COLOR_CONSOLE_BACKGROUND</code>, <code>GRUB_COLOR_CONSOLE_TEXT</code>. The actual color defines are not specified at this point.
</p></li></ul>

<span id="grub_005fvideo_005fmap_005frgb"></span><h4 class="subsection">10.1.14 grub_video_map_rgb</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_video_color_t
grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue);
</pre></div>
</li><li> Description:

<p>Map RGB values to compatible screen color data. Values are expected to be in range 0-255 and in RGB modes they will be converted to screen color data. In index color modes, index color palette will be searched for specified color and then index is returned.
</p></li></ul>

<span id="grub_005fvideo_005fmap_005frgba"></span><h4 class="subsection">10.1.15 grub_video_map_rgba</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_video_color_t
grub_video_map_rgba (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue, grub_uint8_t alpha);
</pre></div>
</li><li> Description:

<p>Map RGBA values to compatible screen color data. Values are expected to be in range 0-255. In RGBA modes they will be converted to screen color data. In index color modes, index color palette will be searched for best matching color and its index is returned.
</p></li></ul>

<span id="grub_005fvideo_005funmap_005fcolor"></span><h4 class="subsection">10.1.16 grub_video_unmap_color</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_unmap_color (grub_video_color_t color, grub_uint8_t *red, grub_uint8_t *green, grub_uint8_t *blue, grub_uint8_t *alpha);
</pre></div>
</li><li> Description:

<p>Unmap color value from <code>color</code> to color channels in <code>red</code>, <code>green</code>, <code>blue</code> and <code>alpha</code>. Values will be in range 0-255. Active rendering target will be used for color domain. In case alpha information is not available in rendering target, it is assumed to be opaque (having value 255).
</p></li></ul>

<span id="grub_005fvideo_005ffill_005frect"></span><h4 class="subsection">10.1.17 grub_video_fill_rect</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_fill_rect (grub_video_color_t color, int x, int y, unsigned int width, unsigned int height);
</pre></div>
</li><li> Description:

<p>Fill specified area limited by given coordinates within specified viewport. Negative coordinates are accepted in order to allow easy moving of rectangle within viewport. If coordinates are negative, area of the rectangle will be shrinken to follow size limits of the viewport.
</p>
<p>Software developer should use either <code>grub_video_map_color</code>, <code>grub_video_map_rgb</code> or <code>grub_video_map_rgba</code> to map requested color to <code>color</code> parameter.
</p></li></ul>

<span id="grub_005fvideo_005fblit_005fglyph"></span><h4 class="subsection">10.1.18 grub_video_blit_glyph</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_blit_glyph (struct grub_font_glyph *glyph, grub_video_color_t color, int x, int y);
</pre></div>
<div class="example">
<pre class="example">struct grub_font_glyph {
    /* TBD. */
};
</pre></div>
</li><li> Description:

<p>Used to blit glyph to viewport in specified coodinates. If glyph is at edge of viewport, pixels outside of viewport will be clipped out. Software developer should use either <code>grub_video_map_rgb</code> or <code>grub_video_map_rgba</code> to map requested color to <code>color</code> parameter.
</p></li></ul>

<span id="grub_005fvideo_005fblit_005fbitmap"></span><h4 class="subsection">10.1.19 grub_video_blit_bitmap</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_blit_bitmap (struct grub_video_bitmap *bitmap, enum grub_video_blit_operators oper, int x, int y, int offset_x, int offset_y, unsigned int width, unsigned int height);
</pre></div>
<div class="example">
<pre class="example">struct grub_video_bitmap
{
    /* TBD. */
};

enum grub_video_blit_operators
  {
    GRUB_VIDEO_BLIT_REPLACE,
    GRUB_VIDEO_BLIT_BLEND
  };
</pre></div>
</li><li> Description:

<p>Used to blit bitmap to viewport in specified coordinates. If part of bitmap is outside of viewport region, it will be clipped out. Offsets affect bitmap position where data will be copied from. Negative values for both viewport coordinates and bitmap offset coordinates are allowed. If data is looked out of bounds of bitmap, color value will be assumed to be transparent. If viewport coordinates are negative, area of the blitted rectangle will be shrinken to follow size limits of the viewport and bitmap. Blitting operator <code>oper</code> specifies should source pixel replace data in screen or blend with pixel alpha value.
</p>
<p>Software developer should use <code>grub_video_bitmap_create</code> or <code>grub_video_bitmap_load</code> to create or load bitmap data.
</p></li></ul>

<span id="grub_005fvideo_005fblit_005frender_005ftarget"></span><h4 class="subsection">10.1.20 grub_video_blit_render_target</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_blit_render_target (struct grub_video_render_target *source, enum grub_video_blit_operators oper, int x, int y, int offset_x, int offset_y, unsigned int width, unsigned int height);
</pre></div>
<div class="example">
<pre class="example">struct grub_video_render_target {
    /* This is private data for video driver. Should not be accessed from elsewhere directly.  */
};

enum grub_video_blit_operators
  {
    GRUB_VIDEO_BLIT_REPLACE,
    GRUB_VIDEO_BLIT_BLEND
  };
</pre></div>
</li><li> Description:

<p>Used to blit source render target to viewport in specified coordinates. If part of source render target is outside of viewport region, it will be clipped out. If blitting operator is specified and source contains alpha values, resulting pixel color components will be calculated using formula ((src_color * src_alpha) + (dst_color * (255 - src_alpha)) / 255, if target buffer has alpha, it will be set to src_alpha. Offsets affect render target position where data will be copied from. If data is looked out of bounds of render target, color value will be assumed to be transparent. Blitting operator <code>oper</code> specifies should source pixel replace data in screen or blend with pixel alpha value.
</p></li></ul>

<span id="grub_005fvideo_005fscroll"></span><h4 class="subsection">10.1.21 grub_video_scroll</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_scroll (grub_video_color_t color, int dx, int dy);
</pre></div>
</li><li> Description:

<p>Used to scroll viewport to specified direction. New areas are filled with specified color. This function is used when screen is scroller up in video terminal.
</p></li></ul>

<span id="grub_005fvideo_005fswap_005fbuffers"></span><h4 class="subsection">10.1.22 grub_video_swap_buffers</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_swap_buffers (void);
</pre></div>
</li><li> Description:

<p>If double buffering is enabled, this swaps frontbuffer and backbuffer, in order to show values drawn to back buffer. Video driver is free to choose how this operation is techincally done.
</p></li></ul>

<span id="grub_005fvideo_005fcreate_005frender_005ftarget"></span><h4 class="subsection">10.1.23 grub_video_create_render_target</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_create_render_target (struct grub_video_render_target **result, unsigned int width, unsigned int height, unsigned int mode_type);
</pre></div>
<div class="example">
<pre class="example">struct grub_video_render_target {
    /* This is private data for video driver. Should not be accessed from elsewhere directly.  */
};
</pre></div>
</li><li> Description:

<p>Driver will use information provided to it to create best fitting render target. <code>mode_type</code> will be used to guide on selecting what features are wanted for render target. Supported values for <code>mode_type</code> are <code>GRUB_VIDEO_MODE_TYPE_INDEX_COLOR</code> for index color modes, <code>GRUB_VIDEO_MODE_TYPE_RGB</code> for direct RGB color modes and <code>GRUB_VIDEO_MODE_TYPE_ALPHA</code> for alpha component.
</p></li></ul>

<span id="grub_005fvideo_005fdelete_005frender_005ftarget"></span><h4 class="subsection">10.1.24 grub_video_delete_render_target</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_delete_render_target (struct grub_video_render_target *target);
</pre></div>
</li><li> Description:

<p>Used to delete previously created render target. If <code>target</code> contains <code>NULL</code> pointer, nothing will be done. If render target is correctly destroyed, GRUB_ERR_NONE is returned.
</p></li></ul>

<span id="grub_005fvideo_005fset_005factive_005frender_005ftarget"></span><h4 class="subsection">10.1.25 grub_video_set_active_render_target</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_set_active_render_target (struct grub_video_render_target *target);
</pre></div>
</li><li> Description:

<p>Sets active render target. If this comand is successful all drawing commands will be done to specified <code>target</code>. There is also special values for target, <code>GRUB_VIDEO_RENDER_TARGET_DISPLAY</code> used to reference screen&rsquo;s front buffer, <code>GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER</code> used to reference screen&rsquo;s front buffer (alias for <code>GRUB_VIDEO_RENDER_TARGET_DISPLAY</code>) and <code>GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER</code> used to reference back buffer (if double buffering is enabled). If render target is correclty switched GRUB_ERR_NONE is returned. In no any event shall there be non drawable active render target.
</p>
</li></ul>
<span id="grub_005fvideo_005fget_005factive_005frender_005ftarget"></span><h4 class="subsection">10.1.26 grub_video_get_active_render_target</h4>
<ul>
<li> Prototype:

<div class="example">
<pre class="example">grub_err_t
grub_video_get_active_render_target (struct grub_video_render_target **target);
</pre></div>
</li><li> Description:

<p>Returns currently active render target. It returns value in <code>target</code> that can be subsequently issued back to <code>grub_video_set_active_render_target</code>.
</p></li></ul>

<hr>
<span id="Example-usage-of-Video-API"></span><div class="header">
<p>
Next: <a href="#Bitmap-API" accesskey="n" rel="next">Bitmap API</a>, Previous: <a href="#Video-API" accesskey="p" rel="prev">Video API</a>, Up: <a href="#Video-Subsystem" accesskey="u" rel="up">Video Subsystem</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Example-usage-of-Video-API-1"></span><h3 class="section">10.2 Example usage of Video API</h3>
<span id="Example-of-screen-setup"></span><h4 class="subsection">10.2.1 Example of screen setup</h4>
<div class="example">
<pre class="example">grub_err_t rc;
/* Try to initialize video mode 1024 x 768 with direct RGB.  */
rc = grub_video_setup (1024, 768, GRUB_VIDEO_MODE_TYPE_RGB);
if (rc != GRUB_ERR_NONE)
{
  /* Fall back to standard VGA Index Color mode.  */
  rc = grub_video_setup (640, 480, GRUB_VIDEO_MODE_TYPE_INDEX);
  if (rc != GRUB_ERR_NONE)
  {
  /* Handle error.  */
  }
}
</pre></div>
<span id="Example-of-setting-up-console-viewport"></span><h4 class="subsection">10.2.2 Example of setting up console viewport</h4>
<div class="example">
<pre class="example">grub_uint32_t x, y, width, height;
grub_video_color_t color;
struct grub_font_glyph glyph;
grub_err_t rc;
/* Query existing viewport.  */
grub_video_get_viewport (&amp;x, &amp;y, &amp;width, &amp;height);
/* Fill background.  */
color = grub_video_map_color (GRUB_COLOR_BACKGROUND);
grub_video_fill_rect (color, 0, 0, width, height);
/* Setup console viewport.  */
grub_video_set_viewport (x + 10, y + 10, width - 20, height - 20);
grub_video_get_viewport (&amp;x, &amp;y, &amp;width, &amp;height);
color = grub_video_map_color (GRUB_COLOR_CONSOLE_BACKGROUND);
grub_video_fill_rect (color, 0, 0, width, height);
/* Draw text to viewport.  */
color = grub_video_map_color (GRUB_COLOR_CONSOLE_TEXT);
grub_font_get_glyph ('X', &amp;glyph);
grub_video_blit_glyph (&amp;glyph, color, 0, 0);
</pre></div>

<hr>
<span id="Bitmap-API"></span><div class="header">
<p>
Previous: <a href="#Example-usage-of-Video-API" accesskey="p" rel="prev">Example usage of Video API</a>, Up: <a href="#Video-Subsystem" accesskey="u" rel="up">Video Subsystem</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Bitmap-API-1"></span><h3 class="section">10.3 Bitmap API</h3>
<span id="grub_005fvideo_005fbitmap_005fcreate"></span><h4 class="subsection">10.3.1 grub_video_bitmap_create</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">grub_err_t grub_video_bitmap_create (struct grub_video_bitmap **bitmap, unsigned int width, unsigned int height, enum grub_video_blit_format blit_format)
</pre></div>

</li><li> Description:

<p>Creates a new bitmap with given dimensions and blitting format. Allocated bitmap data can then be modified freely and finally blitted with <code>grub_video_blit_bitmap</code> to rendering target.
</p></li></ul>

<span id="grub_005fvideo_005fbitmap_005fdestroy"></span><h4 class="subsection">10.3.2 grub_video_bitmap_destroy</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">grub_err_t grub_video_bitmap_destroy (struct grub_video_bitmap *bitmap);
</pre></div>

</li><li> Description:

<p>When bitmap is no longer needed, it can be freed from memory using this command. <code>bitmap</code> is previously allocated bitmap with <code>grub_video_bitmap_create</code> or loaded with <code>grub_video_bitmap_load</code>.
</p></li></ul>

<span id="grub_005fvideo_005fbitmap_005fload"></span><h4 class="subsection">10.3.3 grub_video_bitmap_load</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">grub_err_t grub_video_bitmap_load (struct grub_video_bitmap **bitmap, const char *filename);
</pre></div>

</li><li> Description:

<p>Tries to load given bitmap (<code>filename</code>) using registered bitmap loaders. In case bitmap format is not recognized or supported error <code>GRUB_ERR_BAD_FILE_TYPE</code> is returned.
</p></li></ul>

<span id="grub_005fvideo_005fbitmap_005fget_005fwidth"></span><h4 class="subsection">10.3.4 grub_video_bitmap_get_width</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">unsigned int grub_video_bitmap_get_width (struct grub_video_bitmap *bitmap);
</pre></div>

</li><li> Description:

<p>Returns bitmap width.
</p></li></ul>

<span id="grub_005fvideo_005fbitmap_005fget_005fheight"></span><h4 class="subsection">10.3.5 grub_video_bitmap_get_height</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">unsigned int grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap);
</pre></div>

</li><li> Description:

<p>Return bitmap height.
</p></li></ul>

<span id="grub_005fvideo_005fbitmap_005fget_005fmode_005finfo"></span><h4 class="subsection">10.3.6 grub_video_bitmap_get_mode_info</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap, struct grub_video_mode_info *mode_info);
</pre></div>

</li><li> Description:

<p>Returns bitmap format details in form of <code>grub_video_mode_info</code>.
</p></li></ul>

<span id="grub_005fvideo_005fbitmap_005fget_005fdata"></span><h4 class="subsection">10.3.7 grub_video_bitmap_get_data</h4>
<ul>
<li> Prototype:
<div class="example">
<pre class="example">void *grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap);
</pre></div>

</li><li> Description:

<p>Return pointer to bitmap data. Contents of the pointed data can be freely modified. There is no extra protection against going off the bounds so you have to be carefull how to access the data.
</p></li></ul>

<hr>
<span id="PFF2-Font-File-Format"></span><div class="header">
<p>
Next: <a href="#Graphical-Menu-Software-Design" accesskey="n" rel="next">Graphical Menu Software Design</a>, Previous: <a href="#Video-Subsystem" accesskey="p" rel="prev">Video Subsystem</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="PFF2-Font-File-Format-1"></span><h2 class="chapter">11 PFF2 Font File Format</h2>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Introduction" accesskey="1">Introduction</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#File-Structure" accesskey="2">File Structure</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Font-Metrics" accesskey="3">Font Metrics</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>


<hr>
<span id="Introduction"></span><div class="header">
<p>
Next: <a href="#File-Structure" accesskey="n" rel="next">File Structure</a>, Up: <a href="#PFF2-Font-File-Format" accesskey="u" rel="up">PFF2 Font File Format</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Introduction-1"></span><h3 class="section">11.1 Introduction</h3>

<p>The goal of this format is to provide a bitmap font format that is simple to
use, compact, and cleanly supports Unicode.
</p>

<span id="Goals-of-the-GRUB-Font-Format"></span><h4 class="subsection">11.1.1 Goals of the GRUB Font Format</h4>

<ul>
<li> Simple to read and use.
Since GRUB will only be reading the font files,
we are more concerned with making the code to read the font simple than we
are with writing the font.

</li><li> Compact storage.
The fonts will generally be stored in a small boot
partition where GRUB is located, and this may be on a removable storage
device such as a CD or USB flash drive where space is more limited than it
is on most hard drives.

</li><li> Unicode.
GRUB should not have to deal with multiple character
encodings.  The font should always use Unicode character codes for simple
internationalization.
</li></ul>

<span id="Why-Another-Font-Format_003f"></span><h4 class="subsection">11.1.2 Why Another Font Format?</h4>

<p>There are many existing bitmap font formats that GRUB could use.  However,
there are aspects of these formats that may make them less than suitable for
use in GRUB at this time:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>BDF</samp>&rsquo;</dt>
<dd><p>Inefficient storage; uses ASCII to describe properties and 
hexadecimal numbers in ASCII for the bitmap rows.
</p></dd>
<dt>&lsquo;<samp>PCF</samp>&rsquo;</dt>
<dd><p>Many format variations such as byte order and bitmap padding (rows
padded to byte, word, etc.) would result in more complex code to
handle the font format.
</p></dd>
</dl>

<hr>
<span id="File-Structure"></span><div class="header">
<p>
Next: <a href="#Font-Metrics" accesskey="n" rel="next">Font Metrics</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#PFF2-Font-File-Format" accesskey="u" rel="up">PFF2 Font File Format</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="File-Structure-1"></span><h3 class="section">11.2 File Structure</h3>

<p>A file <strong>section</strong> consists of a 4-byte name, a 32-bit big-endian length (not
including the name or length), and then <var>length</var> more section-type-specific 
bytes.
</p>
<p>The standard file extension for PFF2 font files is <samp>.pf2</samp>.
</p>

<span id="Section-Types"></span><h4 class="subsection">11.2.1 Section Types</h4>

<dl compact="compact">
<dt>&lsquo;<samp>FILE</samp>&rsquo;</dt>
<dd><p><strong>File type ID</strong> (ASCII string).  This must be the first section in the file.  It has length 4
and the contents are the four bytes of the ASCII string &lsquo;<samp>PFF2</samp>&rsquo;.
</p>
</dd>
<dt>&lsquo;<samp>NAME</samp>&rsquo;</dt>
<dd><p><strong>Font name</strong> (ASCII string).  This is the full font name including family,
weight, style, and point size.  For instance, &quot;Helvetica Bold Italic 14&quot;.
</p>
</dd>
<dt>&lsquo;<samp>FAMI</samp>&rsquo;</dt>
<dd><p><strong>Font family name</strong> (ASCII string).  For instance, &quot;Helvetica&quot;.  This should
be included so that intelligent font substitution can take place.
</p>
</dd>
<dt>&lsquo;<samp>WEIG</samp>&rsquo;</dt>
<dd><p><strong>Font weight</strong> (ASCII string).  Valid values are &lsquo;<samp>bold</samp>&rsquo; and &lsquo;<samp>normal</samp>&rsquo;.
This should be included so that intelligent font substitution can take
place.
</p>
</dd>
<dt>&lsquo;<samp>SLAN</samp>&rsquo;</dt>
<dd><p><strong>Font slant</strong> (ASCII string).  Valid values are &lsquo;<samp>italic</samp>&rsquo; and &lsquo;<samp>normal</samp>&rsquo;.
This should be included so that intelligent font substitution can take
place.
</p>
</dd>
<dt>&lsquo;<samp>PTSZ</samp>&rsquo;</dt>
<dd><p><strong>Font point size</strong> (uint16be).
</p>
</dd>
<dt>&lsquo;<samp>MAXW</samp>&rsquo;</dt>
<dd><p><strong>Maximum character width in pixels</strong> (uint16be).
</p>
</dd>
<dt>&lsquo;<samp>MAXH</samp>&rsquo;</dt>
<dd><p><strong>Maximum character height in pixels</strong> (uint16be).
</p>
</dd>
<dt>&lsquo;<samp>ASCE</samp>&rsquo;</dt>
<dd><p><strong>Ascent in pixels</strong> (uint16be).  See <a href="#Font-Metrics">Font Metrics</a>, for details.
</p>
</dd>
<dt>&lsquo;<samp>DESC</samp>&rsquo;</dt>
<dd><p><strong>Descent in pixels</strong> (uint16be).  See <a href="#Font-Metrics">Font Metrics</a>, for details.
</p>
</dd>
<dt>&lsquo;<samp>CHIX</samp>&rsquo;</dt>
<dd><p><strong>Character index.</strong>
The character index begins with a 32-bit big-endian unsigned integer
indicating the total size of the section, not including this size value.
For each character, there is an instance of the following entry structure:
</p>
<ul>
<li> <strong>Unicode code point.</strong> (32-bit big-endian integer.)

</li><li> <strong>Storage flags.</strong> (byte.)
       
<ul>
<li> Bits 2..0: 

<p>If equal to 000 binary, then the character data is stored
uncompressed beginning at the offset indicated by the character&rsquo;s
<strong>offset</strong> value.
</p>
<p>If equal to 001 binary, then the character data is stored within a 
compressed character definition block that begins at the offset 
within the file indicated by the character&rsquo;s <strong>offset</strong> value.
</p></li></ul>

</li><li> <strong>Offset.</strong> (32-bit big-endian integer.)

<p>A marker that indicates the remainder of the file is data accessed via
the character index (CHIX) section.  When reading this font file, the rest
of the file can be ignored when scanning the sections.  The length should
be set to -1 (0xFFFFFFFF).
</p>
<p>Supported data structures:
</p>
<p>Character definition
Each character definition consists of:
</p>
<ul>
<li> <strong>Width.</strong>
Width of the bitmap in pixels.  The bitmap&rsquo;s extents 
represent the glyph&rsquo;s bounding box.  <code>uint16be</code>.

</li><li> <strong>Height.</strong>
Height of the bitmap in pixels.  The bitmap&rsquo;s extents
represent the glyph&rsquo;s bounding box.  <code>uint16be</code>.

</li><li> <strong>X offset.</strong>
The number of pixels to shift the bitmap by
horizontally before drawing the character. <code>int16be</code>.

</li><li> <strong>Y offset.</strong>
The number of pixels to shift the bitmap by
vertically before drawing the character. <code>int16be</code>.

</li><li> <strong>Device width.</strong>
The number of pixels to advance horizontally from
this character&rsquo;s origin to the origin of the next character.
<code>int16be</code>.

</li><li> <strong>Bitmap data.</strong>
This is encoded as a string of bits.  It is
organized as a row-major, top-down, left-to-right bitmap.  The most
significant bit of each byte is taken to be the leftmost or uppermost
bit in the byte.  For the sake of compact storage, rows are not padded
to byte boundaries (i.e., a single byte may contain bits belonging to
multiple rows).  The last byte of the bitmap <strong>is</strong> padded with zero
bits in the bits positions to the right of the last used bit if the
bitmap data does not fill the last byte.  
         
<p>The length of the <strong>bitmap data</strong> field is (<var>width</var> * <var>height</var> + 7) / 8
using integer arithmetic, which is equivalent to ceil(<var>width</var> *
<var>height</var> / 8) using real number arithmetic.
</p>
<p>It remains to be determined whether bitmap fonts usually make all
glyph bitmaps the same height, or if smaller glyphs are stored with
bitmaps having a lesser height.  In the latter case, the baseline
would have to be used to calculate the location the bitmap should be
anchored at on screen.
</p></li></ul>

</li></ul>
</dd>
</dl>

<hr>
<span id="Font-Metrics"></span><div class="header">
<p>
Previous: <a href="#File-Structure" accesskey="p" rel="prev">File Structure</a>, Up: <a href="#PFF2-Font-File-Format" accesskey="u" rel="up">PFF2 Font File Format</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Font-Metrics-1"></span><h3 class="section">11.3 Font Metrics</h3>

<ul>
<li> Ascent.
The distance from the baseline to the top of most characters.
Note that in some cases characters may extend above the ascent.

</li><li> Descent.
The distance from the baseline to the bottom of most characters.  Note that
in some cases characters may extend below the descent.
 
</li><li> Leading.
The amount of space, in pixels, to leave between the descent of one line of
text and the ascent of the next line.  This metrics is not specified in the
current file format; instead, the font rendering engine calculates a
reasonable leading value based on the other font metrics.

</li><li> Horizonal leading.
The amount of space, in pixels, to leave horizontally between the left and
right edges of two adjacent glyphs.  The <strong>device width</strong> field determines
the effective leading value that is used to render the font.

</li></ul>
<img src="font_char_metrics.png" alt="font_char_metrics">
   
<p>An illustration of how the various font metrics apply to characters.
</p>


<hr>
<span id="Graphical-Menu-Software-Design"></span><div class="header">
<p>
Next: <a href="#Verifiers-framework" accesskey="n" rel="next">Verifiers framework</a>, Previous: <a href="#PFF2-Font-File-Format" accesskey="p" rel="prev">PFF2 Font File Format</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Graphical-Menu-Software-Design-1"></span><h2 class="chapter">12 Graphical Menu Software Design</h2>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#Introduction_005f2" accesskey="1">Introduction_2</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Startup-Sequence" accesskey="2">Startup Sequence</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#GUI-Components" accesskey="3">GUI Components</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="#Command-Line-Window" accesskey="4">Command Line Window</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<span id="Introduction_005f2"></span><div class="header">
<p>
Next: <a href="#Startup-Sequence" accesskey="n" rel="next">Startup Sequence</a>, Up: <a href="#Graphical-Menu-Software-Design" accesskey="u" rel="up">Graphical Menu Software Design</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Introduction-2"></span><h3 class="section">12.1 Introduction</h3>

<p>The &lsquo;<samp>gfxmenu</samp>&rsquo; module provides a graphical menu interface for GRUB 2.  It
functions as an alternative to the menu interface provided by the &lsquo;<samp>normal</samp>&rsquo;
module, which uses the grub terminal interface to display a menu on a
character-oriented terminal.
</p>
<p>The graphical menu uses the GRUB video API, which is currently for the VESA
BIOS extensions (VBE) 2.0+.  This is supported on the i386-pc platform.
However, the graphical menu itself does not depend on using VBE, so if another
GRUB video driver were implemented, the &lsquo;<samp>gfxmenu</samp>&rsquo; graphical menu would work
on the new video driver as well.
</p>

<hr>
<span id="Startup-Sequence"></span><div class="header">
<p>
Next: <a href="#GUI-Components" accesskey="n" rel="next">GUI Components</a>, Previous: <a href="#Introduction_005f2" accesskey="p" rel="prev">Introduction_2</a>, Up: <a href="#Graphical-Menu-Software-Design" accesskey="u" rel="up">Graphical Menu Software Design</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Startup-Sequence-1"></span><h3 class="section">12.2 Startup Sequence</h3>

<ul>
<li> grub_enter_normal_mode [normal/main.c]
</li><li> grub_normal_execute [normal/main.c]
</li><li> read_config_file [normal/main.c]
</li><li> (When <samp>gfxmenu.mod</samp> is loaded with <code>insmod</code>, it will call <code>grub_menu_viewer_register()</code> to register itself.)
</li><li> GRUB_MOD_INIT (gfxmenu) [gfxmenu/gfxmenu.c]
</li><li> grub_menu_viewer_register [kern/menu_viewer.c]
</li><li> grub_menu_viewer_show_menu [kern/menu_viewer.c]
</li><li> get_current_menu_viewer() [kern/menu_viewer.c]
</li><li> show_menu() [gfxmenu/gfxmenu.c]
</li><li> grub_gfxmenu_model_new [gfxmenu/model.c]
</li><li> grub_gfxmenu_view_new [gfxmenu/view.c]
</li><li> set_graphics_mode [gfxmenu/view.c]
</li><li> grub_gfxmenu_view_load_theme [gfxmenu/theme_loader.c]
</li></ul>


<hr>
<span id="GUI-Components"></span><div class="header">
<p>
Next: <a href="#Command-Line-Window" accesskey="n" rel="next">Command Line Window</a>, Previous: <a href="#Startup-Sequence" accesskey="p" rel="prev">Startup Sequence</a>, Up: <a href="#Graphical-Menu-Software-Design" accesskey="u" rel="up">Graphical Menu Software Design</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="GUI-Components-1"></span><h3 class="section">12.3 GUI Components</h3>

<p>The graphical menu implements a GUI component system that supports a
container-based layout system.  Components can be added to containers, and
containers (which are a type of component) can then be added to other
containers, to form a tree of components.  Currently, the root component of
this tree is a &lsquo;<samp>canvas</samp>&rsquo; component, which allows manual layout of its child
components.
</p>
<p>Components (non-container):
</p>
<ul>
<li> label
</li><li> image
</li><li> progress_bar
</li><li> circular_progress
</li><li> list (currently hard coded to be a boot menu list)
</li></ul>

<p>Containers:
</p>
<ul>
<li> canvas
</li><li> hbox
</li><li> vbox
</li></ul>

<p>The GUI component instances are created by the theme loader in
<samp>gfxmenu/theme_loader.c</samp> when a theme is loaded.  Theme files specify
statements such as &lsquo;<samp>+vbox{ +label { text=&quot;Hello&quot; } +label{ text=&quot;World&quot; } }</samp>&rsquo;
to add components to the component tree root.  By nesting the component
creation statements in the theme file, the instantiated components are nested
the same way.
</p>
<p>When a component is added to a container, that new child is considered <strong>owned</strong>
by the container.  Great care should be taken if the caller retains a
reference to the child component, since it will be destroyed if its parent
container is destroyed.  A better choice instead of storing a pointer to the
child component is to use the component ID to find the desired component.
Component IDs do not have to be unique (it is often useful to have multiple
components with an ID of &quot;__timeout__&quot;, for instance).
</p>
<p>In order to access and use components in the component tree, there are two
functions (defined in <samp>gfxmenu/gui_util.c</samp>) that are particularly useful:
</p>
<ul>
<li> <code>grub_gui_find_by_id (root, id, callback, userdata)</code>:

<p>This function ecursively traverses the component tree rooted at <var>root</var>, and
for every component that has an ID equal to <var>id</var>, calls the function pointed
to by <var>callback</var> with the matching component and the void pointer <var>userdata</var>
as arguments.  The callback function can do whatever is desired to use the
component passed in.
</p>
</li><li> <code>grub_gui_iterate_recursively (root, callback, userdata)</code>:

<p>This function calls the function pointed to by <var>callback</var> for every
component that is a descendant of <var>root</var> in the component tree.  When the
callback function is called, the component and the void pointer <var>userdata</var>
as arguments.  The callback function can do whatever is desired to use the
component passed in.
</p></li></ul>

<hr>
<span id="Command-Line-Window"></span><div class="header">
<p>
Previous: <a href="#GUI-Components" accesskey="p" rel="prev">GUI Components</a>, Up: <a href="#Graphical-Menu-Software-Design" accesskey="u" rel="up">Graphical Menu Software Design</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Command-Line-Window-1"></span><h3 class="section">12.4 Command Line Window</h3>

<p>The terminal window used to provide command line access within the graphical
menu is managed by <samp>gfxmenu/view.c</samp>.  The &lsquo;<samp>gfxterm</samp>&rsquo; terminal is used, and
it has been modified to allow rendering to an offscreen render target to allow
it to be composed into the double buffering system that the graphical menu
view uses.  This is bad for performance, however, so it would probably be a
good idea to make it possible to temporarily disable double buffering as long
as the terminal window is visible.  There are still unresolved problems that
occur when commands are executed from the terminal window that change the
graphics mode.  It&rsquo;s possible that making <code>grub_video_restore()</code> return to
the graphics mode that was in use before <code>grub_video_setup()</code> was called
might fix some of the problems.
</p>

<hr>
<span id="Verifiers-framework"></span><div class="header">
<p>
Next: <a href="#Lockdown-framework" accesskey="n" rel="next">Lockdown framework</a>, Previous: <a href="#Graphical-Menu-Software-Design" accesskey="p" rel="prev">Graphical Menu Software Design</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Verifiers-framework-1"></span><h2 class="chapter">13 Verifiers framework</h2>

<p>To register your own verifier call &lsquo;<samp>grub_verifier_register</samp>&rsquo; with a structure
pointing to your functions.
</p>
<p>The interface is inspired by the hash interface with &lsquo;<samp>init</samp>&rsquo;/&lsquo;<samp>write</samp>&rsquo;/&lsquo;<samp>fini</samp>&rsquo;.
</p>
<p>There are essentially 2 ways of using it, hashing and whole-file verification.
</p>
<p>With the hashing approach:
During &lsquo;<samp>init</samp>&rsquo; you decide whether you want to check the given file and init context.
In &lsquo;<samp>write</samp>&rsquo; you update your hashing state.
In &lsquo;<samp>fini</samp>&rsquo; you check that the hash matches the expected value/passes some check/...
</p>
<p>With whole-file verification:
During &lsquo;<samp>init</samp>&rsquo; you decide whether you want to check the given file and init context.
In &lsquo;<samp>write</samp>&rsquo; you verify the file and return an error if it fails.
You don&rsquo;t have &lsquo;<samp>fini</samp>&rsquo;.
</p>
<p>Additional &lsquo;<samp>verify_string</samp>&rsquo; receives various strings like kernel parameters
to verify. Returning no error means successful verification and an error stops
the current action.
</p>
<p>Detailed description of the API:
</p>
<p>Every time a file is opened your &lsquo;<samp>init</samp>&rsquo; function is called with file descriptor
and file type. Your function can have the following outcomes:
</p>
<ul>
<li> returning no error and setting &lsquo;<samp>*flags</samp>&rsquo; to &lsquo;<samp>GRUB_VERIFY_FLAGS_DEFER_AUTH</samp>&rsquo;.
In this case verification is deferred to other active verifiers. Verification
fails if nobody cares or selected verifier fails.

</li><li> returning no error and setting &lsquo;<samp>*flags</samp>&rsquo; to &lsquo;<samp>GRUB_VERIFY_FLAGS_SKIP_VERIFICATION</samp>&rsquo;.
In this case your verifier will not be called anymore and it is assumed to have
skipped verification.

</li><li> returning no error and not setting &lsquo;<samp>*flags</samp>&rsquo; to &lsquo;<samp>GRUB_VERIFY_FLAGS_SKIP_VERIFICATION</samp>&rsquo;
In this case verification is done as described in the following section.

</li><li> returning an error. Then opening of the file will fail due to failed verification.

</li></ul>

<p>In the third case your &lsquo;<samp>write</samp>&rsquo; will be called with chunks of the file. If
you need the whole file in a single chunk then during &lsquo;<samp>init</samp>&rsquo; set the bit
&lsquo;<samp>GRUB_VERIFY_FLAGS_SINGLE_CHUNK</samp>&rsquo; in &lsquo;<samp>*flags</samp>&rsquo;. During &lsquo;<samp>init</samp>&rsquo; you
may set &lsquo;<samp>*context</samp>&rsquo; if you need additional context. At every iteration you
may return an error and the file will be considered as having failed the
verification. If you return no error then verification continues.
</p>
<p>Optionally at the end of the file &lsquo;<samp>fini</samp>&rsquo;, if it exists, is called with just
the context. If you return no error during any of &lsquo;<samp>init</samp>&rsquo;, &lsquo;<samp>write</samp>&rsquo; and
&lsquo;<samp>fini</samp>&rsquo; then the file is considered as having succeded verification.
</p>
<hr>
<span id="Lockdown-framework"></span><div class="header">
<p>
Next: <a href="#Copying-This-Manual" accesskey="n" rel="next">Copying This Manual</a>, Previous: <a href="#Verifiers-framework" accesskey="p" rel="prev">Verifiers framework</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Lockdown-framework-1"></span><h2 class="chapter">14 Lockdown framework</h2>

<p>The GRUB can be locked down, which is a restricted mode where some operations
are not allowed. For instance, some commands cannot be used when the GRUB is
locked down.
</p>
<p>The function
<code>grub_lockdown()</code> is used to lockdown GRUB and the function
<code>grub_is_lockdown()</code> function can be used to check whether lockdown is
enabled or not. When enabled, the function returns &lsquo;<samp>GRUB_LOCKDOWN_ENABLED</samp>&rsquo;
and &lsquo;<samp>GRUB_LOCKDOWN_DISABLED</samp>&rsquo; when is not enabled.
</p>
<p>The following functions can be used to register the commands that can only be
used when lockdown is disabled:
</p>
<ul>
<li> <code>grub_cmd_lockdown()</code> registers command which should not run when the
GRUB is in lockdown mode.

</li><li> <code>grub_cmd_lockdown()</code> registers extended command which should not run
when the GRUB is in lockdown mode.

</li></ul>

<hr>
<span id="Copying-This-Manual"></span><div class="header">
<p>
Next: <a href="#Index" accesskey="n" rel="next">Index</a>, Previous: <a href="#Lockdown-framework" accesskey="p" rel="prev">Lockdown framework</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Copying-This-Manual-1"></span><h2 class="appendix">Appendix A Copying This Manual</h2>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="#GNU-Free-Documentation-License" accesskey="1">GNU Free Documentation License</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">License for copying this manual.
</td></tr>
</table>


<hr>
<span id="GNU-Free-Documentation-License"></span><div class="header">
<p>
Up: <a href="#Copying-This-Manual" accesskey="u" rel="up">Copying This Manual</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="GNU-Free-Documentation-License-1"></span><h3 class="appendixsec">A.1 GNU Free Documentation License</h3>

<span id="index-FDL_002c-GNU-Free-Documentation-License"></span>
<div align="center">Version 1.2, November 2002
</div>
<div class="display">
<pre class="display">Copyright &copy; 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
</pre></div>

<ol start="0">
<li> PREAMBLE

<p>The purpose of this License is to make a manual, textbook, or other
functional and useful document <em>free</em> in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
</p>
<p>This License is a kind of &ldquo;copyleft&rdquo;, which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.
</p>
<p>We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.
</p>
</li><li> APPLICABILITY AND DEFINITIONS

<p>This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The &ldquo;Document&rdquo;, below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as &ldquo;you&rdquo;.  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
</p>
<p>A &ldquo;Modified Version&rdquo; of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
</p>
<p>A &ldquo;Secondary Section&rdquo; is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document&rsquo;s overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject.  (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
</p>
<p>The &ldquo;Invariant Sections&rdquo; are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.
</p>
<p>The &ldquo;Cover Texts&rdquo; are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
</p>
<p>A &ldquo;Transparent&rdquo; copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not &ldquo;Transparent&rdquo; is called &ldquo;Opaque&rdquo;.
</p>
<p>Examples of suitable formats for Transparent copies include plain
<small>ASCII</small> without markup, Texinfo input format, LaTeX input
format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly available
<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
PostScript or <acronym>PDF</acronym> designed for human modification.  Examples
of transparent image formats include <acronym>PNG</acronym>, <acronym>XCF</acronym> and
<acronym>JPG</acronym>.  Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, <acronym>SGML</acronym> or
<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing tools are
not generally available, and the machine-generated <acronym>HTML</acronym>,
PostScript or <acronym>PDF</acronym> produced by some word processors for
output purposes only.
</p>
<p>The &ldquo;Title Page&rdquo; means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, &ldquo;Title Page&rdquo; means
the text near the most prominent appearance of the work&rsquo;s title,
preceding the beginning of the body of the text.
</p>
<p>A section &ldquo;Entitled XYZ&rdquo; means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as &ldquo;Acknowledgements&rdquo;,
&ldquo;Dedications&rdquo;, &ldquo;Endorsements&rdquo;, or &ldquo;History&rdquo;.)  To &ldquo;Preserve the Title&rdquo;
of such a section when you modify the Document means that it remains a
section &ldquo;Entitled XYZ&rdquo; according to this definition.
</p>
<p>The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
</p>
</li><li> VERBATIM COPYING

<p>You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.
</p>
<p>You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
</p>
</li><li> COPYING IN QUANTITY

<p>If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document&rsquo;s license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
</p>
<p>If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
</p>
<p>If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
</p>
<p>It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
</p>
</li><li> MODIFICATIONS

<p>You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:
</p>
<ol type="A" start="1">
<li> Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document).  You may use the same title as a previous version
if the original publisher of that version gives permission.

</li><li> List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.

</li><li> State on the Title page the name of the publisher of the
Modified Version, as the publisher.

</li><li> Preserve all the copyright notices of the Document.

</li><li> Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.

</li><li> Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.

</li><li> Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document&rsquo;s license notice.

</li><li> Include an unaltered copy of this License.

</li><li> Preserve the section Entitled &ldquo;History&rdquo;, Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page.  If
there is no section Entitled &ldquo;History&rdquo; in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.

</li><li> Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on.  These may be placed in the &ldquo;History&rdquo; section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.

</li><li> For any section Entitled &ldquo;Acknowledgements&rdquo; or &ldquo;Dedications&rdquo;, Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.

</li><li> Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles.  Section numbers
or the equivalent are not considered part of the section titles.

</li><li> Delete any section Entitled &ldquo;Endorsements&rdquo;.  Such a section
may not be included in the Modified Version.

</li><li> Do not retitle any existing section to be Entitled &ldquo;Endorsements&rdquo; or
to conflict in title with any Invariant Section.

</li><li> Preserve any Warranty Disclaimers.
</li></ol>

<p>If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version&rsquo;s license notice.
These titles must be distinct from any other section titles.
</p>
<p>You may add a section Entitled &ldquo;Endorsements&rdquo;, provided it contains
nothing but endorsements of your Modified Version by various
parties&mdash;for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
</p>
<p>You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
</p>
<p>The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
</p>
</li><li> COMBINING DOCUMENTS

<p>You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
</p>
<p>The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
</p>
<p>In the combination, you must combine any sections Entitled &ldquo;History&rdquo;
in the various original documents, forming one section Entitled
&ldquo;History&rdquo;; likewise combine any sections Entitled &ldquo;Acknowledgements&rdquo;,
and any sections Entitled &ldquo;Dedications&rdquo;.  You must delete all
sections Entitled &ldquo;Endorsements.&rdquo;
</p>
</li><li> COLLECTIONS OF DOCUMENTS

<p>You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
</p>
<p>You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
</p>
</li><li> AGGREGATION WITH INDEPENDENT WORKS

<p>A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an &ldquo;aggregate&rdquo; if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation&rsquo;s users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
</p>
<p>If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document&rsquo;s Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
</p>
</li><li> TRANSLATION

<p>Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
</p>
<p>If a section in the Document is Entitled &ldquo;Acknowledgements&rdquo;,
&ldquo;Dedications&rdquo;, or &ldquo;History&rdquo;, the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
</p>
</li><li> TERMINATION

<p>You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License.  Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License.  However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
</p>
</li><li> FUTURE REVISIONS OF THIS LICENSE

<p>The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time.  Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.  See
<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
</p>
<p>Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License &ldquo;or any later version&rdquo; applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
</p></li></ol>

<span id="ADDENDUM_003a-How-to-use-this-License-for-your-documents"></span><h4 class="appendixsubsec">A.1.1 ADDENDUM: How to use this License for your documents</h4>

<p>To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
</p>
<div class="example">
<pre class="example">  Copyright (C)  <var>year</var>  <var>your name</var>.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.2
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.
</pre></div>

<p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the &ldquo;with...Texts.&rdquo; line with this:
</p>
<div class="example">
<pre class="example">    with the Invariant Sections being <var>list their titles</var>, with
    the Front-Cover Texts being <var>list</var>, and with the Back-Cover Texts
    being <var>list</var>.
</pre></div>

<p>If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
</p>
<p>If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
</p>



<hr>
<span id="Index"></span><div class="header">
<p>
Previous: <a href="#Copying-This-Manual" accesskey="p" rel="prev">Copying This Manual</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Index" title="Index" rel="index">Index</a>]</p>
</div>
<span id="Index-1"></span><h2 class="unnumbered">Index</h2>

<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Index_cp_letter-F"><b>F</b></a>
 &nbsp; 
</td></tr></table>
<table class="index-cp" border="0">
<tr><td></td><th align="left">Index Entry</th><td>&nbsp;</td><th align="left"> Section</th></tr>
<tr><td colspan="4"> <hr></td></tr>
<tr><th id="Index_cp_letter-F">F</th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#index-FDL_002c-GNU-Free-Documentation-License">FDL, GNU Free Documentation License</a>:</td><td>&nbsp;</td><td valign="top"><a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a></td></tr>
<tr><td colspan="4"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a class="summary-letter" href="#Index_cp_letter-F"><b>F</b></a>
 &nbsp; 
</td></tr></table>

<hr>



</body>
</html>

Zerion Mini Shell 1.0