mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-29 05:39:47 +08:00
committed by
Gedare Bloom
parent
32c2cd2be1
commit
c8a8a6013f
@@ -12,8 +12,6 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
|
||||
AC_CONFIG_SUBDIRS([csb337]);;
|
||||
edb7312 )
|
||||
AC_CONFIG_SUBDIRS([edb7312]);;
|
||||
gba )
|
||||
AC_CONFIG_SUBDIRS([gba]);;
|
||||
gdbarmsim )
|
||||
AC_CONFIG_SUBDIRS([gdbarmsim]);;
|
||||
gp32 )
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
ACLOCAL_AMFLAGS = -I ../../../../aclocal
|
||||
|
||||
include $(top_srcdir)/../../../../automake/compile.am
|
||||
|
||||
include_bspdir = $(includedir)/bsp
|
||||
|
||||
dist_project_lib_DATA = bsp_specs
|
||||
|
||||
include_HEADERS = include/bsp.h
|
||||
include_HEADERS += include/arm_mode_bits.h
|
||||
include_HEADERS += include/asm_macros.h
|
||||
include_HEADERS += include/gba_registers.h
|
||||
include_HEADERS += include/conio.h
|
||||
include_HEADERS += ../../shared/include/tm27.h
|
||||
include_HEADERS += include/gba.h
|
||||
|
||||
include_bsp_HEADERS =
|
||||
|
||||
nodist_include_HEADERS = include/bspopts.h
|
||||
nodist_include_HEADERS += ../../shared/include/coverhd.h
|
||||
nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
|
||||
DISTCLEANFILES = include/bspopts.h
|
||||
noinst_PROGRAMS =
|
||||
|
||||
noinst_LIBRARIES = libbspstart.a
|
||||
libbspstart_a_SOURCES = start/start.S
|
||||
project_lib_DATA = start.$(OBJEXT)
|
||||
|
||||
dist_project_lib_DATA += startup/linkcmds
|
||||
|
||||
noinst_LIBRARIES += libbsp.a
|
||||
libbsp_a_SOURCES =
|
||||
|
||||
# startup
|
||||
libbsp_a_SOURCES += ../../shared/bsplibc.c ../../shared/bsppost.c \
|
||||
startup/bspgetworkarea.c \
|
||||
../../shared/bsppredriverhook.c ../../shared/bspclean.c \
|
||||
startup/bspreset.c ../../shared/bootcard.c ../../shared/sbrk.c \
|
||||
../../shared/gnatinstallhandler.c \
|
||||
startup/bspstart.c
|
||||
libbsp_a_SOURCES += ../../shared/cpucounterread.c
|
||||
libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
|
||||
# clock
|
||||
libbsp_a_SOURCES += clock/clockdrv.c
|
||||
libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
|
||||
# console
|
||||
libbsp_a_SOURCES += console/conio.c console/console.c \
|
||||
console/defaultfont.h
|
||||
# timer
|
||||
libbsp_a_SOURCES += timer/timer.c
|
||||
|
||||
# irq
|
||||
include_bsp_HEADERS += ../../shared/include/irq-generic.h \
|
||||
../../shared/include/irq-info.h \
|
||||
irq/irq.h
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-generic.c
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-info.c
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-server.c
|
||||
libbsp_a_SOURCES += ../../shared/src/irq-shell.c
|
||||
libbsp_a_SOURCES += irq/irq.c
|
||||
|
||||
# Cache
|
||||
libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
|
||||
libbsp_a_SOURCES += ../../shared/include/cache_.h
|
||||
libbsp_a_CPPFLAGS = -I$(srcdir)/../../shared/include
|
||||
|
||||
include $(srcdir)/preinstall.am
|
||||
include $(top_srcdir)/../../../../automake/local.am
|
||||
@@ -1,3 +0,0 @@
|
||||
This is the BSP for Nintendo's GBA and GBA SP. The RTEMS Wiki
|
||||
has more detailed information on this BSP.
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
%rename endfile old_endfile
|
||||
%rename startfile old_startfile
|
||||
%rename link old_link
|
||||
|
||||
*startfile:
|
||||
%{!qrtems: %(old_startfile)} \
|
||||
%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}
|
||||
|
||||
*link:
|
||||
%{!qrtems: %(old_link)} %{qrtems: -dc -dp -Bstatic -N}
|
||||
|
||||
*endfile:
|
||||
%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* @file clockdrv.c
|
||||
*
|
||||
* Game Boy Advance Clock driver.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <gba.h>
|
||||
#include <assert.h>
|
||||
|
||||
void Clock_isr(void * arg);
|
||||
void Clock_driver_support_initialize_hardware(void);
|
||||
|
||||
#define Clock_driver_support_at_tick()
|
||||
|
||||
#define Clock_driver_support_install_isr( _new, _old ) \
|
||||
do { \
|
||||
rtems_status_code status = RTEMS_SUCCESSFUL; \
|
||||
status = rtems_interrupt_handler_install( \
|
||||
BSP_IRQ_TIMER3, \
|
||||
"Clock", \
|
||||
RTEMS_INTERRUPT_UNIQUE, \
|
||||
Clock_isr, \
|
||||
NULL \
|
||||
); \
|
||||
assert(status == RTEMS_SUCCESSFUL); \
|
||||
_old = NULL; \
|
||||
} while(0)
|
||||
|
||||
#define Clock_driver_support_shutdown_hardware() \
|
||||
do { \
|
||||
rtems_status_code status = RTEMS_SUCCESSFUL; \
|
||||
status = rtems_interrupt_handler_remove( \
|
||||
BSP_IRQ_TIMER3, \
|
||||
Clock_isr, \
|
||||
NULL \
|
||||
); \
|
||||
assert(status == RTEMS_SUCCESSFUL); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* Calculate Tick Times
|
||||
* 1 / 16.78Mhz => 59.595 ns
|
||||
* 64 / 16.78Mhz => 3.814 us
|
||||
* 256 / 16.78Mhz => 15.256 us
|
||||
* 1024 / 16.78Mhz => 61.025 us
|
||||
*/
|
||||
#define __TimTickTime_us ((1000000L/__ClockFrequency)*__TimPreScaler)
|
||||
#define __TimTickTime_ns ((1000000000L/__ClockFrequency)*__TimPreScaler)
|
||||
|
||||
#if (__TimPreScaler==1)
|
||||
#define GBA_TMCNT_PS 0x0000
|
||||
#elif (__TimPreScaler==64)
|
||||
#define GBA_TMCNT_PS 0x0001
|
||||
#elif (__TimPreScaler==256)
|
||||
#define GBA_TMCNT_PS 0x0002
|
||||
#elif (__TimPreScaler==1024)
|
||||
#define GBA_TMCNT_PS 0x0003
|
||||
#else
|
||||
#define GBA_TMCNT_PS 0x0003
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This function set up the clock hardware
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void Clock_driver_support_initialize_hardware(void)
|
||||
{
|
||||
int tmreload;
|
||||
|
||||
tmreload = rtems_configuration_get_nanoseconds_per_tick() / __TimTickTime_ns;
|
||||
|
||||
if (tmreload>0xFFFF)
|
||||
tmreload = 0xFFFF;
|
||||
GBA_REG_TM3CNT = (GBA_TMCNT_PS);
|
||||
GBA_REG_TM3D = (0x0000-tmreload);
|
||||
GBA_REG_TM3CNT = (0x00c0|GBA_TMCNT_PS);
|
||||
}
|
||||
|
||||
#define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
|
||||
|
||||
#include "../../../shared/clockdrv_shell.h"
|
||||
@@ -1,23 +0,0 @@
|
||||
## Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([rtems-c-src-lib-libbsp-arm-gba],[_RTEMS_VERSION],[https://devel.rtems.org/newticket])
|
||||
AC_CONFIG_SRCDIR([bsp_specs])
|
||||
RTEMS_TOP(../../../../../..)
|
||||
|
||||
RTEMS_CANONICAL_TARGET_CPU
|
||||
AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
|
||||
RTEMS_BSP_CONFIGURE
|
||||
|
||||
RTEMS_PROG_CC_FOR_TARGET
|
||||
RTEMS_CANONICALIZE_TOOLS
|
||||
RTEMS_PROG_CCAS
|
||||
|
||||
RTEMS_CHECK_NETWORKING
|
||||
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
|
||||
|
||||
RTEMS_BSP_CLEANUP_OPTIONS(1, 1)
|
||||
|
||||
# Explicitly list all Makefiles here
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
@@ -1,450 +0,0 @@
|
||||
/**
|
||||
* @file conio.c
|
||||
*
|
||||
* This file contains the GBA conio I/O package.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
* based on MyLib by Rafael Vuijk (aka Dark Fader)
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
* This source file is based on work by Rafael Vuijk (aka Dark Fader)
|
||||
*****************************************************************************
|
||||
*****************************************************************************
|
||||
* MyLib by Rafael Vuijk (aka Dark Fader)
|
||||
* :
|
||||
* This file is released into the public domain for commercial
|
||||
* or non-commercial usage with no restrictions placed upon it.
|
||||
*****************************************************************************/
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Includes *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <rtems/score/types.h>
|
||||
#include <gba.h>
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Defines *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define W 60 /**< Screen width */
|
||||
#define H 26 /**< Screen height */
|
||||
#define CLRSCR_SIZE (W*4 * H*6) /**< Screen size */
|
||||
#define DEFAULT_FONT_WIDTH 4 /**< Font width */
|
||||
#define DEFAULT_FONT_HEIGHT 6 /**< Font height */
|
||||
|
||||
typedef unsigned short Palette[256]; /**< 256 colors */
|
||||
typedef unsigned short Palettes[16][16]; /**< 16 palettes with each 16 colors */
|
||||
typedef unsigned short Bitmap3[GBA_LCD_HEIGHT][GBA_LCD_WIDTH]; /**< 16 bits, single buffered */
|
||||
typedef unsigned char Bitmap4[GBA_LCD_HEIGHT][GBA_LCD_WIDTH]; /**< 8 bits, double buffered */
|
||||
typedef unsigned short Bitmap5[GBA_MODE5_HEIGHT][GBA_MODE5_WIDTH];/**< double buffered */
|
||||
|
||||
#define VRAM GBA_VRAM_ADDR /**< VRAM address */
|
||||
#define VRAM_END (VRAM + 0x18000) /**< VRAM end */
|
||||
#define BG_BITMAP0_VRAM (VRAM + 0x0) /**< BG Bitmap 0 RAM */
|
||||
#define BG_BITMAP1_VRAM (VRAM + 0xa000) /**< BG Bitmap 1 RAM */
|
||||
|
||||
#define bg_bitmap0 (*(Bitmap4 *)BG_BITMAP0_VRAM)
|
||||
#define bg_bitmap1 (*(Bitmap4 *)BG_BITMAP1_VRAM)
|
||||
#define bg_bitmap3 (*(Bitmap3 *)BG_BITMAP0_VRAM)
|
||||
#define bg_bitmap4a (*(Bitmap4 *)BG_BITMAP0_VRAM)
|
||||
#define bg_bitmap4b (*(Bitmap4 *)BG_BITMAP1_VRAM)
|
||||
#define bg_bitmap5a (*(Bitmap5 *)BG_BITMAP0_VRAM)
|
||||
#define bg_bitmap5b (*(Bitmap5 *)BG_BITMAP1_VRAM)
|
||||
|
||||
/** Color conversion macro */
|
||||
#define RGB(r,g,b) ( (r)<<0 | (g)<<5 | (b)<<10 )
|
||||
|
||||
/** BG Affine Transformation Destination Data Structure */
|
||||
typedef struct {
|
||||
int16_t H_DiffX; /**< Line Direction X Coordinate Difference */
|
||||
int16_t V_DiffX; /**< Vertical Direction X Coordinate Difference */
|
||||
int16_t H_DiffY; /**< Line Direction Y Coordinate Difference */
|
||||
int16_t V_DiffY; /**< Vertical Direction Y Coordinate Difference */
|
||||
int32_t StartX; /**< Start X Coordinate */
|
||||
int32_t StartY; /**< Start Y Coordinate */
|
||||
} BgAffineDestData;
|
||||
|
||||
typedef volatile BgAffineDestData vBgAffineDestData;
|
||||
#define rBg2Affine (*(vBgAffineDestData *)0x4000020)
|
||||
|
||||
/** 256 colors for background(s) */
|
||||
#define bg_palette (*(Palette *)(GBA_PAL_RAM_ADDR))
|
||||
|
||||
|
||||
int _wherex; /**< Screen X coordinate */
|
||||
int _wherey; /**< Screen Y coordinate */
|
||||
int _textattr; /**< Text attribute */
|
||||
|
||||
/*
|
||||
* Forward reference
|
||||
*/
|
||||
static void gba_initconio(void);
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Defaultfont *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include "defaultfont.h"
|
||||
|
||||
/**
|
||||
* @brief gba_gotoxy function set screeen xy-coordinates
|
||||
*
|
||||
* @param _x screen x coordinate
|
||||
* @param _y screen y coordinate
|
||||
* @return None
|
||||
*/
|
||||
void gba_gotoxy(int _x, int _y)
|
||||
{
|
||||
_wherex = _x;
|
||||
_wherey = _y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief gba_putchar function writes char-data to screen memory.
|
||||
*
|
||||
* Char code is index to font table.
|
||||
*
|
||||
* Input parameters: char, attribute and cordinates
|
||||
* @param c character code
|
||||
* @param textattr text attribute
|
||||
* @param x screen x coordinate
|
||||
* @param y screen y coordinate
|
||||
* @return None
|
||||
*/
|
||||
static void gba_putchar(char c, int textattr, int x, int y)
|
||||
{
|
||||
int f = textattr & 0x0F;
|
||||
int b = textattr >> 4;
|
||||
uint32_t fmask = f | f<<8 | f<<16 | f<<24;
|
||||
uint32_t bmask = b | b<<8 | b<<16 | b<<24;
|
||||
uint32_t *dest = (uint32_t *)&bg_bitmap4a[((y<<1) + y) << 1][x<<2];
|
||||
const uint32_t *src = (uint32_t *)&(font3x5[(int)c]);
|
||||
uint32_t s;
|
||||
|
||||
s = *src++;
|
||||
*dest = (fmask&s) | (bmask&~s);
|
||||
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
|
||||
|
||||
s = *src++;
|
||||
*dest = (fmask&s) | (bmask&~s);
|
||||
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
|
||||
|
||||
s = *src++;
|
||||
*dest = (fmask&s) | (bmask&~s);
|
||||
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
|
||||
|
||||
s = *src++;
|
||||
*dest = (fmask&s) | (bmask&~s);
|
||||
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
|
||||
|
||||
s = *src++;
|
||||
*dest = (fmask&s) | (bmask&~s);
|
||||
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
|
||||
|
||||
s = *src++;
|
||||
*dest = (fmask&s) | (bmask&~s);
|
||||
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief gba_textattr function set textattribute
|
||||
*
|
||||
* @param _attr text attribute
|
||||
* @return None
|
||||
*/
|
||||
void gba_textattr(int _attr)
|
||||
{
|
||||
_textattr = _attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_textbackground function set text background color
|
||||
*
|
||||
* @param _color backround color
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void gba_textbackground(int _color)
|
||||
{
|
||||
_textattr = (_textattr & 0x0F) | (_color << 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_textcolor function set text color
|
||||
*
|
||||
* @param _colour text color
|
||||
* @return None
|
||||
*/
|
||||
void gba_textcolor(int _color)
|
||||
{
|
||||
_textattr = (_textattr & 0xF0) | (_color);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief gba_clearline function clear line number y
|
||||
*
|
||||
* Line is filled with spaces
|
||||
*
|
||||
* @param y line number
|
||||
* @return None
|
||||
*/
|
||||
static void gba_clearline(int y)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x=0 ; x<=W ; x++) {
|
||||
gba_putchar(0, _textattr, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_nextline function moves cursor to next line and clears it
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
static void gba_nextline(void)
|
||||
{
|
||||
_wherex = 0;
|
||||
if (++_wherey >= H) {
|
||||
_wherey = 0;
|
||||
}
|
||||
gba_clearline(_wherey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_clrscr function clear screen
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void gba_clrscr(void)
|
||||
{
|
||||
int y;
|
||||
|
||||
for (y=0 ; y<=H ; y++) {
|
||||
gba_clearline(y);
|
||||
}
|
||||
gba_gotoxy(0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_put function convert ascii char to font index and
|
||||
* write char to screen memory
|
||||
*
|
||||
* @param _c character code
|
||||
* @return None
|
||||
*/
|
||||
static void gba_put(char _c)
|
||||
{
|
||||
/* We have save some memory with reduced fonts */
|
||||
_c = _c & 0x7F; /* no extened chars */
|
||||
_c = _c - 0x20; /* no cntr chars */
|
||||
gba_putchar(_c, _textattr, _wherex, _wherey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief gba_putch function write ascii chars to screen
|
||||
*
|
||||
* @param _c character code
|
||||
* @return None
|
||||
*/
|
||||
void gba_putch(char _c)
|
||||
{
|
||||
switch (_c) {
|
||||
case ASCII_LF:
|
||||
gba_nextline();
|
||||
break;
|
||||
case ASCII_CR:
|
||||
gba_gotoxy(0, _wherey);
|
||||
break;
|
||||
default:
|
||||
gba_put(_c);
|
||||
if (++_wherex >= W)
|
||||
{
|
||||
gba_nextline();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_puts function write ascii string to screen
|
||||
*
|
||||
* @param _str ASCII string
|
||||
* @return None
|
||||
*/
|
||||
void gba_puts(const char *_str)
|
||||
{
|
||||
while (*_str) {
|
||||
gba_putch(*_str++);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_printf function do formated printf
|
||||
*
|
||||
* @param _format printf format string
|
||||
* @param ... parameters specified in format string
|
||||
* @return None
|
||||
*/
|
||||
int gba_printf(const char *_format, ...)
|
||||
{
|
||||
char s[256];
|
||||
va_list marker;
|
||||
va_start(marker, _format);
|
||||
int r = vsprintf(s, _format, marker);
|
||||
va_end(marker);
|
||||
gba_puts(s);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_initconio function initialize console
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
static void gba_initconio(void)
|
||||
{
|
||||
GBA_REG_DISPCNT = GBA_DISP_MODE_4 | GBA_DISP_BG2_ON;/* 256 color bitmapped mode */
|
||||
const BgAffineDestData bgAffineReset = {256,0,0,256,0,-256*2};
|
||||
rBg2Affine = bgAffineReset;
|
||||
bg_palette[BLACK ] = RGB( 0, 0, 0); /* BLACK */
|
||||
bg_palette[BLUE ] = RGB( 0, 0,16); /* BLUE */
|
||||
bg_palette[GREEN ] = RGB( 0,16, 0); /* GREEN */
|
||||
bg_palette[CYAN ] = RGB( 0,16,16); /* CYAN */
|
||||
bg_palette[RED ] = RGB(16, 0, 0); /* RED */
|
||||
bg_palette[MAGENTA ] = RGB(16, 0,16); /* MAGENTA */
|
||||
bg_palette[BROWN ] = RGB(16,16, 0); /* BROWN */
|
||||
bg_palette[LIGHTGRAY ] = RGB(24,24,24); /* LIGHTGRAY */
|
||||
bg_palette[DARKGRAY ] = RGB(16,16,16); /* DARKGRAY */
|
||||
bg_palette[LIGHTBLUE ] = RGB( 0, 0,31); /* LIGHTBLUE */
|
||||
bg_palette[LIGHTGREEN ] = RGB( 0,31, 0); /* LIGHTGREEN */
|
||||
bg_palette[LIGHTCYAN ] = RGB( 0,31,31); /* LIGHTCYAN */
|
||||
bg_palette[LIGHTRED ] = RGB(31, 0, 0); /* LIGHTRED */
|
||||
bg_palette[LIGHTMAGENTA] = RGB(31, 0,31); /* LIGHTMAGENTA */
|
||||
bg_palette[YELLOW ] = RGB(31,31, 0); /* YELLOW */
|
||||
bg_palette[WHITE ] = RGB(31,31,31); /* WHITE */
|
||||
gba_textattr(0);
|
||||
gba_textcolor(DEF_TEXTCOLOR);
|
||||
gba_textbackground(DEF_TEXTBACKGROUND);
|
||||
gba_clrscr();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_textmode function set console mode
|
||||
*
|
||||
* @param _mode console mode code
|
||||
* @return None
|
||||
*/
|
||||
void gba_textmode(int _mode)
|
||||
{
|
||||
switch (_mode) {
|
||||
case CO60: {
|
||||
gba_initconio();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief delay_loop function is simple delay loop
|
||||
*
|
||||
* @param count loop counter
|
||||
* @return None
|
||||
*/
|
||||
static void delay_loop(unsigned int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i<count; i++) i = i;
|
||||
}
|
||||
|
||||
static unsigned char inputch = ASCII_CR; /**< input character value */
|
||||
/**
|
||||
* @brief gba_getch function read char from game pad keys
|
||||
*
|
||||
* Character input is done with GBA buttons,
|
||||
* up-down-left-right/A/B/R/L/Select/Start
|
||||
* - Select-key accept selected character
|
||||
* - Start-key read CR (Enter)
|
||||
* - A-key select 'A' character
|
||||
* - B-key select 'Z' character
|
||||
* - R-key select '1' character
|
||||
* - L-key select '9' character
|
||||
* - up-key increment character ('A'->'B')
|
||||
* - down-key decrement character ('B'-'A')
|
||||
* - left-key change set of character ('!'->'A'->'a')
|
||||
* - right-key change set of character ('a'->'A'->'!')
|
||||
*
|
||||
* @param None
|
||||
* @return Selected char code
|
||||
*/
|
||||
int gba_getch(void)
|
||||
{
|
||||
int keyx, key = 0;
|
||||
|
||||
while(1) {
|
||||
key = GBA_KEY();
|
||||
while ( (keyx=GBA_KEY())==key );
|
||||
switch (key) {
|
||||
case GBA_KEY_SELECT:
|
||||
gba_put(inputch);
|
||||
return inputch;
|
||||
break;
|
||||
case GBA_KEY_START:
|
||||
gba_put(' ');
|
||||
inputch = ASCII_CR;
|
||||
return inputch;
|
||||
break;
|
||||
case GBA_KEY_A:
|
||||
inputch = 'A';
|
||||
break;
|
||||
case GBA_KEY_B:
|
||||
inputch = 'Z';
|
||||
break;
|
||||
case GBA_KEY_UP:
|
||||
if ((inputch-1) >= 0x20) inputch--;
|
||||
break;
|
||||
case GBA_KEY_DOWN:
|
||||
if ((inputch+1) <= 0x7E) inputch++;
|
||||
break;
|
||||
case GBA_KEY_LEFT:
|
||||
if ((inputch - 0x20) >= 0x20) inputch -= 0x20;
|
||||
break;
|
||||
case GBA_KEY_RIGHT:
|
||||
if ((inputch + 0x20) <= 0x7E) inputch += 0x20;
|
||||
break;
|
||||
case GBA_KEY_R:
|
||||
inputch = '1';
|
||||
break;
|
||||
case GBA_KEY_L:
|
||||
inputch = '9';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gba_put(inputch);
|
||||
delay_loop(1000);
|
||||
}
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
/**
|
||||
* @file console.c
|
||||
*
|
||||
* This file contains the GBA console I/O package.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
#include <termios.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <gba.h>
|
||||
#include <conio.h>
|
||||
|
||||
/**
|
||||
* @brief gba_pollRead function read char
|
||||
*
|
||||
* @param minor unused
|
||||
* @return character code
|
||||
*/
|
||||
static int gba_pollRead(int minor)
|
||||
{
|
||||
return (gba_getch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_write function writes chars
|
||||
*
|
||||
* Input parameters: minor code, buffer pointer and lenght
|
||||
* @param minor unused
|
||||
* @param *buf buffer pointer
|
||||
* @param len lenght of buffer
|
||||
* @return character code
|
||||
*
|
||||
*/
|
||||
static ssize_t gba_write(int minor, const char *buf, size_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<len;i++) {
|
||||
gba_putch((unsigned short)buf[i]);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gba_setAttributes function is empty
|
||||
*
|
||||
* @param minor unused
|
||||
* @param *t unused
|
||||
* @return constant 0
|
||||
*/
|
||||
static int gba_setAttributes(int minor, const struct termios *t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** BSP_output_char for printk support */
|
||||
BSP_output_char_function_type BSP_output_char = (BSP_output_char_function_type) gba_putch;
|
||||
/** BSP_poll_char for printk support */
|
||||
BSP_polling_getchar_function_type BSP_poll_char = gba_getch;
|
||||
|
||||
/**
|
||||
* @brief Console device driver INITIALIZE entry point
|
||||
*
|
||||
* Initilizes the I/O console driver.
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
rtems_device_driver
|
||||
console_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
/* Set up TERMIOS */
|
||||
rtems_termios_initialize ();
|
||||
|
||||
/* Do device-specific initialization */
|
||||
/* Already done in bspstart.c -> gba_textmode(CO60); */
|
||||
|
||||
/* Register the device */
|
||||
status = rtems_io_register_name ("/dev/console", major, 0);
|
||||
if (status != RTEMS_SUCCESSFUL) {
|
||||
printk("Error registering console device!\n");
|
||||
rtems_fatal_error_occurred (status);
|
||||
}
|
||||
|
||||
printk("Initialized GBA console\n\n");
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief console_first_open function is empty
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
static int console_first_open(int major, int minor, void *arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief console_last_close function is empty
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
static int console_last_close(int major, int minor, void *arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Console device driver OPEN entry point
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
rtems_device_driver
|
||||
console_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
static rtems_termios_callbacks cb =
|
||||
{
|
||||
console_first_open, /* firstOpen */
|
||||
console_last_close, /* lastClose */
|
||||
gba_pollRead, /* pollRead */
|
||||
gba_write, /* write */
|
||||
gba_setAttributes, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
TERMIOS_POLLED /* 1 = outputUsesInterrupts */
|
||||
};
|
||||
|
||||
status = rtems_termios_open (major, minor, arg, &cb);
|
||||
|
||||
if (status != RTEMS_SUCCESSFUL) {
|
||||
printk("Error openning console device\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Console device driver CLOSE entry point
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
rtems_device_driver
|
||||
console_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_device_driver res = RTEMS_SUCCESSFUL;
|
||||
|
||||
res = rtems_termios_close (arg);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Console device driver READ entry point.
|
||||
*
|
||||
* Read characters from the I/O console.
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
rtems_device_driver
|
||||
console_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_read (arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Console device driver WRITE entry point.
|
||||
*
|
||||
* Write characters to the I/O console.
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
rtems_device_driver
|
||||
console_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_write (arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handle ioctl request.
|
||||
*
|
||||
* @param major diver major number
|
||||
* @param minor driver minor mumber
|
||||
* @param *arg pointer to parameters
|
||||
* @return status code
|
||||
*/
|
||||
rtems_device_driver
|
||||
console_control(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_ioctl (arg);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup arm_gba
|
||||
*
|
||||
* @brief ARM status register mode bits.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef __ARMMODEBITS_H
|
||||
#define __ARMMODEBITS_H
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
----------------------------------------------------------------------------*/
|
||||
#define Mode_USR 0x10
|
||||
#define Mode_FIQ 0x11
|
||||
#define Mode_IRQ 0x12
|
||||
#define Mode_SVC 0x13
|
||||
#define Mode_ABT 0x17
|
||||
#define Mode_ABORT 0x17
|
||||
#define Mode_UNDEF 0x1B
|
||||
#define Mode_SYS 0x1F /**< only available on ARM Arch v4 */
|
||||
#define Mode_Bits 0x1F /**< mask for mode bits */
|
||||
#define ModePriv Mode_SVC /**< used supervisor mode */
|
||||
|
||||
#define I_Bit 0x80
|
||||
#define F_Bit 0x40
|
||||
#define Int_Bits 0xC0
|
||||
|
||||
#define Mode_SVC_MIRQ (Mode_SVC | I_Bit | F_Bit)
|
||||
#define Mode_SVC_UIRQ (Mode_SVC)
|
||||
#define Mode_IRQ_MIRQ (Mode_SVC | I_Bit | F_Bit)
|
||||
#define Mode_IRQ_UIRQ (Mode_SVC)
|
||||
|
||||
#endif /* __ARMMODEBITS_H */
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup arm_gba
|
||||
*
|
||||
* @brief ASM macros.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------*
|
||||
* Macros
|
||||
*-----------------------------------------------------------------------------*/
|
||||
#ifdef __asm__
|
||||
#define PUBLIC_ARM_FUNCTION(label) .global label ; \
|
||||
.type label, function ; \
|
||||
.arm ; \
|
||||
label:
|
||||
|
||||
#define PUBLIC_THUMB_FUNCTION(label) .global label ; \
|
||||
.type label, function ; \
|
||||
.thumb_func ; \
|
||||
label:
|
||||
|
||||
#define STATIC_ARM_FUNCTION(label) .type label, function ; \
|
||||
.arm ; \
|
||||
label:
|
||||
|
||||
#define STATIC_THUMB_FUNCTION(label) .type label, function ; \
|
||||
.thumb_func ; \
|
||||
label:
|
||||
|
||||
#define OBJECT(label) .global label ; \
|
||||
.type label, object ; \
|
||||
label:
|
||||
|
||||
#define STATIC_OBJECT(label) .type label, object ; \
|
||||
label:
|
||||
|
||||
#define WEAK_OBJECT(label) .weak label ; \
|
||||
.type label, object ; \
|
||||
label:
|
||||
|
||||
#define LABEL_END(label) .L##label##_end: ; \
|
||||
.size label, .L##label##_end - label
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup arm_gba
|
||||
*
|
||||
* @brief Global BSP definitions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef LIBBSP_ARM_GBA_H
|
||||
#define LIBBSP_ARM_GBA_H
|
||||
|
||||
#include <bspopts.h>
|
||||
#include <bsp/default-initial-extension.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/iosupp.h>
|
||||
#include <rtems/console.h>
|
||||
#include <rtems/clockdrv.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BSP_FEATURE_IRQ_EXTENSION
|
||||
|
||||
/** Define operation count for Tests */
|
||||
#define OPERATION_COUNT 10
|
||||
|
||||
/** gba_zero_memory library function in start.S */
|
||||
extern void gba_zero_memory(int start, int stop);
|
||||
/** gba_move_memory library function in start.S */
|
||||
extern void gba_move_memory(int from, int toStart, int toEnd);
|
||||
/** gba_set_memory library function in start.S */
|
||||
extern void gba_set_memory(int start, int stop, int data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __BSP_H_ */
|
||||
/**
|
||||
* @defgroup arm_gba GBA Support
|
||||
*
|
||||
* @ingroup bsp_arm
|
||||
*
|
||||
* @brief GBA support package.
|
||||
*/
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup gba_conio
|
||||
*
|
||||
* @brief GBA conio I/O package.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef _CONIO_H
|
||||
#define _CONIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup gba_conio GBA Conio I/O
|
||||
*
|
||||
* @ingroup arm_gba
|
||||
*
|
||||
* @brief GBA Conio I/O support.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Includes *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#include <gba.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Defines *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define ASCII_BEL 0x07 /**< bell */
|
||||
#define ASCII_BS 0x08 /**< backspace */
|
||||
#define ASCII_TAB 0x09 /**< horizontal tab */
|
||||
#define ASCII_LF 0x0A /**< line feed */
|
||||
#define ASCII_CR 0x0D /**< carriage return */
|
||||
#define ASCII_XON 0x11 /**< control-Q */
|
||||
#define ASCII_XOFF 0x13 /**< control-S */
|
||||
#define ASCII_ESC 0x1B /**< escape */
|
||||
|
||||
|
||||
enum TEXT_MODES
|
||||
{
|
||||
CO60 = 0, /**< 60x26 (3x5 font) */
|
||||
MAXMODES
|
||||
};
|
||||
|
||||
enum COLORS
|
||||
{
|
||||
BLACK,
|
||||
BLUE,
|
||||
GREEN,
|
||||
CYAN,
|
||||
RED,
|
||||
MAGENTA,
|
||||
BROWN,
|
||||
LIGHTGRAY,
|
||||
DARKGRAY,
|
||||
LIGHTBLUE,
|
||||
LIGHTGREEN,
|
||||
LIGHTCYAN,
|
||||
LIGHTRED,
|
||||
LIGHTMAGENTA,
|
||||
YELLOW,
|
||||
WHITE,
|
||||
MAXCOLORS
|
||||
};
|
||||
|
||||
#define DEF_TEXTCOLOR BLACK
|
||||
#define DEF_TEXTBACKGROUND WHITE
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Prototypes *
|
||||
*---------------------------------------------------------------------------*/
|
||||
void gba_textmode(int _mode);
|
||||
void gba_clrscr(void);
|
||||
void gba_textattr(int _attr);
|
||||
void gba_textbackground(int _color);
|
||||
void gba_textcolor(int _color);
|
||||
void gba_putch(char _c);
|
||||
void gba_puts(const char *_str);
|
||||
int gba_printf(const char *_format, ...);
|
||||
void gba_gotoxy(int _x, int _y);
|
||||
int gba_getch(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CONIO_H */
|
||||
@@ -1,107 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup arm_gba
|
||||
*
|
||||
* @brief GameBoy Advance definitions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef _GBA_H
|
||||
#define _GBA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gba_registers.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Clock *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define __ClockFrequency 16780000L /**< ClockFreguency in Hz */
|
||||
#define __TimPreScaler 1024L /**< Prescaler value 1,64,256,1024 */
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Activation defines *
|
||||
*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Multiboot/Cart boot Selection.
|
||||
*
|
||||
* If the variable __gba_multiboot is defined
|
||||
* (probably should be in your main project file) then code
|
||||
* is generated which will run as a multiboot image (code starts
|
||||
* at 0x02000000) or as a normal flash cart / emulator image.
|
||||
* (i.e. start.S copies code from ROM to EWRAM if started in cart
|
||||
* or emulator.) If this variable is not defined then code is
|
||||
* generated for flash cart / emulator only operation (code starts
|
||||
* at 0x08000000).
|
||||
*/
|
||||
#define MULTIBOOT volatile const unsigned short __gba_multiboot;
|
||||
|
||||
/**
|
||||
* IWRAM/EWRAM data Selection.
|
||||
*
|
||||
* If the variable __gba_iwram_data is defined
|
||||
* (probably should be in your main project file) then code
|
||||
* is generated which will allocate data section in IWRAM
|
||||
* (data starts at 0x03000080).
|
||||
* If this variable is not defined then data sections is
|
||||
* allocated in EWRAM (data starts at 0x02000000).
|
||||
*/
|
||||
#define IWRAMDATA volatile const unsigned short __gba_iwram_data;
|
||||
|
||||
/**
|
||||
* IWRAM/EWRAM bss Selection.
|
||||
*
|
||||
* If the variable __gba_iwram_bss is defined
|
||||
* (probably should be in your main project file) then code
|
||||
* is generated which will allocate bss section in IWRAM
|
||||
* (data starts at 0x03000080).
|
||||
* If this variable is not defined then bss sections is
|
||||
* allocated in EWRAM (data starts at 0x02000000).
|
||||
*/
|
||||
#define IWRAMBSS volatile const unsigned short __gba_iwram_bss;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Attributes *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define CODE_IN_ROM __attribute__ ((section (".text"), long_call))
|
||||
#define CODE_IN_IWRAM __attribute__ ((section (".iwram"), long_call))
|
||||
#define IN_IWRAM __attribute__ ((section (".iwram")))
|
||||
#define IN_EWRAM __attribute__ ((section (".ewram")))
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Console Keypad *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define OK_KEY (0==0) /**< TRUE */
|
||||
#define NO_KEY (0==1) /**< FALSE */
|
||||
#define GBA_KEYS_PRESSED(keys) (( ((~GBA_REG_P1) & (keys)) == (keys)) ? (OK_KEY) : (NO_KEY))
|
||||
#define GBA_ANY_KEY(keys) (( ((~GBA_REG_P1) & (keys)) != 0) ? (OK_KEY) : (NO_KEY))
|
||||
#define GBA_KEY() ((~GBA_REG_P1)&GBA_KEY_ALL)
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* Console Screen *
|
||||
*---------------------------------------------------------------------------*/
|
||||
#define GBA_LCD_WIDTH 240
|
||||
#define GBA_LCD_HEIGHT 160
|
||||
#define GBA_MODE5_WIDTH 160
|
||||
#define GBA_MODE5_HEIGHT 128
|
||||
#define GBA_LCD_ASPECT ((float)(GBA_LCD_WIDTH / GBA_LCD_HEIGHT))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* @file irq.c
|
||||
*
|
||||
* This file contains the implementation of the function described in irq.h.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2010 embedded brains GmbH.
|
||||
*
|
||||
* Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com>
|
||||
*
|
||||
* Copyright (c) 2002 by Charlie Steader <charlies@poliac.com>
|
||||
*
|
||||
* Copyright (c) 2004 by Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <bsp/irq-generic.h>
|
||||
|
||||
#include <gba_registers.h>
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void bsp_interrupt_dispatch(void);
|
||||
|
||||
void bsp_interrupt_dispatch(void)
|
||||
{
|
||||
unsigned reg_ie = GBA_REG_IE;
|
||||
unsigned reg_if = GBA_REG_IF & reg_ie;
|
||||
rtems_vector_number vector = 31 - __builtin_clz(reg_if);
|
||||
|
||||
bsp_interrupt_handler_dispatch(vector);
|
||||
|
||||
GBA_REG_IF = 1 << vector;
|
||||
}
|
||||
|
||||
rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
|
||||
{
|
||||
GBA_REG_IE |= 1 << vector;
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
|
||||
{
|
||||
GBA_REG_IE &= ~(1 << vector);
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_status_code bsp_interrupt_facility_initialize(void)
|
||||
{
|
||||
/* clear all interrupt status flags */
|
||||
GBA_REG_IF = 0xffff;
|
||||
/* disable all interrupts */
|
||||
GBA_REG_IE = 0;
|
||||
/* set master interrupt enable */
|
||||
GBA_REG_IME = 1;
|
||||
|
||||
/* Exception handler is already present in the ROM BIOS */
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup gba_interrupt
|
||||
*
|
||||
* @brief Interrupt definitions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2010 embedded brains GmbH.
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifndef __asm__
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/irq.h>
|
||||
#include <rtems/irq-extension.h>
|
||||
|
||||
#endif /* __asm__ */
|
||||
|
||||
#ifndef _IRQ_H_
|
||||
#define _IRQ_H_
|
||||
|
||||
/**
|
||||
* @defgroup gba_interrupt Interrupt Support
|
||||
*
|
||||
* @ingroup arm_gba
|
||||
*
|
||||
* @brief Interrupt support.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#define ENABLE_IRQ() GBA_REG_IME = 1;
|
||||
#define DISABLE_IRQ() GBA_REG_IME = 0;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| Constants
|
||||
+--------------------------------------------------------------------------*/
|
||||
|
||||
#define BSP_IRQ_VBLANK 0
|
||||
#define BSP_IRQ_HBLANK 1
|
||||
#define BSP_IRQ_VCOUNTER 2
|
||||
#define BSP_IRQ_TIMER0 3
|
||||
#define BSP_IRQ_TIMER1 4
|
||||
#define BSP_IRQ_TIMER2 5
|
||||
#define BSP_IRQ_TIMER3 6
|
||||
#define BSP_IRQ_SERIAL 7
|
||||
#define BSP_IRQ_DMA0 8
|
||||
#define BSP_IRQ_DMA1 9
|
||||
#define BSP_IRQ_DMA2 10
|
||||
#define BSP_IRQ_DMA3 11
|
||||
#define BSP_IRQ_KEY 12
|
||||
#define BSP_IRQ_CART 13
|
||||
#define BSP_IRQ_NA14 14
|
||||
#define BSP_IRQ_NA15 15
|
||||
#define BSP_MAX_INT 16
|
||||
|
||||
#define BSP_INTERRUPT_VECTOR_MIN 0
|
||||
|
||||
#define BSP_INTERRUPT_VECTOR_MAX (BSP_MAX_INT - 1)
|
||||
|
||||
#endif /* _IRQ_H_ */
|
||||
@@ -1,24 +0,0 @@
|
||||
#
|
||||
# Config file for Gameboy Advance ARM --
|
||||
#
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/default.cfg
|
||||
|
||||
RTEMS_CPU=arm
|
||||
RTEMS_CPU_MODEL=arm7tdmi
|
||||
|
||||
# This contains the compiler options necessary to select the CPU model
|
||||
# and (hopefully) optimize for it.
|
||||
#
|
||||
CPU_CFLAGS = -mcpu=$(RTEMS_CPU_MODEL)
|
||||
|
||||
# optimize flag: typically -O2
|
||||
CFLAGS_OPTIMIZE_V = -O2 -g
|
||||
|
||||
# Some GBA simulators want a .gba extension.
|
||||
define bsp-post-link
|
||||
$(OBJCOPY) -O binary --remove-section=.comment \
|
||||
--remove-section=.note --strip-unneeded \
|
||||
$(basename $@)$(EXEEXT) $(basename $@)$(DOWNEXT)
|
||||
$(default-bsp-post-link)
|
||||
endef
|
||||
@@ -1,99 +0,0 @@
|
||||
## Automatically generated by ampolish3 - Do not edit
|
||||
|
||||
if AMPOLISH3
|
||||
$(srcdir)/preinstall.am: Makefile.am
|
||||
$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
|
||||
endif
|
||||
|
||||
PREINSTALL_DIRS =
|
||||
DISTCLEANFILES += $(PREINSTALL_DIRS)
|
||||
|
||||
all-am: $(PREINSTALL_FILES)
|
||||
|
||||
PREINSTALL_FILES =
|
||||
CLEANFILES = $(PREINSTALL_FILES)
|
||||
|
||||
all-local: $(TMPINSTALL_FILES)
|
||||
|
||||
TMPINSTALL_FILES =
|
||||
CLEANFILES += $(TMPINSTALL_FILES)
|
||||
|
||||
$(PROJECT_LIB)/$(dirstamp):
|
||||
@$(MKDIR_P) $(PROJECT_LIB)
|
||||
@: > $(PROJECT_LIB)/$(dirstamp)
|
||||
PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
|
||||
|
||||
$(PROJECT_INCLUDE)/$(dirstamp):
|
||||
@$(MKDIR_P) $(PROJECT_INCLUDE)
|
||||
@: > $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/$(dirstamp):
|
||||
@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
|
||||
@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
|
||||
$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
|
||||
PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
|
||||
|
||||
$(PROJECT_INCLUDE)/arm_mode_bits.h: include/arm_mode_bits.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arm_mode_bits.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/arm_mode_bits.h
|
||||
|
||||
$(PROJECT_INCLUDE)/asm_macros.h: include/asm_macros.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/asm_macros.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/asm_macros.h
|
||||
|
||||
$(PROJECT_INCLUDE)/gba_registers.h: include/gba_registers.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/gba_registers.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/gba_registers.h
|
||||
|
||||
$(PROJECT_INCLUDE)/conio.h: include/conio.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/conio.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/conio.h
|
||||
|
||||
$(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
|
||||
|
||||
$(PROJECT_INCLUDE)/gba.h: include/gba.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/gba.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/gba.h
|
||||
|
||||
$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
|
||||
|
||||
$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
|
||||
|
||||
$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
|
||||
TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
|
||||
|
||||
$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
|
||||
PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
|
||||
|
||||
$(PROJECT_INCLUDE)/bsp/irq.h: irq/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
|
||||
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
|
||||
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* @file logo.S
|
||||
*
|
||||
* Nintendo Logo Character Data [offset 0x04].
|
||||
*/
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* THIS CODE WAS NOT MADE IN ASSOCIATION WITH NINTENDO AND DOES NOT MAKE USE
|
||||
* OF ANY INTELLECTUAL PROPERTY CLAIMED BY NINTENDO.
|
||||
*
|
||||
* GAMEBOY ADVANCE IS A TRADEMARK OF NINTENDO.
|
||||
*/
|
||||
/* @cond INCLUDE_ASM */
|
||||
.word 0x51AEFF24, 0x21A29A69, 0x0A82843D, 0xAD09E484
|
||||
.word 0x988B2411, 0x217F81C0, 0x19BE52A3, 0x20CE0993
|
||||
.word 0x4A4A4610, 0xEC3127F8, 0x33E8C758, 0xBFCEE382
|
||||
.word 0x94DFF485, 0xC1094BCE, 0xC08A5694, 0xFCA77213
|
||||
.word 0x734D849F, 0x619ACAA3, 0x27A39758, 0x769803FC
|
||||
.word 0x61C71D23, 0x56AE0403, 0x008438BF, 0xFD0EA740
|
||||
.word 0x03FE52FF, 0xF130956F, 0x85C0FB97, 0x2580D660
|
||||
.word 0x03BE63A9, 0xE2384E01, 0xFF34A2F9, 0x44033EBB
|
||||
.word 0xCB900078, 0x943A1188, 0x637CC065, 0xAF3CF087
|
||||
.word 0x8BE425D6, 0x72AC0A38, 0x07F8D421
|
||||
/* @endcond */
|
||||
@@ -1,396 +0,0 @@
|
||||
/**
|
||||
* @file start.S
|
||||
*
|
||||
* RTEMS entry point.
|
||||
*/
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) by Jeff Frohwein.
|
||||
*
|
||||
* Copyright (c) 2003, Jason Wilkins.
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
* based on crt0.S v1.28 by Jeff Frohwein
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
* This source file is based on work by Jeff Frohwein and Jason Wilkins
|
||||
*****************************************************************************
|
||||
*****************************************************************************
|
||||
* crt0.S v1.28 by Jeff Frohwein
|
||||
* :
|
||||
* This file is released into the public domain for commercial
|
||||
* or non-commercial usage with no restrictions placed upon it.
|
||||
*****************************************************************************
|
||||
* Copyright 2003, Jason Wilkins. This source code is free for any use except
|
||||
* that this copyright notice and the following disclaimers remain intact when
|
||||
* the source is distributed. Object code and binary distributions may be made
|
||||
* as if the code were in the public domain.
|
||||
*
|
||||
* THIS CODE WAS NOT MADE IN ASSOCIATION WITH NINTENDO AND DOES NOT MAKE USE
|
||||
* OF ANY INTELLECTUAL PROPERTY CLAIMED BY NINTENDO.
|
||||
*
|
||||
* GAMEBOY ADVANCE IS A TRADEMARK OF NINTENDO.
|
||||
*
|
||||
* THIS CODE HAS BEEN PROVIDED "AS-IS" WITHOUT A WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. THE ENTIRE RISK AS TO THE
|
||||
* QUALITY OR PERFORMANCE OF THE CODE IS WITH YOU.
|
||||
*
|
||||
* IN NO EVENT, UNLESS AGREED TO IN WRITING, WILL ANY COPYRIGHT HOLDER, OR ANY
|
||||
* OTHER PARTY, BE HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OR
|
||||
* INABILITY TO USE THIS CODE.
|
||||
*****************************************************************************/
|
||||
|
||||
#define __asm__
|
||||
#include <rtems/asm.h>
|
||||
#include <asm_macros.h>
|
||||
#include <arm_mode_bits.h>
|
||||
/* @cond INCLUDE_ASM */
|
||||
|
||||
#ifndef NINTENDO_LOGO
|
||||
#define NINTENDO_LOGO 1
|
||||
#endif
|
||||
|
||||
#ifndef GBA_MULTIBOOT
|
||||
#define GBA_MULTIBOOT 1
|
||||
#endif
|
||||
|
||||
#ifndef GAME_TITLE
|
||||
#define GAME_TITLE "RTEMS-RTOS "
|
||||
#endif
|
||||
|
||||
#ifdef GBA_MULTIBOOT
|
||||
#ifndef GAME_CODE
|
||||
#define GAME_CODE "MB "
|
||||
#endif
|
||||
#ifndef COMPLEMENT_CHECK
|
||||
#define COMPLEMENT_CHECK 0xE2
|
||||
#endif
|
||||
#else
|
||||
#ifndef GAME_CODE
|
||||
#define GAME_CODE "GBA "
|
||||
#endif
|
||||
#ifndef COMPLEMENT_CHECK
|
||||
#define COMPLEMENT_CHECK 0xC7
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAKER_CODE
|
||||
#define MAKER_CODE "00"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* RTEMS entry point
|
||||
* function void _start(void)
|
||||
*
|
||||
*/
|
||||
/*****************************************************************************\
|
||||
ROM Header
|
||||
\*****************************************************************************/
|
||||
|
||||
.text
|
||||
.align
|
||||
.arm
|
||||
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Nintendo Header:
|
||||
| A special header is required or the GBA will refuse to run your code.
|
||||
|
|
||||
| File offsets from 0x0200000 or 0x08000000.
|
||||
+----------------------------------------------------------------------------*/
|
||||
PUBLIC_ARM_FUNCTION(_start)
|
||||
b SYM(_real_start) /* 0x00 Entry Point */
|
||||
SYM(_gba_rom_header):
|
||||
#if NINTENDO_LOGO /* 0x04 Nintendo Logo Character Data */
|
||||
#include "logo.S"
|
||||
#else
|
||||
.fill 156, 1, 0 /* 0x04 Nintendo Logo Character Data */
|
||||
#endif
|
||||
.ascii GAME_TITLE /* 0xA0 Game Title */
|
||||
.ascii GAME_CODE /* 0xAC Game Code */
|
||||
.ascii MAKER_CODE /* 0xB0 Maker Code */
|
||||
.byte 0x96 /* 0xB2 Fixed Value */
|
||||
.byte 0 /* 0xB3 Main Unit Code */
|
||||
.byte 0 /* 0xB4 Device Type */
|
||||
.byte 0, 0, 0, 0, 0, 0, 0 /* 0xB5 Reserved (7 Bytes) */
|
||||
.byte 0 /* 0xBC Software Version No. */
|
||||
.byte COMPLEMENT_CHECK /* 0xBD Complement Check */
|
||||
.byte 0, 0 /* 0xBE Reserved */
|
||||
.Lheader_end:
|
||||
|
||||
|
||||
#if GBA_MULTIBOOT
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Multiboot Header:
|
||||
| The following header is required if the code is meant for Multiboot.
|
||||
|
|
||||
| If the code has been downloaded through the serial port, then the GBA BIOS
|
||||
| will set offset 0xC0 depending on the boot method:
|
||||
| 1 = JoyBus, 3 = Multiboot
|
||||
| It remains 0 for cartridges.
|
||||
|
|
||||
| offset 0xC4 will be set to the GBA's assigned slave number 1-3.
|
||||
| This header also defines the symbols _boot_method and _slave_number for
|
||||
| easy reference to these values. Some libraries may depend on them whether
|
||||
| or not the code is meant for Multiboot.
|
||||
|
|
||||
+----------------------------------------------------------------------------*/
|
||||
SYM(_gba_multiboot_start):
|
||||
b SYM(_real_start) /* 0xC0 Multiboot Entry Point */
|
||||
OBJECT(_boot_method)
|
||||
.byte 0 /* 0xC4 Boot Method */
|
||||
OBJECT(_slave_number)
|
||||
.byte 0 /* 0xC5 Slave Number (1-3) */
|
||||
.align
|
||||
STATIC_OBJECT(_gba_mb_reserved)
|
||||
.word 0, 0, 0, 0, 0, 0 /* 0xC8 Reserved (6 words) */
|
||||
SYM(_gba_joybus_start):
|
||||
b SYM(_real_start) /* 0xE0 JoyBus Entry Point */
|
||||
.Lmultiboot_header_end:
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Restore registers and stack from GBA bios IRQ frame and call ISR_Handler
|
||||
+----------------------------------------------------------------------------*/
|
||||
EXTERN(_ISR_Handler)
|
||||
.align
|
||||
PUBLIC_ARM_FUNCTION(_gba_ISR_handler)
|
||||
ldmfd r13!,{r0-r3,r12,r14}
|
||||
b _ARMV4_Exception_interrupt
|
||||
LABEL_END(_gba_ISR_handler)
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Code to initialize the low-level BSP environment
|
||||
+----------------------------------------------------------------------------*/
|
||||
SYM(_real_start):
|
||||
/* Initialize IRQ and USR Stack Pointers */
|
||||
SYM(_gba_init_stacks):
|
||||
mov r0, #(Mode_IRQ | Int_Bits) /* No interrupts */
|
||||
msr cpsr, r0 /* switch to IRQ mode */
|
||||
ldr sp, =__sp_irq /* defined in linkcmds */
|
||||
mov r0, #(ModePriv | Int_Bits) /* No interrupts */
|
||||
msr cpsr, r0 /* switch to System Mode */
|
||||
ldr sp, =__sp_usr /* defined in linkcmds */
|
||||
|
||||
/* Switch to Thumb Mode */
|
||||
SYM(_gba_bx_thumb):
|
||||
adr r0, .Lthumb + 1
|
||||
bx r0
|
||||
.thumb
|
||||
.Lthumb:
|
||||
/* Reduce gameboy waitstates */
|
||||
SYM(_reduce_waitstates):
|
||||
ldr r1, =0x4000204
|
||||
ldrh r0, =0x4490
|
||||
strh r0, [r1]
|
||||
|
||||
|
||||
#if GBA_MULTIBOOT
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Load Multiboot Image from ROM into RAM:
|
||||
| Check to see if the image is meant for Multiboot or GamePak. If it is for
|
||||
| Multiboot then check if it is currently running from EWRAM or from CARTROM.
|
||||
| If it is running from CARTROM, then it needs to be copied to EWRAM and
|
||||
| re-executed from the beginning.
|
||||
|
|
||||
| The reason for all this is to allow a program to be used "as-is" with a
|
||||
| flash-cart, emulator, or MBV2-style Multiboot cable without rebuilding.
|
||||
|
|
||||
| NOTE: Any branchs used above this code need to be relative.
|
||||
+----------------------------------------------------------------------------*/
|
||||
STATIC_THUMB_FUNCTION(_gba_load_multiboot)
|
||||
ldr r0, =_start /* 8000000h=GamePak 2000000h=Multiboot*/
|
||||
ldr r1, =__gba_rom_start /* defined in linkcmds */
|
||||
cmp r0, r1
|
||||
beq SYM(_no_load_multiboot)/* skip if GamePak */
|
||||
mov r3, pc
|
||||
cmp r1, r3 /* check program counter */
|
||||
bhi SYM(_no_load_multiboot)/* skip if already running from EWRAM */
|
||||
sub r3, r1, r0 /* diff between _start and CARTROM */
|
||||
ldr r2, =__load_stop_data /* defined in linkcmds */
|
||||
add r2, r2, r3 /* adjust pointer into ROM */
|
||||
bl SYM(gba_move_memory)
|
||||
|
||||
/* patch multiboot header */
|
||||
ldr r0, =SYM(_boot_method)
|
||||
mov r1, #3
|
||||
str r1, [r0]
|
||||
|
||||
/* remember that multiboot image came from GamePak */
|
||||
ldr r0, =SYM(_gba_flash_loaded_multiboot)
|
||||
mov r1, #0
|
||||
str r1, [r0]
|
||||
|
||||
ldr r0, =SYM(_start)
|
||||
bx r0 /* restart */
|
||||
LABEL_END(_gba_load_multiboot)
|
||||
|
||||
.align 4
|
||||
OBJECT(_gba_flash_loaded_multiboot)
|
||||
.word -1
|
||||
LABEL_END(_gba_flash_loaded_multiboot)
|
||||
SYM(_no_load_multiboot):
|
||||
#endif
|
||||
|
||||
/* Initialize Standard Sections */
|
||||
STATIC_THUMB_FUNCTION(_gba_init_std_sections)
|
||||
/* Copy internal work ram (iwram section ROM to RAM)*/
|
||||
ldr r0,=__iwram_start
|
||||
ldr r1,=__load_start_iwram
|
||||
ldr r2,=__load_stop_iwram
|
||||
bl SYM(gba_move_memory)
|
||||
|
||||
/* Copy external work ram (ewram section ROM to RAM) */
|
||||
ldr r0,=__ewram_start
|
||||
ldr r1,=__load_start_ewram
|
||||
ldr r2,=__load_stop_ewram
|
||||
bl SYM(gba_move_memory)
|
||||
|
||||
/* load initial values of variables like 'int foo = 42' */
|
||||
ldr r0, =__data_start /* defined in linkcmds */
|
||||
ldr r1, =__load_start_data /* defined in linkcmds */
|
||||
ldr r2, =__load_stop_data /* defined in linkcmds */
|
||||
bl SYM(gba_move_memory)
|
||||
|
||||
/* zero the bss */
|
||||
ldr r0, =__bss_start /* defined in linkcmds */
|
||||
ldr r1, =__bss_end /* defined in linkcmds */
|
||||
bl SYM(gba_zero_memory)
|
||||
LABEL_END(_gba_init_std_sections)
|
||||
|
||||
/* Initialize Interrupt Vector */
|
||||
STATIC_THUMB_FUNCTION(_gba_init_intr_vect)
|
||||
ldr r1, =__irq_vector /* defined in linkcmds */
|
||||
ldr r0, =SYM(_gba_ISR_handler)
|
||||
str r0, [r1]
|
||||
LABEL_END(_gba_init_intr_vect)
|
||||
|
||||
|
||||
/* Enter the C code. If it returns, then restart */
|
||||
STATIC_THUMB_FUNCTION(_gba_call_arm_boot_card)
|
||||
adr r1, .Larm
|
||||
bx r1
|
||||
.arm
|
||||
.Larm:
|
||||
ldr r1, =boot_card
|
||||
mov r0, #0
|
||||
bl SYM(_gba_call_via_r1)
|
||||
|
||||
ldr r0, =SYM(_gba_reset)
|
||||
SYM(_gba_call_via_r1):
|
||||
bx r1
|
||||
|
||||
/* GBA Reset */
|
||||
PUBLIC_ARM_FUNCTION(_gba_reset)
|
||||
adr r0, .Lthumb2 + 1
|
||||
bx r0
|
||||
.thumb
|
||||
.Lthumb2:
|
||||
/* disable interrupts */
|
||||
ldr r0, =0x04000208
|
||||
mov r1, #0
|
||||
strb r1, [r0]
|
||||
|
||||
/* reset stack, default free area */
|
||||
ldr r0, =0x03007F00
|
||||
mov sp, r0
|
||||
|
||||
#if GBA_MULTIBOOT
|
||||
ldr r0, =SYM(_gba_flash_loaded_multiboot)
|
||||
ldr r0, [r0]
|
||||
cmp r0, #0
|
||||
beq SYM(_reset)
|
||||
#endif
|
||||
|
||||
ldr r0, =_start /* defined in linkcmds */
|
||||
ldr r1, =__gba_rom_start /* defined in linkcmds */
|
||||
sub r0, r0, r1
|
||||
lsr r0, r0, #24
|
||||
|
||||
SYM(_reset):
|
||||
/* soft reset (swi 0) parameter: where is _start */
|
||||
ldr r1, =0x03007FFA
|
||||
strb r0, [r1]
|
||||
mov r0, #0xFE /* clear all but EWRAM */
|
||||
swi 1
|
||||
swi 0
|
||||
LABEL_END(_gba_reset)
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------+
|
||||
| Library Functions
|
||||
+----------------------------------------------------------------------------*/
|
||||
|
||||
/* gba_zero_memory */
|
||||
PUBLIC_THUMB_FUNCTION(gba_zero_memory)
|
||||
mov r2, #0
|
||||
nop
|
||||
LABEL_END(gba_zero_memory)
|
||||
|
||||
/* gba_set_memory */
|
||||
PUBLIC_THUMB_FUNCTION(gba_set_memory)
|
||||
cmp r0, r1
|
||||
bcs .Lset_memory_return
|
||||
|
||||
.Lset_memory_loop:
|
||||
stmia r0!, {r2}
|
||||
cmp r0, r1
|
||||
bcc .Lset_memory_loop
|
||||
|
||||
.Lset_memory_return:
|
||||
bx lr
|
||||
LABEL_END(gba_set_memory)
|
||||
|
||||
/* gba_move_memory */
|
||||
.align
|
||||
PUBLIC_THUMB_FUNCTION(gba_move_memory)
|
||||
cmp r0, r1
|
||||
bcc .Lforward_move /* if dst < src then forward copy */
|
||||
bhi .Lreverse_move /* if dst > src then reverse copy */
|
||||
bx lr /* else dst == src, nothing to do */
|
||||
|
||||
.Lforward_move:
|
||||
cmp r1, r2
|
||||
bcs .Lmove_memory_return
|
||||
|
||||
.Lforward_move_loop:
|
||||
ldmia r1!, {r3}
|
||||
stmia r0!, {r3}
|
||||
cmp r1, r2
|
||||
bcc .Lforward_move_loop
|
||||
bx lr
|
||||
|
||||
.Lreverse_move:
|
||||
cmp r2, r1
|
||||
bls .Lmove_memory_return
|
||||
sub r3, r2, r1
|
||||
add r0, r0, r3
|
||||
|
||||
.Lreverse_move_loop:
|
||||
sub r2, r2, #4
|
||||
ldr r3, [r2]
|
||||
sub r0, r0, #4
|
||||
str r3, [r0]
|
||||
cmp r2, r1
|
||||
bhi .Lreverse_move_loop
|
||||
|
||||
.Lmove_memory_return:
|
||||
bx lr
|
||||
LABEL_END(gba_move_memory)
|
||||
|
||||
|
||||
/* @todo FIXME: Remove unused handler needed by ../score/cpu_asm.S
|
||||
*****************************************************************************/
|
||||
.arm
|
||||
.global SWI_Handler
|
||||
SWI_Handler:
|
||||
mov pc, lr
|
||||
/* @endcond */
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bsp/bootcard.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern int _end;
|
||||
extern int __heap_limit;
|
||||
|
||||
void bsp_work_area_initialize(void)
|
||||
{
|
||||
void *area_start = (void *)&_end;
|
||||
uintptr_t area_size = (uintptr_t)&__heap_limit - (uintptr_t)&_end;
|
||||
|
||||
bsp_work_area_initialize_default( area_start, area_size );
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <bsp.h>
|
||||
#include <bsp/bootcard.h>
|
||||
|
||||
void bsp_reset(void)
|
||||
{
|
||||
__asm__ volatile ("ldr r0, =_gba_reset");
|
||||
__asm__ volatile ("bx r0");
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* @file bspstart.c
|
||||
*
|
||||
* This file contains the GBA BSP startup package.
|
||||
* It includes application, board, and monitor specific initialization and
|
||||
* configuration. The generic CPU dependent initialization has been
|
||||
* performed before this routine is invoked.
|
||||
*/
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <bsp.h>
|
||||
#include <bsp/irq-generic.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <gba.h>
|
||||
#include <conio.h>
|
||||
|
||||
/** Chip registers */
|
||||
volatile unsigned int *Regs = (unsigned int *)GBA_IO_REGS_ADDR;
|
||||
|
||||
/**
|
||||
* @brief BSP Start
|
||||
*
|
||||
* Called before main is invoked.
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
static void bsp_start_default( void )
|
||||
{
|
||||
/* Init conio */
|
||||
gba_textmode(CO60);
|
||||
|
||||
/* Init rtems exceptions management
|
||||
* !!!!!GBA -- Can't use exception vectors in GBA because they are
|
||||
* already in GBA ROM BIOS
|
||||
*/
|
||||
/* rtems_exception_init_mngt(); */
|
||||
|
||||
/* Init rtems interrupt management */
|
||||
bsp_interrupt_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief weak alias for bsp_start_default
|
||||
*
|
||||
* By making this a weak alias for bsp_start_default, a brave soul
|
||||
* can override the actual bsp_start routine used.
|
||||
*/
|
||||
void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
|
||||
@@ -1,386 +0,0 @@
|
||||
/**
|
||||
* @file linkcmds
|
||||
*
|
||||
* GBA BSP linker script
|
||||
*/
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) Jeff Frohwein
|
||||
*
|
||||
* Copyright (c) 2003 Jason Wilkins
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
*
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
* This Linker Script is based on work by Jeff Frohwein and Jason Wilkins
|
||||
*****************************************************************************
|
||||
* Linker Script v1.3 by Jeff Frohwein
|
||||
* :
|
||||
* This file is released into the public domain
|
||||
* for commercial or non-commercial use with no
|
||||
* restrictions placed upon it.
|
||||
*****************************************************************************
|
||||
* Copyright 2003, Jason Wilkins. This source code is free for any use except
|
||||
* that this copyright notice and the following disclaimers remain intact when
|
||||
* the source is distributed. There are absolutely no restrictions on use of
|
||||
* object code generated from this source, but the disclaimers remain in force.
|
||||
*
|
||||
* THIS CODE WAS NOT MADE IN ASSOCIATION WITH NINTENDO AND DOES NOT MAKE USE OF
|
||||
* ANY INTELLECTUAL PROPERTY CLAIMED BY NINTENDO.
|
||||
*
|
||||
* GAMEBOY ADVANCE IS A TRADEMARK OF NINTENDO.
|
||||
*
|
||||
* THIS CODE HAS BEEN PROVIDED "AS-IS" WITHOUT A WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. THE ENTIRE RISK AS TO THE
|
||||
* QUALITY OR PERFORMANCE OF THE CODE IS WITH YOU.
|
||||
*
|
||||
* IN NO EVENT, UNLESS AGREED TO IN WRITING, WILL ANY COPYRIGHT HOLDER, OR ANY
|
||||
* OTHER PARTY, BE HELD LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OR
|
||||
* INABILITY TO USE THIS CODE.
|
||||
*
|
||||
*****************************************************************************/
|
||||
/* @cond INCLUDE_ASM */
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_start)
|
||||
|
||||
/*************************************************************************
|
||||
The linker script MEMORY directive is not used here due to the fact
|
||||
that __ro_start is not always a fixed value.
|
||||
*************************************************************************
|
||||
MEMORY
|
||||
{
|
||||
rom : ORIGIN = 0x08000000 , LENGTH = 96M
|
||||
iwram : ORIGIN = 0x03000000 , LENGTH = 32K
|
||||
ewram : ORIGIN = 0x02000000 , LENGTH = 256K
|
||||
sram : ORIGIN = 0x0E000000 , LENGTH = 64K
|
||||
}
|
||||
*************************************************************************/
|
||||
__gba_ewram_start = 0x02000000;
|
||||
__gba_ewram_end = 0x02040000;
|
||||
__gba_iwram_start = 0x03000000;
|
||||
__gba_iwram_end = 0x03008000;
|
||||
__gba_rom_start = 0x08000000;
|
||||
__gba_rom_end = 0x0E000000;
|
||||
__gba_sram_start = 0x0E000000;
|
||||
__gba_sram_end = 0x0E010000;
|
||||
|
||||
__sp_irq_size = 0x2A0;
|
||||
_stack_size = 0xA00;
|
||||
__irq_vector = __gba_iwram_end - 0x0004; /* 0x03007FFC */
|
||||
__sp_svc = __gba_iwram_end - 0x0020; /* 0x03007FE0 */
|
||||
__sp_irq = __gba_iwram_end - 0x0060; /* 0x03007FA0 */
|
||||
__sp_usr = __sp_irq - __sp_irq_size; /* 0x03007D00 */
|
||||
__sp_limit = __sp_usr - _stack_size; /* 0x03007300 */
|
||||
__heap_limit = DEFINED(__gba_multiboot) ? __gba_ewram_end : ( DEFINED(__gba_iwram_bss) ? __sp_limit : __gba_ewram_end ) ;
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/*** read-only sections ***/
|
||||
/*************************************************************************
|
||||
if 'multiboot' allocate prog in __gba_ewram_start (0x02000000-0x0207FFFF)
|
||||
else allocate prog in __gba_rom_start (0x08000000-0x0DFFFFFF)
|
||||
*************************************************************************/
|
||||
__ro_start = DEFINED(__gba_multiboot) ? __gba_ewram_start : __gba_rom_start ;
|
||||
PROVIDE(__text_start__ = __ro_start );
|
||||
.text __ro_start :
|
||||
{
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*/start.o(.text)
|
||||
*(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .text)
|
||||
*(.stub .text.* .gnu.linkonce.t*)
|
||||
|
||||
/*
|
||||
* Special FreeBSD sysctl sections.
|
||||
*/
|
||||
. = ALIGN (16);
|
||||
__start_set_sysctl_set = .;
|
||||
*(set_sysctl_*);
|
||||
__stop_set_sysctl_set = ABSOLUTE(.);
|
||||
*(set_domain_*);
|
||||
*(set_pseudo_*);
|
||||
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.init :
|
||||
{
|
||||
*(.init)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.fini :
|
||||
{
|
||||
*(.fini)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
__rodata_start = . ;
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata1)
|
||||
*(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .rodata)
|
||||
*(.rodata.* .gnu.linkonce.r*)
|
||||
KEEP (*(SORT(.rtemsroset.*)))
|
||||
*(.roda) /* deprecated: for compatibility with objcopyroda */
|
||||
SORT(CONSTRUCTORS)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
.tdata : {
|
||||
_TLS_Data_begin = .;
|
||||
*(.tdata .tdata.* .gnu.linkonce.td.*)
|
||||
_TLS_Data_end = .;
|
||||
} =0xFF
|
||||
.tbss : {
|
||||
_TLS_BSS_begin = .;
|
||||
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
|
||||
_TLS_BSS_end = .;
|
||||
}
|
||||
_TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;
|
||||
_TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;
|
||||
_TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;
|
||||
_TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;
|
||||
_TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
|
||||
_TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));
|
||||
__rodata_end = . ;
|
||||
|
||||
.eh_frame :
|
||||
{
|
||||
KEEP(*(.eh_frame))
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.gcc_except_table :
|
||||
{
|
||||
*(.gcc_except_table*)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.ctors :
|
||||
{
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is first.
|
||||
Because this is a wildcard, it doesn't matter
|
||||
if the user does not actually link against crtbegin.o;
|
||||
the linker won't look for a file to match a wildcard.
|
||||
The wildcard also means that it doesn't matter which
|
||||
directory crtbegin.o is in.
|
||||
*/
|
||||
KEEP(*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last
|
||||
*/
|
||||
KEEP(*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP(*(SORT(.ctors.*)))
|
||||
KEEP(*(.ctors))
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.dtors :
|
||||
{
|
||||
KEEP(*crtbegin.o(.dtors))
|
||||
KEEP(*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP(*(SORT(.dtors.*)))
|
||||
KEEP(*(.dtors))
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.jcr :
|
||||
{
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} =0xff
|
||||
__exidx_start = .;
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} =0xff
|
||||
__exidx_end = .;
|
||||
.preinit_array : {
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} =0xFF
|
||||
.init_array : {
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} =0xFF
|
||||
.fini_array : {
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} =0xFF
|
||||
|
||||
/*************************************************************************
|
||||
calculate __ro_end
|
||||
*************************************************************************/
|
||||
__ro_end = .;
|
||||
PROVIDE(__text_end__ = __ro_end );
|
||||
|
||||
/*** IWRAM ***/
|
||||
/*************************************************************************
|
||||
allocate iwram in __gba_iwram_start (0x03000000-0x03003FFF)
|
||||
*************************************************************************/
|
||||
__load_start_iwram = __ro_end;
|
||||
. = __gba_iwram_start ;
|
||||
__iwram_start = . ;
|
||||
PROVIDE(__iwram_start__ = . );
|
||||
.iwram : AT(__load_start_iwram)
|
||||
{
|
||||
/* put irq_vector_table in stat of iwram */
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
_irq_vector_table = .;
|
||||
PROVIDE(irq_vector_table = .);
|
||||
. += 4;
|
||||
. = ALIGN(16 * 4);
|
||||
PROVIDE(irq_vector_table_end = .);
|
||||
_irq_vector_table_end = .;
|
||||
*(.iwram .iwram.*)
|
||||
*.iwram.o (.text .rodata .data)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
__iwram_end = . ;
|
||||
PROVIDE(__iwram_end__ = . );
|
||||
__load_stop_iwram = __load_start_iwram + SIZEOF(.iwram);
|
||||
|
||||
_irq_vector_table_size = _irq_vector_table_end - _irq_vector_table;
|
||||
PROVIDE(_irq_max_vector = _irq_vector_table_size / 4 );
|
||||
|
||||
|
||||
/*** EWRAM ***/
|
||||
/*************************************************************************
|
||||
if 'multiboot' allocate prog+ewram in __gba_ewram
|
||||
else allocate only ewram in __gba_ewram_start
|
||||
*************************************************************************/
|
||||
. = DEFINED(__gba_multiboot) ? __load_stop_iwram : __gba_ewram_start ;
|
||||
__load_start_ewram = __load_stop_iwram;
|
||||
__ewram_start = . ;
|
||||
PROVIDE(__ewram_start__ = . );
|
||||
.ewram : AT(__load_start_ewram)
|
||||
{
|
||||
*(.ewram .ewram.*)
|
||||
*.ewram.o (.text .rodata .data)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
__ewram_end = . ;
|
||||
PROVIDE(__ewram_end__ = . );
|
||||
__load_stop_ewram = __load_start_ewram + SIZEOF(.ewram) ;
|
||||
|
||||
/*************************************************************************
|
||||
if 'multiboot' allocate prog+ewram+data+bss in __gba_ewram
|
||||
else if 'iwram_data' allocate data in __gba_iwram
|
||||
else allocate data in __gba_ewram
|
||||
*************************************************************************/
|
||||
. = DEFINED(__gba_multiboot) ? __load_stop_ewram : (DEFINED(__gba_iwram_data) ? __iwram_end : __ewram_end) ;
|
||||
__load_start_data = __load_stop_ewram;
|
||||
__data_start = . ;
|
||||
PROVIDE(__data_start__ = . );
|
||||
.data : AT(__load_start_data)
|
||||
{
|
||||
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
||||
*(EXCLUDE_FILE(*.rodata.* *.ewram.o *.iwram.o) .data)
|
||||
*(.data.* .gnu.linkonce.d.*)
|
||||
*(.data1)
|
||||
KEEP (*(SORT(.rtemsrwset.*)))
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
. = ALIGN(4);
|
||||
} =0xFF
|
||||
__data_end = . ;
|
||||
PROVIDE(__data_end__ = . );
|
||||
__load_stop_data = __load_start_data + SIZEOF(.data);
|
||||
|
||||
/*** BSS ***/
|
||||
/*************************************************************************
|
||||
if 'multiboot' allocate prog+ewram+data+bss in __gba_ewram
|
||||
else if 'iwram_data' and 'iwram_bss' allocate iwram+data+bss in __gba_iwram
|
||||
else if !'iwram_data' and 'iwram_bss' allocate iwram+bss in __gba_iwram
|
||||
else allocate data+ewram+bss in __gba_ewram
|
||||
*************************************************************************/
|
||||
. = DEFINED(__gba_multiboot) ? __load_stop_data : ( DEFINED(__gba_iwram_data) ? (DEFINED(__gba_iwram_bss) ? __data_end : __ewram_end) : (DEFINED(__gba_iwram_bss) ? __iwram_end : __data_end) ) ;
|
||||
__bss_start = . ;
|
||||
PROVIDE(__bss_start__ = . );
|
||||
.bss :
|
||||
{
|
||||
*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
|
||||
*(.tcommon)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
*(.bss .bss.* .gnu.linkonce.b*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
__bss_end = . ;
|
||||
PROVIDE(__bss_end__ = . );
|
||||
PROVIDE(_bss_end__ = . );
|
||||
|
||||
PROVIDE(_end = . );
|
||||
PROVIDE(__end__ = _end);
|
||||
PROVIDE(end = _end);
|
||||
|
||||
|
||||
/*** debugging info ***/
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* DWARF 3 */
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
/* DWARF extension */
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
|
||||
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
||||
}
|
||||
/* @endcond */
|
||||
@@ -1,134 +0,0 @@
|
||||
/**
|
||||
* @file timer.c
|
||||
*
|
||||
* GBA Timer driver.
|
||||
*/
|
||||
/*
|
||||
* RTEMS GBA BSP
|
||||
*
|
||||
* Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com>
|
||||
*
|
||||
* Copyright (c) 2004 Markku Puro <markku.puro@kopteri.net>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*
|
||||
*
|
||||
* Notes:
|
||||
* This file manages the benchmark timer used by the RTEMS Timing Test
|
||||
* Suite. Each measured time period is demarcated by calls to
|
||||
* benchmark_timer_initialize() and benchmark_timer_read(). benchmark_timer_read() usually returns
|
||||
* the number of microseconds since benchmark_timer_initialize() exitted.
|
||||
*
|
||||
* It is important that the timer start/stop overhead be determined
|
||||
* when porting or modifying this code.
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <rtems/btimer.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <gba.h>
|
||||
|
||||
/*
|
||||
* Set up the timer hardware
|
||||
* 1 / 16.78Mhz => 59.595 ns
|
||||
* 64 / 16.78Mhz => 3.814 us
|
||||
* 256 / 16.78Mhz => 15.256 us
|
||||
* 1024 / 16.78Mhz => 61.025 us
|
||||
*/
|
||||
#define __TimePreScaler 1
|
||||
#define __TickTime_ns ((1000000000L/__ClockFrequency)*__TimePreScaler)
|
||||
#define __TickTime_us ((1000000L/__ClockFrequency)*__TimePreScaler)
|
||||
|
||||
#if (__TimePreScaler==1)
|
||||
#define GBA_TM0CNT_PS 0x0000
|
||||
#elif (__TimePreScaler==64)
|
||||
#define GBA_TM0CNT_PS 0x0001
|
||||
#elif (__TimePreScaler==256)
|
||||
#define GBA_TM0CNT_PS 0x0002
|
||||
#elif (__TimePreScaler==1024)
|
||||
#define GBA_TM0CNT_PS 0x0003
|
||||
#else
|
||||
#define GBA_TM0CNT_PS 0x0003
|
||||
#endif
|
||||
|
||||
bool benchmark_timer_find_average_overhead;
|
||||
|
||||
/**
|
||||
* @brief benchmark_timer_initialize start TM0 and TM1
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void benchmark_timer_initialize( void )
|
||||
{
|
||||
GBA_REG_TM1CNT = 0x0000; /* Stop Counters */
|
||||
GBA_REG_TM0CNT = 0x0000;
|
||||
GBA_REG_TM1D = 0x0000; /* Reset Counters */
|
||||
GBA_REG_TM0D = 0x0000;
|
||||
/* Start Counters */
|
||||
GBA_REG_TM1CNT = 0x0084; /* Start Count Up timing */
|
||||
GBA_REG_TM0CNT = (0x0080|GBA_TM0CNT_PS); /* Start Count */
|
||||
}
|
||||
|
||||
/*
|
||||
* The following controls the behavior of benchmark_timer_read().
|
||||
*
|
||||
* AVG_OVEREHAD is the overhead for starting and stopping the timer. It
|
||||
* is usually deducted from the number returned.
|
||||
*
|
||||
* LEAST_VALID is the lowest number this routine should trust. Numbers
|
||||
* below this are "noise" and zero is returned.
|
||||
*/
|
||||
|
||||
#define AVG_OVERHEAD 3 /**< It typically takes 3 microseconds */
|
||||
#define LEAST_VALID 1 /**< Don't trust a clicks value lower than this */
|
||||
|
||||
/**
|
||||
* @brief benchmark_timer_read return timer countervalue in microseconds.
|
||||
*
|
||||
* Used in Timing Test Suite.
|
||||
*
|
||||
* @param None
|
||||
* @return Timer value in microseconds
|
||||
*/
|
||||
benchmark_timer_t benchmark_timer_read( void )
|
||||
{
|
||||
uint32_t ticks;
|
||||
uint32_t total;
|
||||
|
||||
/* Stop Counters */
|
||||
GBA_REG_TM0CNT = 0x0000;
|
||||
GBA_REG_TM1CNT = 0x0000;
|
||||
/* Read Counters */
|
||||
ticks = (GBA_REG_TM1D<<16) | GBA_REG_TM0D;
|
||||
if ( ticks < LEAST_VALID ) {
|
||||
return 0; /* below timer resolution */
|
||||
}
|
||||
/* convert to uS */
|
||||
total = ((ticks * __TickTime_ns) / 1000);
|
||||
if ( benchmark_timer_find_average_overhead == true ) {
|
||||
return total; /* in microseconds */
|
||||
}
|
||||
else {
|
||||
if ( total < AVG_OVERHEAD ) {
|
||||
return 0;
|
||||
}
|
||||
return (total - AVG_OVERHEAD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set benchmark_timer_find_average_overhead flag.
|
||||
*
|
||||
* Used in Timing Test Suite.
|
||||
*
|
||||
* @param find_flag bool find_flag
|
||||
* @return None
|
||||
*/
|
||||
void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
|
||||
{
|
||||
benchmark_timer_find_average_overhead = find_flag;
|
||||
}
|
||||
Reference in New Issue
Block a user