### A.6 Led control sample

    /*
     * leds.h -- control the led's on a Motorola mc68ec0x0 board.
     */

    #ifndef __LEDS_H__
    #define __LEDS_H__

    #define LED_ADDR	0xd00003
    #define LED_0           ~0x1
    #define LED_1           ~0x2
    #define LED_2           ~0x4
    #define LED_3           ~0x8
    #define LED_4           ~0x10
    #define LED_5           ~0x20
    #define LED_6           ~0x40
    #define LED_7           ~0x80
    #define LEDS_OFF	0xff
    #define LEDS_ON		0x0

    #define FUDGE(x) ((x >= 0xa && x <= 0xf) ? (x + 'a') & 0x7f : (x + '0') & 0x7f)

    extern void led_putnum( char );

    #endif		/* __LEDS_H__ */

    /*
     * leds.c -- control the led's on a Motorola mc68ec0x0 (IDP)board.
     */
    #include "leds.h"

    void zylons();
    void led_putnum();

    /*
     * led_putnum -- print a hex number on the LED. the value of num must be a char with
     *              the ascii value. ie... number 0 is '0', a is 'a', ' ' (null) clears
     *		the led display.
     *		Setting the bit to 0 turns it on, 1 turns it off.
     * 		the LED's are controlled by setting the right bit mask in the base
     * 		address.
     *		The bits are:
     *			[d.p | g | f | e | d | c | b | a ] is the byte.
     *
     *		The locations are:
     *
     *			 a
     *		       -----
     *		    f |     | b
     *		      |  g  |
     *		       -----
     *                    |     |
     *                  e |     | c
     *                     -----
     *                       d                . d.p (decimal point)
     */
    void
    led_putnum ( num )
    char num;
    {
        static unsigned char *leds = (unsigned char *)LED_ADDR;
        static unsigned char num_bits [18] = {
          0xff,						/* clear all */
          0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, /* numbers 0-9 */
          0x98, 0x20, 0x3, 0x27, 0x21, 0x4, 0xe 		/* letters a-f */
        };

        if (num >= '0' && num <= '9')
          num = (num - '0') + 1;

        if (num >= 'a' && num <= 'f')
          num = (num - 'a') + 12;

        if (num == ' ')
          num = 0;

        *leds = num_bits[num];
    }

    /*
     * zylons -- draw a rotating pattern. NOTE: this function never returns.
     */
    void
    zylons()
    {
      unsigned char *leds 	= (unsigned char *)LED_ADDR;
      unsigned char curled = 0xfe;

      while (1)
        {
          *leds = curled;
          curled = (curled >> 1) | (curled << 7);
          delay ( 200 );
        }
    }

## Table of Contents

- 1 Libgloss
  - 1.1 Supported Targets
    - 1.1.1 Sparclite Targets Supported
    - 1.1.2 Motorola CPU32 Targets supported
    - 1.1.3 Mips core Targets Supported
    - 1.1.4 PA-RISC Targets Supported
  - 1.2 Configuring and building libgloss.
  - 1.3 Adding Support for a New Board
- 2 Porting GCC
  - 2.1 Compilation passes
- 3 Porting newlib
  - 3.1 Crt0, the main startup file
  - 3.2 Linker scripts for memory management
  - 3.3 What to do when you have a binary image
  - 3.4 Libraries
    - 3.4.1 Making I/O work
    - 3.4.2 Routines for dynamic memory allocation
    - 3.4.3 Misc support routines
    - 3.4.4 Useful debugging functions
- 4 Writing a new GDB backend
  - 4.1 The standard remote protocol
  - 4.2 A linked in exception handler
  - 4.3 Using a ROM monitor as a backend
  - 4.4 Adding support for new protocols
- Appendix A Code Listings
  - A.1 Linker script for the IDP board
  - A.2 crt0.S - The startup file
  - A.3 C based "glue" code.
  - A.4 I/O assembler code sample
  - A.5 I/O code sample
  - A.6 Led control sample