[BACK]Return to gba.html CVS log [TXT][DIR] Up to [local] / prex-old / doc / html / doc

File: [local] / prex-old / doc / html / doc / gba.html (download) (as text)

Revision 1.1, Tue Jun 3 09:38:42 2008 UTC (15 years, 11 months ago) by nbrk
Branch point for: MAIN

Initial revision

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Prex/Game Boy Advance - Documentation</title>
  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  <meta name="keywords" content="Prex, embedded, real-time, operating system, RTOS, open source, free">
  <meta name="author" content="Kohsuke Ohtani">
  <link rel="stylesheet" type="text/css" href="../default.css" media="screen">
  <link rel="stylesheet" type="text/css" href="../print.css" media="print">
</head>
<body>
<div id="top">
</div>
<div id="middle">

<table id="content" cellpadding="0" cellspacing="0">
  <tbody>

    <tr>
      <td id="header" colspan="2" valign="top">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td id="logo">
            <a href="http://prex.sourceforge.net/">
            <img alt="Prex logo" src="../img/logo.gif" border="0"
            style="width: 281px; height: 56px;"></a>
          </td>
          <td id="brief" align="right" valign="bottom">
            An Open Source, Royalty-free,<br>
	    Real-time Operating System
          </td>
        </tr>
        </table>
      </td>
    </tr>

    <tr>
      <td id="directory" style="vertical-align: top;">
      <a href="http://prex.sourceforge.net/">Prex Home</a> >
      <a href="index.html">Document Index</a> >
      Game Boy Advance
    </tr>
    <tr><td class="pad" colspan="2" style="vertical-align: top;"></td></tr>

    <tr>
      <td id="main" style="vertical-align: top;">
      <h1>Prex/Game Boy Advance - Documentation</h1>

<i>Version 0.2 (draft), 2005/06/29</i><br>

<h3>Table of Contents</h3>

<b>HOWTO</b>
<ul>
  <li><a href="#gba">How to run Prex on the Game Boy Advance?</a></li>
  <li><a href="#vba">How to run Prex with VisualBoy Advance?</a></li>
  <li><a href="#build">How to compile Prex for Game Boy Advance?</a></li>
  <li><a href="#kbd">How to use On-screen Keyboard?</a></li>
</ul>

<b>Technical Note</b>
<ul>
  <li><a href="#mem">Memory Map</a></li>
  <li><a href="#syscall">System Call</a></li>
</ul>
<br>


<h2 id="gba">How to run Prex on the Game Boy Advance?</h2>
<p>
There exist some hardware to run Prex on the Game Boy Advance.
Currently, I am using "Boot Cable USB" which is sold by
<a href="http://optimize.ath.cx/shopv2_2/chuumon.html">Optimize</a>.
And, its control software is available for download from this
<a href="http://optimize.ath.cx/bootcable/btusb.html">page</a>.

Unfortunately, these are only japanese page... :-(

<br>
You may find other useful information to run your program on GBA at 
<a href="http://www.gbadev.org">http://www.gbadev.org</a>.
</p>
<i><b>Figure 1. Boot Cable USB</b></i><br>
<img alt="USB Boot Cable" src="img/usbcable.jpg" border="1"
style="width: 256px; height: 192px;"><br>


<h2 id="vba">How to run Prex with the VisualBoy Advance?</h2>
<p>
VBA - VisualBoy Advance is most popular GBA emulator. You can find the 
latest release at 
<a href="http://vba.ngemu.com">http://www.vba.ngemu.com</a>.
To run Prex with VBA, simply select file->open and open the prex image.
There is no need to prepare the original GBA BIOS.
</p>
<p>
The default keyboard setting of VBA is as follow:
</p>

<i><b>Table 1. VBA Key Assign</b></i>
<table width="80%" border="1" cellspacing="0">
<tbody>
<tr>
  <th width="150">PC Key</th>
  <th>GBA Button</th>
</tr>

  <tr>
    <td>Cursor Keys</td>
    <td>Up, Down, Left, Right</td>
  </tr>
  <tr>
    <td>Z</td>
    <td>Button A</td>
  </tr>
  <tr>
    <td>X</td>
    <td>Button B</td>
  </tr>
  <tr>
    <td>A</td>
    <td>Button L</td>
  </tr>
  <tr>
    <td>S</td>
    <td>Button R</td>
  </tr>
  <tr>
    <td>Enter</td>
    <td>Start</td>
  </tr>
  <tr>
    <td>Backspace</td>
    <td>Select</td>
  </tr>

</tbody>
</table>


<h2 id="build">How to compile Prex for Game Boy Advance?</h2>

At first, you have to prepare the toolchain for cross compiling ARM code.
And then, the shell variables must be set for the arm-gba target.

<h4>Step 1. Unpack Archives</h4>
You have to download and unpack the following files.

<pre class="terminal">$ cd /usr/src
$ tar zxvf binitils-2.15.tar.gz
$ tar zxvf gcc-core-3.4.3.tar.gz
$ tar zxvf newlib-1.13.0.tar.gz</pre>

<h4>Step 2. Build Binutils</h4>

<p>
Configure and build binutils.
</p>
<pre class="terminal">$ mkdir binutils-2.15-arm-elf
$ cd binutils-2.15-arm-elf
$ ../binutils-2.15/configure --prefix=/usr/local/arm --target=arm-elf --disable-nls \
 --with-cpu=arm7tdmi
$ make
$ make install</pre>
<p>
You must set the path to this binutils.
</p>
<pre class="terminal">$ export PATH=/usr/local/arm/bin:$PATH
$ cd /usr/src</pre>


<h4>Step 3. Build gcc</h4>

<pre class="terminal">$ mkdir gcc-3.4.3-arm-elf
$ cd gcc-3.4.3-arm-elf
$ ../gcc-3.4.3/configure --prefix=/usr/local/arm --target=arm-elf --with-gnu-as \
 --with-gnu-ld --with-cpu=arm7tdmi --disable-nls --enable-languages=c --with-newlib \
 --enable-interwork --with-headers=../newlib-1.13.0/newlib/libc/include/
$ make LANGUAGES="c"
$ make LANGUAGES="c" install
$ cd /usr/src</pre>

<h4>Setp 4. Configure</h4>
Setup target architecture and platform.
<pre class="terminal">$ export PREX_ARCH=arm
$ export PREX_PLATFORM=gba
$ export PREX_SRC=/usr/src/prex-X.X.X
</pre>

<h4>Step 5. Make</h4>
Run make.<br>
<pre class="terminal">
$ make
</pre>

<p>
Note: There is a cross-compiling kit for GBA named 
<a href="http://devkitadv.sourceforge.net">DevKit Advance</a>.
It may be usable for compiling Prex.
</p>

<h2 id="kbd">How to use On-Screen Keyboard?</h2>

<i><b>Figure 2. On-Screen Keyboard</b></i><br>
<img alt="On-Screen Keyboard" src="img/gbakbd.png" border="1"
style="width: 254px; height: 94px;"><br>
<p>
The driver for on-screen keyboard is provided to emulate a generic keyboard
by using the GBA keypad. You can input any key by moving the cursor on the 
on-screen keyboard. The user can show/hide the on-screen keyboard on the
GBA screen by pressing select button. The key assign is different
for each case.
</p>

<i><b>Table 2. Key for On-screen Keyboard</b></i>
<table width="80%" border="1" cellspacing="0">
<tbody>
<tr>
  <th width="150">GBA Key</th>
  <th>Function</th>
</tr>

  <tr>
    <td>A</td>
    <td>Input current pointed key</td>
  </tr>
  <tr>
    <td>B</td>
    <td>"Enter" key</td>
  </tr>
  <tr>
    <td>Select</td>
    <td>Hide on-screen keyboard</td>
  </tr>
  <tr>
    <td>Start</td>
    <td>N/A</td>
  </tr>
  <tr>
    <td>Right</td>
    <td>Move keyboard cursor right</td>
  </tr>
  <tr>
    <td>Left</td>
    <td>Move keyboard cursor left</td>
  </tr>
  <tr>
    <td>Up</td>
    <td>Move keyboard cursor up</td>
  </tr>
  <tr>
    <td>Down</td>
    <td>Move keyboard cursor down</td>
  </tr>
  <tr>
    <td>R</td>
    <td>Toggle shift state</td>
  </tr>
  <tr>
    <td>L</td>
    <td>Toggle shift state</td>
  </tr>

</tbody>
</table>

<br>
<i><b>Table 3. Default Key (No On-screen Keyboard)</b></i>
<table width="80%" border="1" cellspacing="0">
<tbody>
<tr>
  <th width="150">GBA Key</th>
  <th>Function</th>
</tr>

  <tr>
    <td>A</td>
    <td>"A" key</td>
  </tr>
  <tr>
    <td>B</td>
    <td>"B" key</td>
  </tr>
  <tr>
    <td>Select</td>
    <td>Show on-screen keyboard</td>
  </tr>
  <tr>
    <td>Start</td>
    <td>"Enter" key</td>
  </tr>
  <tr>
    <td>Right</td>
    <td>Cursor "Right" key</td>
  </tr>
  <tr>
    <td>Left</td>
    <td>Cursor "Left" key</td>
  </tr>
  <tr>
    <td>Up</td>
    <td>Cursor "Up" key</td>
  </tr>
  <tr>
    <td>Down</td>
    <td>Cursor "Down" key</td>
  </tr>
  <tr>
    <td>R</td>
    <td>"R" key</td>
  </tr>
  <tr>
    <td>L</td>
    <td>"L" key</td>
  </tr>

</tbody>
</table>


<h2 id="mem">Memory Map</h2>

<h3>General Memory Usage</h3>
<ul>
 <li>00000000 - 00003FFF  BIOS - System ROM
 <li>02000000 - 0203FFFF  EWRAM (256K)
 <li>03000000 - 03007FFF  EWRAM (32K)
 <li>04000000 - 040003FF  I/O Registers
 <li>05000000 - 040003FF  Palette RAM
 <li>06000000 - 06017fFF  VRAM
 <li>07000000 - 070003FF  Object Attributes
</ul>

<h3>VRAM Usage</h3>
<ul>
 <li>06000000 - 06003FFF  Tile 1 - Font</li>
 <li>06004000 - 06005FFF  Tile 2 - Keyboard Image (non shift)</li>
 <li>06006000 - 06007FFF  Tile 2 - Keyboard Image (shift)</li>
 <li>06008000 - 06008FFF  Background 3 Map (Console text)</li>
 <li>06009000 - 06009FFF  Background 1 Map (Keyboard non-shift)</li>
 <li>0600A000 - 0600AFFF  Background 2 Map (Keyboard shift)</li>
 <li>0600B000 - 0600FFFF  Not used
 <li>06010000 - 0601FFFF  Cursor Data
</ul>


<h2 id="syscall">System Call</h2>
<p>
Since the GBA BIOS does not allow to handle the SWI event by
the program, we need some trick to handle the system call.
The system call will be handled by the following steps.
<ul>
 <li>The application invoke the system call.</li>
 <li>The system call stub in the library will jump to the SWI exception
 vector (0x0202007C) in the kernel code.</li>
</ul>
<pre>
#define SYSCALL0(name) \
        .global name; .align; \
name##: \
        stmfd   sp!, {r4, r5, lr}; \
        mov     r4, #SYS_##name; \
        ldr     r5, =0x202007c; \
        add     lr, pc, #2; \
        mov     pc, r5; \
        ldmfd   sp!, {r4, r5, pc};
</pre>
<ul>
 <li>The kernel SWI handler will switch the processor mode to SVC mode.</li>
</ul>
<pre>
ENTRY(syscall_entry)
        mov     r5, lr
        mrs     ip, cpsr
        bic     ip, ip, #PSR_MODE
        orr     ip, ip, #PSR_SVC_MODE
        msr     cpsr_c, ip
        mov     lr, r5
</pre>
Since a program can not change the ARM processor mode during the USR mode,
all applications are always executed in SYS mode in Prex arm-gba port.

      </td>
    </tr>
    <tr>
      <td id="footer" colspan="2" style="vertical-align: top;">
        <a href="http://sourceforge.net">
        <img src="http://sourceforge.net/sflogo.php?group_id=132028&amp;type=1"
        alt="SourceForge.net Logo" border="0" height="31" width="88"></a><br>
        Copyright&copy; 2005-2007 Kohsuke Ohtani
      </td>
    </tr>

  </tbody>
</table>

</div>
<div id="bottom"></div>

</body>
</html>