Open Issues:
======================================================================
-* Some commands could default to the "last used address" so that for
- instance a "bootp" could be followed by a plain "iminfo" or "bootm"
- (without arguments) using the memory address used by the previous
- (here bootp) command.
-
* Boot with RAMDisk:
No need to copy ramdisk image when it's already in RAM ??? Or do we
No need to copy ramdisk image when it's in Flash/ROM ...
-* Network Code:
-
- After booting over BOOTP / RARP, any new network configuration
- parameters like IP-Address, Server Address, ... should be
- automatically stored in the environment for later use by the Linux
- (or other RTOS) kernel and/or processes.
-
* Timer:
don't use 'lr RX, const; mtdec RX" -> use:
Fix Exception handling for "Software Emulation Exception" etc.
======================================================================
-Modifications since 0.5.3:
+To do:
======================================================================
+* Video extensions support (to pass framebuffer information to
+ applications and linux kernel)
+
+* "last user address" is set even if bootp is used without parameters
+ (and it uses default address).
+
+======================================================================
+Modifications for 0.6.0:
+======================================================================
+
+* Shifted all CFG_CMD_* definitions to a new include file
+ "include/cmd_confdefs.h", which must be included in the
+ include/config_xxx.h file after any definition of CONFIG_COMMANDS
+ (because it defines CONFIG_COMMAND if it isn't defined already),
+ but before testing the value of CONFIG_COMMANDS in any #ifs.
+
+* Fixed Cogent support.
+
+* To allow for platform specific make options, we added two new make
+ variables: PLATFORM_RELFLAGS and PLATFORM_CPPFLAGS. They are
+ initially set empty, and are included in the definitions of
+ RELFLAGS and CPPFLAGS in the top level config.mk file. After making
+ this change, it no longer made sense to have things like #ifdef
+ CONFIG_8xx or CONFIG_4xx etc in the top level config.mk file - so I
+ moved each of the platform dependent flags into the various
+ subdirectory config.mk files.
+
+* Modified Makefiles (hard wired lib names; avoi unnecessary sub
+ directory builds)
+
+* Replaced CFG_FLASH_BASE by CFG_MONITOR_BASE when dealing with the
+ location of the monitor code for systems that boot from EPROM, but
+ have FLASH somewhere else.
+
+* Added CFG_FLASH_ENV_ADDR for systems where monitor and environment
+ are in different memory regions.
+
+* Added CFG_FLASH_ENV_BUF for systems with very large flash sectors,
+ where you cannot reserve a whole sector for the environment (well,
+ you could store the Linux kernel as environemnt variable then :-)
+
+* Added watchdog support (this will need sppropiate changes in the
+ Linux kernel, too!)
+
+* Added command to boot from a partition on an IDE device
+
+* Improved IDE support
+
+* Added support for MacOS / LinuxPPC compatible partitions on IDE
+ devices
+
+* Added support for MBX8xx boards (unfinished, work in progress!
+ - thanks to Marius Gröger)
+
+* Added list handling into 'common/list.c'
+
+* Added devices support into 'common/devices.c' (now used to install
+ console devices and redirect stdin, stdout and stderr)
+
+* Detected keypress while showing the help
+
+* Minimized the console structures
+
+* Use a dynamic way to redirect the console input, output and error
+ using environment variables (stdin, stdout, stderr). The list of
+ available console devices is printed using the 'coninfo' command.
+ Supported console drivers are "serial" (buildin) & "video". Who
+ want to add the LCD console driver? Read the README.CONSOLE for
+ more infos.
+
+* Some commands default to the "last used address" so that for
+ instance a "bootp" could be followed by a plain "iminfo" or "bootm"
+ (without arguments) using the memory address used by the previous
+ (here bootp) command.
+
+* Rewrite the commandline parser (added a 'repeatable' field to the
+ command structure)
+
+* The command separator ';' now can be used in interactive commands,
+ too
+
+* Changed console support to use a global variable that points to the
+ bd_t structure instead of old bi_mon_fnc_ptr. All console functions
+ called before relocation will be replaced with the serial functions
+ on linking.
+
+* Now printenv prints environment size, too
+
+* Added BOOTP environment variables (when received)
+
+* Added bash-like MACRO support using the syntax "$(envname)". Then
+ you can boot the linux kernel by using this simple command:
+
+ bootp; setenv bootargs root=/dev/nfs nfsroot=$(serverip): \
+ $(rootpath) ip=$(ipaddr):$(serverip):$(gatewayip):$(subnetmask): \
+ $(hostname):eth0:off; bootm
+
+* Extended BOOTP features. Now we have more network parameters from
+ the server in net/net.c: subnet mask, gateways ip, NIS domain,
+ hostname, bootfile size & root path. More can be added by looking
+ at the RFC1048.
+
+* Added tab emulation on video_putc.
+
+* Fixed FADS823 pcmcia support. Changed PCMCIA driver to support 3.3V
+ pcmcia cards on the 5V keyed socket.
+
+* Added a custom board configuration (GENIETV).
+
+* Added AD7177 video encoder support.
+
+* Added NTSC support to video controller (untested).
+
+* Added putc, getc, puts and tstc functions.
+
+* Hacked a bug into /tools/easylogo.c
+
* Some changes to CPCI405 code (by Stefan Roese): added
CONFIG_NVRAM_ENV so that environment variables are no longer in
flash, but in NVRAM (this needs some more defines like base address
E: ddickey@charter.net
D: FADS Support
+N: Marius Groeger
+E: mgroeger@sysgo.de
+D: MBX Support, board specific function interface
+W: www.elinos.com
+
N: Kirk Haderlie
E: khaderlie@vividimage.com
D: Added TFTP to 8xxrom (-> 0.3.1)
--- /dev/null
+#!/bin/sh
+
+[ -d LOG ] || mkdir LOG
+
+set -x
+
+for i in TQM823L TQM850L TQM855L TQM860L FPS850L \
+ ETX094 SPD823TS \
+ FADS823 FADS850SAR FADS860T \
+ CPCI405 ADCIOP \
+ cogent_mpc8xx \
+ GENIETV
+
+do
+ make distclean >/dev/null
+ make ${i}_config
+ make all 2>&1 >LOG/$i.MAKELOG | tee LOG/$i.ERR
+ powerpc-linux-size ppcboot | tee -a LOG/$i.MAKELOG
+done
#########################################################################
-all: ppcboot.srec
+all: ppcboot.srec ppcboot.bin
install: all
#cp ppcboot.srec /tftpboot/moni.srec
ppcboot.bin: ppcboot
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
-ppcboot: depend $(SUBDIRS) $(OBJS) $(LDSCRIPT)
+ppcboot: depend subdirs $(OBJS) $(LDSCRIPT)
$(LD) $(LDFLAGS) $(OBJS) -Map ppcboot.map -o ppcboot
-$(SUBDIRS): dummy
+subdirs:
@for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir || exit 1 ; done
-dummy:
-
depend dep:
@for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir .depend ; done
echo "CPU = mpc8xx" >>config.mk ; \
echo "#include <config_$(@:_config=).h>" >config.h
+GENIETV_config: unconfig
+ @echo "Configuring for $(@:_config=) Board..." ; \
+ cd include ; \
+ echo "ARCH = ppc" > config.mk ; \
+ echo "BOARD = genietv" >>config.mk ; \
+ echo "CPU = mpc8xx" >>config.mk ; \
+ echo "#include <config_$(@:_config=).h>" >config.h
+
+MBX_config: unconfig
+ @echo "Configuring for $(@:_config=) Board..." ; \
+ cd include ; \
+ echo "ARCH = ppc" > config.mk ; \
+ echo "BOARD = mbx8xx" >>config.mk ; \
+ echo "CPU = mpc8xx" >>config.mk ; \
+ echo "#include <config_$(@:_config=).h>" >config.h
+
#########################################################################
clean:
\( -name 'core' -o -name '*.bak' \
-o -name '*.o' -o -name '*.a' \) -print`
rm -f examples/{hello_world,timer}
- rm -f tools/{img2srec,mkimage}
+ rm -f tools/{img2srec,mkimage,easylogo/easylogo}
+ rm -f tools/gdb/{astest,gdbcont,gdbsend}
clobber: clean
rm -f `find . -type f \
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+PPCBOOT console handling
+========================
+
+HOW THE CONSOLE WORKS?
+----------------------
+
+At system startup PPCBOOT initializes a serial console. When PPCBOOT relocates
+itself to RAM, all console drivers are initialized (they will register all
+detected console devices to the system for further use).
+
+The first input device is assigned to the 'stdin' file, the first output one to
+'stdout' and 'stderr'.
+
+In the prompt you can use the command 'coninfo' to see all registered console
+devices and its flags. You can assign a standard file (stdin, stdout or stderr)
+to any device you see in that list simply assigning to the relative environment
+variable its name. For example:
+
+ setenv stdin wl_kbd <- To use the wireless keyboard
+ setenv stdout video <- To use the video console
+
+HOW CAN I USE STANDARD FILE INTO THE SOURCES?
+---------------------------------------------
+
+You can use these functions to access the console:
+
+* STDOUT:
+ putc (to put a char to stdout)
+ puts (to put a string to stdout)
+ printf (to format and put a string to stdout)
+
+* STDIN:
+ tstc (to test the presence of a char in the stdin)
+ getc (to get a char from stdin)
+
+* STDERR:
+ eputc (to put a char to the stderr)
+ eputs (to put a string to the stderr)
+ eprintf (to format and put a string to stderr)
+
+* FILE (can be 'stdin', 'stdout', 'stderr'):
+ fputc (like putc but redirected to a file)
+ fputs (like puts but redirected to a file)
+ fprintf (like printf but redirected to a file)
+ ftstc (like tstc but redirected to a file)
+ fgetc (like getc but redirected to a file)
+
+Remember that all FILE-relative functions CANNOT be used before PPCBOOT
+relocation (done in 'board_init_r' into common/board.c).
+
+SUPPORTED DRIVERS
+-----------------
+
+Working: serial (architecture dependent serial stuff)
+ video (mpc8xx video controller)
+
+WIP: wl_kbd (Wireless 4PPM keyboard)
+
+To do: lcd (mpc8xx lcd controller)
\ No newline at end of file
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+PPCBOOT MPC8xx video controller driver
+======================================
+
+The driver has been tested with these configurations:
+
+- MPC823FADS with AD7176 on a PAL TV (YCbYCr)
+- GENIETV with AD7177 on a PAL TV (YCbYCr)
}
for ( ; s<e; ++s) {
- serial_putc (*s);
+ putc (*s);
}
- serial_putc ('\n');
+ putc ('\n');
return (l_type);
}
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
}
}
void
-serial_putstr(const char *s)
+serial_puts(const char *s)
{
while (*s != '\0')
serial_putc(*s++);
*/
void
-flash_erase(flash_info_t *info, int s_first, int s_last, bd_t *bd)
+flash_erase(flash_info_t *info, int s_first, int s_last)
{
int flag, prot, sect, errcount;
ulong start, now, last;
enable_interrupts();
/* wait at least 80us - let's wait 1 ms */
- udelay (1000, bd->bi_intfreq);
+ udelay (1000);
start = get_timer (0);
last = 0;
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
enable_interrupts();
/* wait at least 80us - let's wait 1 ms */
- udelay (1000, bd->bi_intfreq);
+ udelay (1000);
estart = get_timer(start);
#ifndef FLASH_DEBUG
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
#endif
/* show that we're waiting */
now = get_timer(start);
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
}
AOBJS = environment.o
endif
COBJS = board.o main.o command.o \
- cmd_cache.o cmd_mem.o cmd_boot.o cmd_flash.o \
- cmd_bootm.o cmd_ide.o cmd_net.o cmd_nvedit.o \
- s_record.o dlmalloc.o kgdb.o
+ cmd_boot.o cmd_bootm.o cmd_cache.o \
+ cmd_console.o cmd_flash.o cmd_ide.o \
+ cmd_mem.o cmd_net.o cmd_nvedit.o \
+ s_record.o dlmalloc.o kgdb.o \
+ console.o lists.o devices.o
+
OBJS = $(AOBJS) $(COBJS)
CPPFLAGS += -I..
ip <<= 8;
}
printf ("\n baudrate = %6ld bps\n", bd->bi_baudrate );
- printf (" getc = 0x%08lx\n",(ulong)bd->bi_mon_fnc.getc);
- printf (" tstc = 0x%08lx\n",(ulong)bd->bi_mon_fnc.tstc);
- printf (" putc = 0x%08lx\n",(ulong)bd->bi_mon_fnc.putc);
- printf (" putstr = 0x%08lx\n",(ulong)bd->bi_mon_fnc.putstr);
- printf (" printf = 0x%08lx\n",(ulong)bd->bi_mon_fnc.printf);
- printf (" install_hdlr= 0x%08lx\n",(ulong)bd->bi_mon_fnc.install_hdlr);
- printf (" free_hdlr = 0x%08lx\n",(ulong)bd->bi_mon_fnc.free_hdlr);
- printf (" malloc = 0x%08lx\n",(ulong)bd->bi_mon_fnc.malloc);
- printf (" free = 0x%08lx\n",(ulong)bd->bi_mon_fnc.free);
+ printf (" getc = 0x%08lx\n",(ulong)bd->bi_mon_fnc->getc);
+ printf (" tstc = 0x%08lx\n",(ulong)bd->bi_mon_fnc->tstc);
+ printf (" putc = 0x%08lx\n",(ulong)bd->bi_mon_fnc->putc);
+ printf (" puts = 0x%08lx\n",(ulong)bd->bi_mon_fnc->puts);
+ printf (" printf = 0x%08lx\n",(ulong)bd->bi_mon_fnc->printf);
+ printf (" install_hdlr= 0x%08lx\n",(ulong)bd->bi_mon_fnc->install_hdlr);
+ printf (" free_hdlr = 0x%08lx\n",(ulong)bd->bi_mon_fnc->free_hdlr);
+ printf (" malloc = 0x%08lx\n",(ulong)bd->bi_mon_fnc->malloc);
+ printf (" free = 0x%08lx\n",(ulong)bd->bi_mon_fnc->free);
}
#endif /* CFG_CMD_BDI */
}
#endif /* CFG_LOADS_BAUD_CHANGE */
- command_repeat_off();
-
#ifdef CFG_LOADS_BAUD_CHANGE
if (loads_baudrate != bd->bi_baudrate) {
printf ("## Switch baudrate to %d bps and press ENTER ...\n",
serial_setbrg (bd->bi_intfreq, loads_baudrate);
udelay(50000);
for (;;) {
- if (serial_getc() == '\r')
+ if (getc() == '\r')
break;
}
}
serial_setbrg (bd->bi_intfreq, bd->bi_baudrate);
udelay (50000);
for (;;) {
- if (serial_getc() == 0x1B) /* ESC */
+ if (getc() == 0x1B) /* ESC */
break;
}
}
}
if (!do_echo) { /* print a '.' every 100 lines */
if ((++line_count % 100) == 0)
- serial_putc ('.');
+ putc ('.');
}
}
default:
*p = c;
}
+
+ // Check for the console hangup (if any different from serial)
+
+ if (bd_ptr->bi_mon_fnc->getc != serial_getc)
+ {
+ if (tstc())
+ {
+ switch (getc()){
+ case '\0':
+ case 0x03: /* ^C - Control C */
+ return (-1);
+ }
+ }
+ }
}
/* line too long - truncate */
loadb_baudrate = bd->bi_baudrate;
}
- command_repeat_off();
-
if (loadb_baudrate != bd->bi_baudrate) {
printf ("## Switch baudrate to %d bps and press ENTER ...\n",
loadb_baudrate);
serial_setbrg (bd->bi_intfreq, loadb_baudrate);
udelay(50000);
for (;;) {
- if (serial_getc() == '\r')
+ if (getc() == '\r')
break;
}
}
serial_setbrg (bd->bi_intfreq, bd->bi_baudrate);
udelay (50000);
for (;;) {
- if (serial_getc() == 0x1B) /* ESC */
+ if (getc() == 0x1B) /* ESC */
break;
}
}
#include <zlib.h>
int gunzip (void *, int, unsigned char *, int *);
-void run_default_command (int l, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
+void run_default_command (int len, cmd_tbl_t *cmdtp, bd_t *bd, int flag);
static void *zalloc(void *, unsigned, unsigned);
static void zfree(void *, void *, unsigned);
-static void print_header (image_header_t *hdr);
static void print_type (image_header_t *hdr);
image_header_t header;
}
/* for multi-file images we need the data part, too */
- print_header ((image_header_t *)addr);
+ print_image_hdr ((image_header_t *)addr);
data = addr + sizeof(image_header_t);
len = hdr->ih_size;
do_reset (cmdtp, bd, flag, argc, argv);
}
- print_header (hdr);
+ print_image_hdr (hdr);
data = addr + sizeof(image_header_t);
len = hdr->ih_size;
if (verify) {
+ ulong csum = 0;
+#if defined(CONFIG_WATCHDOG)
+ ulong cdata = data, edata = cdata + len;
+#endif /* CONFIG_WATCHDOG */
+
printf (" Verifying Checksum ... ");
- if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) {
+
+#if defined(CONFIG_WATCHDOG)
+# define CHUNKSZ (64 * 1024)
+
+ while (cdata < edata) {
+ ulong chunk = edata - cdata;
+
+ if (chunk > CHUNKSZ)
+ chunk = CHUNKSZ;
+ csum = crc32 (csum, (char *)cdata, chunk);
+ cdata += chunk;
+ watchdog_reset();
+ }
+#else /* !CONFIG_WATCHDOG */
+ csum = crc32 (0, (char *)data, len);
+#endif /* CONFIG_WATCHDOG */
+
+ if (csum != hdr->ih_dcrc) {
printf ("Bad Data CRC\n");
do_reset (cmdtp, bd, flag, argc, argv);
}
}
/* for multi-file images we need the data part, too */
- print_header ((image_header_t *)addr);
+ print_image_hdr ((image_header_t *)addr);
data = addr + sizeof(image_header_t);
len = hdr->ih_size;
}
#endif /* CFG_CMD_IMI */
-static void
-print_header (image_header_t *hdr)
+void
+print_image_hdr (image_header_t *hdr)
{
/* time_t timestamp = (time_t)hdr->ih_time; */
s.zalloc = zalloc;
s.zfree = zfree;
+#if defined(CONFIG_WATCHDOG)
+ s.outcb = (cb_func)watchdog_reset;
+#else
+ s.outcb = Z_NULL;
+#endif /* CONFIG_WATCHDOG */
+
r = inflateInit2(&s, -MAX_WBITS);
if (r != Z_OK) {
printf ("Error: inflateInit2() returned %d\n", r);
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Boot support
+ */
+#include <ppcboot.h>
+#include <command.h>
+#include <devices.h>
+
+#if (CONFIG_COMMANDS & CFG_CMD_CONSOLE)
+
+extern void _do_coninfo (void) ;
+
+void do_coninfo (cmd_tbl_t *cmd, bd_t *bd, int flag, int argc, char *argv[])
+{
+ int i,l ;
+
+ // Scan for valid output and input devices
+
+ printf("List of available devices:\n");
+
+ for (i=1; i<=ListNumItems(devlist); i++)
+ {
+ device_t *dev = ListGetPtrToItem (devlist, i);
+
+ printf("%-8s %08x %c%c%c ",
+ dev->name,
+ dev->flags,
+ (dev->flags & DEV_FLAGS_SYSTEM) ? 'S' : '.',
+ (dev->flags & DEV_FLAGS_INPUT) ? 'I' : '.',
+ (dev->flags & DEV_FLAGS_OUTPUT) ? 'O' : '.'
+ );
+
+ for (l=0 ; l< MAX_FILES; l++)
+ if (stdio_devices[l] == dev)
+ printf("%s ", stdio_names[l]);
+
+ putc('\n');
+ }
+}
+
+#endif /* CFG_CMD_CONSOLE */
#include <mpc8xx_irq.h>
#include <ppcboot.h>
#include <command.h>
+#include <image.h>
#include <ide.h>
#include <ata.h>
#include <cmd_ide.h>
+#include <cmd_disk.h>
#include <mpc8xx.h>
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
static void input_data(int dev, ulong *sect_buf, int words);
static void output_data(int dev, ulong *sect_buf, int words);
static void trim_trail (unsigned char *str, unsigned int len);
+
/* ------------------------------------------------------------------------- */
void do_ide (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
printf ("Usage:\n%s\n", cmdtp->usage);
return;
case 2:
- if (strcmp(argv[1],"reset") == 0) {
+ if (strncmp(argv[1],"res",3) == 0) {
printf ("\nReset IDE on PCMCIA " PCMCIA_SLOT_MSG ": ");
ide_init();
return;
- } else if (strcmp(argv[1],"info") == 0) {
+ } else if (strncmp(argv[1],"inf",3) == 0) {
int i;
printf ("\n");
}
return;
- } else if (strcmp(argv[1],"device") == 0) {
+ } else if (strncmp(argv[1],"dev",3) == 0) {
if ((curr_device < 0) || (curr_device >= IDE_MAXDEVICE)) {
printf ("\nno IDE devices available\n");
return;
printf ("\nIDE device %d: ", curr_device);
ide_print (curr_device);
return;
+ } else if (strncmp(argv[1],"part",4) == 0) {
+ int dev, ok;
+
+ for (ok=0, dev=0; dev<IDE_MAXDEVICE; ++dev) {
+ if (ide_device[dev].size) {
+ ++ok;
+ if (dev)
+ printf ("\n");
+ print_part_mac (dev);
+ }
+ }
+ if (!ok)
+ printf ("\nno IDE devices available\n");
+ return;
}
printf ("Usage:\n%s\n", cmdtp->usage);
return;
case 3:
- if (strcmp(argv[1],"device") == 0) {
+ if (strncmp(argv[1],"dev",3) == 0) {
int dev = (int)simple_strtoul(argv[2], NULL, 10);
printf ("\nIDE device %d: ", dev);
printf ("... is now current device\n");
+ return;
+ } else if (strncmp(argv[1],"part",4) == 0) {
+ int dev = (int)simple_strtoul(argv[2], NULL, 10);
+
+ if (ide_device[dev].size) {
+ print_part_mac (dev);
+ } else {
+ printf ("\nIDE device %d not available\n", dev);
+ }
return;
}
+
printf ("Usage:\n%s\n", cmdtp->usage);
return;
default:
}
}
+void do_diskboot (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+ char *boot_device = NULL;
+ char *ep;
+ int dev, part;
+ ulong cnt;
+ ulong addr;
+ disk_partition_t info;
+ image_header_t *hdr;
+
+ switch (argc) {
+ case 1:
+ addr = CFG_TFTP_LOADADDR;
+ boot_device = getenv ("bootdevice");
+ break;
+ case 2:
+ addr = simple_strtoul(argv[1], NULL, 16);
+ boot_device = getenv ("bootdevice");
+ break;
+ case 3:
+ addr = simple_strtoul(argv[1], NULL, 16);
+ boot_device = argv[2];
+ break;
+ default:
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return;
+ }
+
+ if (!boot_device) {
+ printf ("\n** No boot device **\n");
+ return;
+ }
+
+ dev = simple_strtoul(boot_device, &ep, 16);
+
+ if (ide_device[dev].size == 0) {
+ printf ("\n** Device %d not available\n", dev);
+ return;
+ }
+
+ if (*ep) {
+ if (*ep != ':') {
+ printf ("\n** Invalid boot device, use `dev[:part]' **\n");
+ return;
+ }
+ part = simple_strtoul(++ep, NULL, 16);
+ }
+
+ if (get_partition_info (dev, part, &info)) {
+ return;
+ }
+
+ if (strncmp(info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) {
+ printf ("\n** Invalid partition type \"%.32s\""
+ " (expect \"" BOOT_PART_TYPE "\")\n",
+ info.type);
+ return;
+ }
+
+ printf ("\nLoading from IDE device %d, partition %d: "
+ "Name: %.32s Type: %.32s\n",
+ dev, part, info.name, info.type);
+#ifdef DEBUG
+ printf ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
+ info.start, info.size, info.blksz);
+#endif
+
+ if (ide_read (dev, info.start, 1, (ulong *)addr) != 1) {
+ printf ("** Read error on %d:%d\n", dev, part);
+ return;
+ }
+
+ hdr = (image_header_t *)addr;
+
+ if (hdr->ih_magic == IH_MAGIC) {
+
+ print_image_hdr (hdr);
+
+ cnt = (hdr->ih_size + sizeof(image_header_t));
+ cnt += info.blksz - 1;
+ cnt /= info.blksz;
+ cnt -= 1;
+ } else {
+ cnt = info.size - 1;
+ }
+
+ if (ide_read (dev, info.start+1, cnt,
+ (ulong *)(addr+info.blksz)) != cnt) {
+ printf ("** Read error on %d:%d\n", dev, part);
+ return;
+ }
+
+
+ /* Loading ok, check if we should attempt an auto-start */
+ if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
+ char *local_args[3];
+ char local_str[32];
+ extern void do_bootm (cmd_tbl_t *, bd_t *, int, int, char *[]);
+
+ sprintf (local_str, "%lX", addr);
+ local_args[0] = argv[0];
+ local_args[1] = local_str;
+ local_args[2] = NULL;
+
+ printf ("Automatic boot of image at addr 0x%08lX ...\n",
+ addr);
+
+ do_bootm (cmdtp, bd, 0, 2, local_args);
+ }
+}
+
/* ------------------------------------------------------------------------- */
void ide_init (void)
if ((i >= 100) && ((i%100)==0)) {
printf (".");
}
- } while (c & (ATA_STAT_BUSY | ATA_STAT_FAULT));
+ } while (c & ATA_STAT_BUSY);
if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) {
- printf ("Status: 0x%02x ", c);
+ printf ("Status 0x%02x ", c);
} else if ((c & ATA_STAT_READY) == 0) {
printf ("not available ");
} else {
/* assert IDE RESET signal */
immr->im_ioport.iop_pcdat &= ~(PC_IDE_RESET);
- udelay (1000);
+ udelay (20000);
/* de-assert RESET signal of IDE */
immr->im_ioport.iop_pcdat |= PC_IDE_RESET;
- udelay (20000);
+ udelay (100000);
}
/* ------------------------------------------------------------------------- */
static void netboot_common (int, cmd_tbl_t *, bd_t *, int , char *[]);
-
void do_bootp (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
netboot_common (BOOTP, cmdtp, bd, argc, argv);
netboot_common (RARP, cmdtp, bd, argc, argv);
}
+static void netboot_update_env(void)
+{
+ char tmp[12] ;
+
+ if (NetOurGatewaysNum) {
+ NetIPaddr (NetOurGatewaysIP[0], tmp);
+ setenv("gatewayip", tmp);
+ }
+
+ if (NetOurSubnetMask) {
+ NetIPaddr (NetOurSubnetMask, tmp);
+ setenv("subnetmask", tmp);
+ }
+
+ if (NetOurHostName[0])
+ setenv("hostname", NetOurHostName);
+
+ if (NetOurRootPath[0])
+ setenv("rootpath", NetOurRootPath);
+
+ if (NetOurIP) {
+ NetIPaddr (NetOurIP, tmp);
+ setenv("ipaddr", tmp);
+ }
+
+ if (NetServerIP) {
+ NetIPaddr (NetServerIP, tmp);
+ setenv("serverip", tmp);
+ }
+}
+
static void
netboot_common (int proto, cmd_tbl_t *cmdtp, bd_t *bd, int argc, char *argv[])
{
}
if (rc == 0)
- return;
-
+ return;
+ else
+ netboot_update_env();
+
/* Loading ok, check if we should attempt an auto-start */
if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) {
char *local_args[3];
printf ("Automatic boot of image at addr 0x%08lX ...\n",
TftpLoadAddress);
-
+
do_bootm (cmdtp, bd, 0, 2, local_args);
}
}
uchar *environment = (uchar *)CFG_NVRAM_VAR_ADDR;
ulong env_size = CFG_NVRAM_ENV_SIZE;
#else
+
+#if defined(CFG_FLASH_ENV_ADDR)
+static uchar environment[CFG_FLASH_ENV_SIZE];
+static ulong env_size = CFG_FLASH_ENV_SIZE;
+
+/* need both ENV and flash */
+#if ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == (CFG_CMD_ENV|CFG_CMD_FLASH))
+static uchar *flash_addr = (uchar *)CFG_FLASH_ENV_ADDR;
+#endif /* ENV, FLASH */
+
+/*
+ * the contents of the rom_addr pointer will not change when the monitor
+ * is relocated into RAM and so will contain the old address of the
+ * environment[] array in flash, but the environment[] array itself *will*
+ * be relocated. Hence, we can tell whether the monitor has been relocated
+ * by comparing the value of rom_addr with environment.
+ */
+static uchar *rom_addr = environment;
+
+#define ISVALID(p) (crc32(0, (char *)(p), env_size - sizeof (ulong)) == \
+ *(ulong *)((char *)(p) + env_size - sizeof (ulong)))
+#define MAKEVALID(p, s) (*(ulong *)((char *)(p) + (s) - sizeof (ulong)) = \
+ crc32(0, (char *)(p), (s) - sizeof (ulong)))
+
+#else /* CFG_FLASH_ENV_ADDR */
extern uchar environment[];
extern ulong env_size;
#if ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == (CFG_CMD_ENV|CFG_CMD_FLASH))
static uchar *flash_addr = environment;
#endif /* ENV, FLASH */
+#endif /* CFG_FLASH_ENV_ADDR */
#endif /* NVRAM_ENV */
static uchar *envmatch (uchar *, uchar *);
+#if defined(CFG_FLASH_ENV_ADDR)
+static uchar *env_init(void);
+#else
static void env_init(void);
+#endif /* CFG_FLASH_ENV_ADDR */
#define XMK_STR(x) #x
#define MK_STR(x) XMK_STR(x)
{
uchar *env, *nxt;
+#if defined(CFG_FLASH_ENV_ADDR)
+ uchar *environment = env_init();
+#else
env_init();
+#endif /* CFG_FLASH_ENV_ADDR */
for (env=environment; *env; env=nxt+1) {
char *val;
uchar *env, *nxt;
int i;
+#if defined(CFG_FLASH_ENV_ADDR)
+ uchar *environment = env_init();
+#else
env_init();
+#endif /* CFG_FLASH_ENV_ADDR */
if (argc == 1) { /* Print all env variables */
+ uchar *start = environment;
for (env=environment; *env; env=nxt+1) {
for (nxt=env; *nxt; ++nxt)
;
- serial_putstr (env);
- serial_putc ('\n');
+ puts (env);
+ putc ('\n');
+
+ if (tstc()) {
+ getc ();
+ printf ("\n ** Abort\n");
+ return;
+ }
}
+
+ printf("\nEnvironment size: %d bytes\n", env-start);
+
return;
}
;
val=envmatch(name, env);
if (val) {
- serial_putstr (name);
- serial_putc ('=');
- serial_putstr (val);
- serial_putc ('\n');
+ puts (name);
+ putc ('=');
+ puts (val);
+ putc ('\n');
break;
}
}
}
}
-void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+void _do_setenv (bd_t *bd, int flag, int argc, char *argv[])
{
- int i, len;
+ int i, len;
+ int console = -1;
uchar *env, *nxt;
uchar *oldval = NULL;
uchar *name;
+#if defined(CFG_FLASH_ENV_ADDR)
+ uchar *environment = env_init();
+ ulong real_env_size = env_size;
+ ulong env_size = real_env_size - sizeof (ulong);
+#else
env_init();
-
- if (argc < 2) {
- printf ("Usage:\n%s\n", cmdtp->usage);
- return;
- }
+#endif /* CFG_FLASH_ENV_ADDR */
name = argv[1];
* Delete any existing definition
*/
if (oldval) {
+#ifndef CONFIG_ENV_OVERWRITE
/*
* Ethernet Address and serial# can be set only once
*/
printf ("Can't overwrite \"%s\"\n", name);
return;
}
+#endif
+
+ /* Check for console redirection */
+ if (strcmp(name,"stdin") == 0) {
+ console = stdin;
+ } else if (strcmp(name,"stdout") == 0) {
+ console = stdout;
+ } else if (strcmp(name,"stderr") == 0) {
+ console = stderr;
+ }
+
+ if (console != -1) {
+ if (argc < 3) /* Cannot delete it! */
+ return;
+
+ /* Try assigning specified device */
+ if (console_assign (console, argv[2]) < 0)
+ return;
+ }
if (*++nxt == '\0') {
*env = '\0';
*++env = '\0';
}
+#if defined(CFG_FLASH_ENV_ADDR)
+ MAKEVALID(environment, real_env_size);
+#endif /* CFG_FLASH_ENV_ADDR */
+
/* Delete only ? */
if (argc < 3)
return;
#ifdef CONFIG_NVRAM_ENV
*(ulong *)CFG_NVRAM_VAR_CRC_ADDR = crc32(0, (char *)environment, env_size);
#endif
+#if defined(CFG_FLASH_ENV_ADDR)
+ MAKEVALID(environment, real_env_size);
+#endif /* CFG_FLASH_ENV_ADDR */
+
/* Changes of the Ethernet or IP address should be reflected
* in the board info structure.
*/
bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
if (s) s = (*e) ? e+1 : e;
}
- } else if (strcmp(argv[1],"ipaddr") == 0) {
+ return;
+ }
+
+ if (strcmp(argv[1],"ipaddr") == 0) {
char *s = argv[2]; /* always use only one arg */
char *e;
bd->bi_ip_addr = 0;
}
}
+void setenv (char *varname, char *varvalue)
+{
+ char *argv[4] = { "setenv", varname, varvalue, NULL };
+ _do_setenv (bd_ptr, 0, 3, argv);
+}
+
+void do_setenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+ if (argc < 2) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return;
+ }
+
+ _do_setenv (bd, flag, argc, argv);
+}
+
/* need both ENV and flash */
#if ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == (CFG_CMD_ENV|CFG_CMD_FLASH))
int rc;
extern void flash_sect_protect (int p, ulong addr_first, ulong addr_last);
extern void flash_sect_erase (ulong addr_first, ulong addr_last);
+#if defined(CFG_FLASH_ENV_BUF)
+ uchar *sector_buffer;
+#endif /* CFG_FLASH_ENV_BUF */
+
+#if defined(CFG_FLASH_ENV_ADDR)
+ uchar *environment = env_init();
+#endif /* CFG_FLASH_ENV_BUF */
+
#ifdef CONFIG_4xx
/*
* On ppc4xx still saved somewhere within a flash sector (no sector
int i;
flash_info_t *info;
+#ifndef CFG_FLASH_ENV_ADDR
env_init();
+#endif
/*
* Calculate environment variables sector address and size
default:
printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
}
-
+
flash_sect_protect (1, sector_flash_addr, sector_flash_addr+sector_flash_size-1);
#else /* ! CONFIG_CPCI405 */
+#ifndef CFG_FLASH_ENV_ADDR
env_init();
+#endif
+
+#if defined(CFG_FLASH_ENV_BUF)
+ /* this buffer area was reserved in board_init_f() */
+ sector_buffer = (uchar *)((ulong)bd - CFG_FLASH_ENV_BUF);
+ /* copy the environment into the sector buffer */
+ memcpy(sector_buffer, environment, env_size);
+ /* override the old names */
+#define environment sector_buffer
+#define env_size CFG_FLASH_ENV_BUF
+#endif /* CFG_FLASH_ENV_BUF */
flash_sect_protect (0, (ulong)flash_addr, (ulong)flash_addr+env_size-1);
-
+
printf ("Erasing Flash...");
flash_sect_erase ((ulong)flash_addr, (ulong)flash_addr+env_size-1);
-
+
printf ("Saving Environment to Flash...\n");
switch (rc = flash_write (environment, (ulong)flash_addr, env_size)) {
case 0: break;
default:
printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc);
}
-
+
flash_sect_protect (1, (ulong)flash_addr, (ulong)flash_addr+env_size-1);
+#if defined(CFG_FLASH_ENV_BUF)
+#undef environment
+#undef env_size
+#endif /* CFG_FLASH_ENV_BUF */
+
#endif /* CONFIG_CPCI405 */
}
/*
* Prevent confusion if running from erased flash memory
*/
+#if defined(CFG_FLASH_ENV_ADDR)
+static uchar *env_init(void)
+#else
static void env_init(void)
+#endif /* CFG_FLASH_ENV_ADDR */
{
#ifdef CONFIG_NVRAM_ENV
if (crc32(0, (char *)environment, env_size) !=
memcpy (environment,
default_environment,
sizeof(default_environment));
- *(ulong *)CFG_NVRAM_VAR_CRC_ADDR =
+ *(ulong *)CFG_NVRAM_VAR_CRC_ADDR =
crc32(0, (char *)environment, env_size);
}
#else /* ! CONFIG_NVRAM_ENV */
+#if defined(CFG_FLASH_ENV_ADDR)
+ /*
+ * check if monitor has been relocated yet
+ */
+ if (environment == rom_addr) {
+ /*
+ * the monitor is still running from ROM. if the flash copy
+ * is valid, use that, otherwise use the default environment
+ *
+ * NOTE: can't printf here, because getenv() is called from
+ * serial_init() (and maybe before that) - hence the serial
+ * port is not ready - we can yell later that we are using
+ * the default environment... see below.
+ */
+ if (ISVALID(flash_addr))
+ return (flash_addr);
+ else
+ return (default_environment);
+ }
+
+ /*
+ * the monitor has been relocated - environment will now
+ * refer to the "in-memory" copy. If it isn't valid, copy it
+ * from the flash, or the default environment, if that isn't
+ * valid either.
+ */
+ if (!ISVALID(environment)) {
+ /*
+ * "in-memory" copy must be initialised
+ */
+ if (!ISVALID(flash_addr)) {
+ /* flash isn't valid either - use default */
+ printf ("\n*** Warning - no Environment,"
+ " using defaults\n\n");
+ memcpy(environment, default_environment,
+ sizeof (default_environment));
+ MAKEVALID(environment, env_size);
+ }
+ else
+ /* copy flash environment into RAM */
+ memcpy(environment, flash_addr, env_size);
+ }
+
+ return (environment);
+
+#else /* !CFG_FLASH_ENV_ADDR */
+
if (environment[0] == 0xFF) {
printf ("*** Warning - no Environment, using defaults\n\n");
memcpy (environment,
sizeof(default_environment));
}
+#endif /* CFG_FLASH_ENV_ADDR */
+
#endif /* CONFIG_NVRAM_ENV */
}
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ********************************************************************
+ *
+ * Lots of code copied from:
+ *
+ * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
+ * (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
+ *
+ * "The ExCA standard specifies that socket controllers should provide
+ * two IO and five memory windows per socket, which can be independently
+ * configured and positioned in the host address space and mapped to
+ * arbitrary segments of card address space. " - David A Hinds. 1999
+ *
+ * This controller does _not_ meet the ExCA standard.
+ *
+ * m8xx pcmcia controller brief info:
+ * + 8 windows (attrib, mem, i/o)
+ * + up to two slots (SLOT_A and SLOT_B)
+ * + inputpins, outputpins, event and mask registers.
+ * - no offset register. sigh.
+ *
+ * Because of the lacking offset register we must map the whole card.
+ * We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
+ * Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
+ * * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
+ * The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
+ * They are maximum 64KByte each...
+ */
+
+/*
+ * PCMCIA support
+ */
+#include <mpc8xx_irq.h>
+#include <ppcboot.h>
+#include <command.h>
+#include <cmd_pcmcia.h>
+#include <mpc8xx.h>
+
+
+static int hardware_enable (int slot);
+static int hardware_disable(int slot);
+static int voltage_set(int slot, int vcc, int vpp);
+
+static u_int m8xx_get_graycode(u_int size);
+#if 0
+static u_int m8xx_get_speed(u_int ns, u_int is_io);
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Autoconfigure boards if no settings are defined */
+#if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || defined(CONFIG_TQM860L)
+#define CONFIG_TQM8xxL
+#endif
+
+#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
+
+/* The RPX series use SLOT_B */
+#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
+# define CONFIG_PCMCIA_SLOT_B
+#endif
+
+/* The ADS board use SLOT_A */
+#ifdef CONFIG_ADS
+# define CONFIG_PCMCIA_SLOT_A
+#endif
+
+/* The FADS series are a mess */
+#ifdef CONFIG_FADS
+# if defined(CONFIG_MPC860T) || defined(CONFIG_MPC860) || defined(CONFIG_MPC821)
+# define CONFIG_PCMCIA_SLOT_A
+# else
+# define CONFIG_PCMCIA_SLOT_B
+# endif
+#endif
+
+/* The TQM8xxL modules use SLOT_A on MPC860, SLOT_B else */
+#ifdef CONFIG_TQM8xxL
+# if defined(CONFIG_MPC860T) || defined(CONFIG_MPC860)
+# define CONFIG_PCMCIA_SLOT_A
+# else /* ! 860, 860T */
+# define CONFIG_PCMCIA_SLOT_B
+# endif /* 860, 860T */
+#endif /* CONFIG_TQM8xxL */
+
+#endif /* !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B) */
+
+/* Make sure exactly one slot is defined - we support only one for now */
+#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
+#error Neither CONFIG_PCMCIA_SLOT_A nor CONFIG_PCMCIA_SLOT_B configured
+#endif
+#if defined(CONFIG_PCMCIA_SLOT_A) && defined(CONFIG_PCMCIA_SLOT_B)
+#error Both CONFIG_PCMCIA_SLOT_A and CONFIG_PCMCIA_SLOT_B configured
+#endif
+
+#define PCMCIA_SOCKETS_NO 1
+#define PCMCIA_MEM_WIN_NO 4
+#define PCMCIA_IO_WIN_NO 2
+
+/* define _slot_ to be able to optimize macros */
+#ifdef CONFIG_PCMCIA_SLOT_A
+# define _slot_ 0
+# define PCMCIA_SLOT_MSG "SLOT_A"
+#else
+# define _slot_ 1
+# define PCMCIA_SLOT_MSG "SLOT_B"
+#endif
+
+/*
+ * The TQM850L hardware has two pins swapped! Grrrrgh!
+ */
+#ifdef CONFIG_TQM850L
+#define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXOE
+#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXRESET
+#else
+#define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXRESET
+#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXOE
+#endif
+
+/* look up table for pgcrx registers */
+
+static u_int *pcmcia_pgcrx[2] = {
+ &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
+ &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
+};
+
+#define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
+
+/*
+ * This structure is used to address each window in the PCMCIA controller.
+ *
+ * Keep in mind that we assume that pcmcia_win_t[n+1] is mapped directly
+ * after pcmcia_win_t[n]...
+ */
+
+typedef struct {
+ uint br;
+ uint or;
+} pcmcia_win_t;
+
+
+
+/* ------------------------------------------------------------------------- */
+
+void do_pinit (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+ int i;
+ u_long reg, base;
+ pcmcia_win_t *win;
+
+ if (argc != 2) {
+ printf ("Usage: pinit {on | off}\n");
+ return;
+ }
+ if (strcmp(argv[1],"on") == 0) {
+ printf ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
+
+ /* intialize the fixed memory windows */
+ win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
+ base = CFG_PCMCIA_MEM_ADDR;
+
+ if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
+ printf ("Cannot set window size to 0x%08x\n",
+ CFG_PCMCIA_MEM_SIZE);
+ return;
+ }
+#if 0
+XXX XXX XXX
+if(mem->flags & MAP_ATTRIB)
+ reg |= 0x00000010;
+
+if(mem->flags & MAP_WRPROT)
+ reg |= 0x00000002;
+
+if(mem->flags & MAP_16BIT)
+ reg |= 0x00000040;
+
+if(mem->flags & MAP_ACTIVE)
+ reg |= 0x00000001;
+XXX XXX XXX
+#endif
+
+ for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
+ win->br = base;
+ win->or = 0; /* set to not valid */
+printf ("MemWin %d: Base 0x%08lX\n", i, base);
+ base += CFG_PCMCIA_MEM_SIZE;
+ ++win;
+ }
+
+ /* turn off voltage */
+ voltage_set(_slot_, 0, 0);
+
+ /* Enable external hardware */
+ hardware_enable(_slot_);
+
+ } else if (strcmp(argv[1],"off") == 0) {
+ printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
+
+ /* clear interrupt state, and disable interrupts */
+ ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
+ ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
+
+ /* turn off interrupt and disable CxOE */
+ PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
+
+ /* turn off memory windows */
+ win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
+
+ for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
+ /* disable memory window */
+ win->or = 0;
+ ++win;
+ }
+
+ /* turn off voltage */
+ voltage_set(_slot_, 0, 0);
+
+ /* disable external hardware */
+ printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
+ hardware_disable(_slot_);
+ } else {
+ printf ("Usage: pinit {on | off}\n");
+ return;
+ }
+
+ return;
+}
+
+/* ---------------------------------------------------------------------------- */
+/* board specific stuff: */
+/* voltage_set(), hardware_enable() and hardware_disable() */
+/* ---------------------------------------------------------------------------- */
+
+/* ---------------------------------------------------------------------------- */
+/* RPX Boards from Embedded Planet */
+/* ---------------------------------------------------------------------------- */
+
+#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
+
+/* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
+ * SYPCR is write once only, therefore must the slowest memory be faster
+ * than the bus monitor or we will get a machine check due to the bus timeout.
+ */
+
+#define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
+
+#undef PCMCIA_BMT_LIMIT
+#define PCMCIA_BMT_LIMIT (6*8)
+
+static int voltage_set(int slot, int vcc, int vpp)
+{
+ u_long reg = 0;
+
+ switch(vcc) {
+ case 0: break;
+ case 33: reg |= BCSR1_PCVCTL4; break;
+ case 50: reg |= BCSR1_PCVCTL5; break;
+ default: return 1;
+ }
+
+ switch(vpp) {
+ case 0: break;
+ case 33:
+ case 50:
+ if(vcc == vpp)
+ reg |= BCSR1_PCVCTL6;
+ else
+ return 1;
+ break;
+ case 120:
+ reg |= BCSR1_PCVCTL7;
+ default: return 1;
+ }
+
+ if(vcc == 120)
+ return 1;
+
+ /* first, turn off all power */
+
+ *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
+ | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
+
+ /* enable new powersettings */
+
+ *((uint *)RPX_CSR_ADDR) |= reg;
+
+ return 0;
+}
+
+#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
+static int hardware_enable (int slot)
+{
+ return 0; /* No hardware to enable */
+}
+static int hardware_disable(int slot)
+{
+ return 0; /* No hardware to disable */
+}
+#endif /* CONFIG_RPXCLASSIC */
+
+/* ---------------------------------------------------------------------------- */
+/* (F)ADS Boards from Motorola */
+/* ---------------------------------------------------------------------------- */
+
+#if defined(CONFIG_ADS) || defined(CONFIG_FADS)
+
+#ifdef CONFIG_ADS
+#define PCMCIA_BOARD_MSG "ADS"
+#define PCMCIA_GLITCHY_CD /* My ADS board needs this */
+#else
+#define PCMCIA_BOARD_MSG "FADS"
+#endif
+
+static int voltage_set(int slot, int vcc, int vpp)
+{
+ u_long reg = 0;
+
+ switch(vpp) {
+ case 0: reg = 0; break;
+ case 50: reg = 1; break;
+ case 120: reg = 2; break;
+ default: return 1;
+ }
+
+ switch(vcc) {
+ case 0: reg = 0; break;
+#ifdef CONFIG_ADS
+ case 50: reg = BCSR1_PCCVCCON; break;
+#endif
+#ifdef CONFIG_FADS
+ case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
+ case 50: reg = BCSR1_PCCVCC1; break;
+#endif
+ default: return 1;
+ }
+
+ /* first, turn off all power */
+
+#ifdef CONFIG_ADS
+ *((uint *)BCSR1) |= BCSR1_PCCVCCON;
+#endif
+#ifdef CONFIG_FADS
+ *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
+#endif
+ *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
+
+ /* enable new powersettings */
+
+#ifdef CONFIG_ADS
+ *((uint *)BCSR1) &= ~reg;
+#endif
+#ifdef CONFIG_FADS
+ *((uint *)BCSR1) |= reg;
+#endif
+
+ *((uint *)BCSR1) |= reg << 20;
+
+ return 0;
+}
+
+#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
+
+static int hardware_enable(int slot)
+{
+ *((uint *)BCSR1) &= ~BCSR1_PCCEN;
+ return 0;
+}
+
+static int hardware_disable(int slot)
+{
+ *((uint *)BCSR1) &= ~BCSR1_PCCEN;
+ return 0;
+}
+
+#endif /* (F)ADS */
+
+/* ---------------------------------------------------------------------------- */
+/* TQM8xxL Boards by TQ Components */
+/* ---------------------------------------------------------------------------- */
+
+#ifdef CONFIG_TQM8xxL
+
+#define PCMCIA_BOARD_MSG "TQM8xxL"
+
+static int hardware_enable(int slot)
+{
+ volatile immap_t *immap;
+ volatile cpm8xx_t *cp;
+ volatile pcmconf8xx_t *pcmp;
+ volatile sysconf8xx_t *sysp;
+ uint reg, mask;
+
+printf ("hardware_enable: TQM8xxL Slot %c\n", 'A'+slot);
+
+if (slot != 1) {
+ printf ("## Only Slot B supported for now ##\n");
+ return (1);
+}
+
+ immap = (immap_t *)CFG_IMMR;
+ sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
+ pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
+ cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
+
+ /*
+ * Configure SIUMCR to enable PCMCIA port B
+ * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
+ */
+ sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
+
+ /* clear interrupt state, and disable interrupts */
+ pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
+ pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
+
+ /* disable interrupts & DMA */
+ PCMCIA_PGCRX(_slot_) = 0;
+
+ /*
+ * Disable PCMCIA buffers (isolate the interface)
+ * and assert RESET signal
+ */
+printf ("Disable PCMCIA buffers and assert RESET\n");
+ reg = PCMCIA_PGCRX(_slot_);
+ reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
+ PCMCIA_PGCRX(_slot_) = reg;
+ udelay(500);
+
+ /*
+ * Configure Port C pins for
+ * 5 Volts Enable and 3 Volts enable
+ */
+ immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
+ immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
+ /* remove all power */
+ immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
+
+ /*
+ * Make sure there is a card in the slot, then configure the interface.
+ */
+printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
+printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
+printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
+ if (pcmp->pcmc_pipr & 0x00001800) {
+printf ("##### hardware_enable - no card in slot\n");
+ return (-1);
+ }
+printf ("# hardware_enable - card found\n");
+
+ /*
+ * Power On.
+ */
+ mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
+ reg = pcmp->pcmc_pipr;
+printf ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
+(reg&PCMCIA_VS1(slot))?"n":"ff", (reg&PCMCIA_VS2(slot))?"n":"ff");
+ if ((reg & mask) == mask) {
+ immap->im_ioport.iop_pcdat |= 0x0004;
+printf ("PCMCIA Power on 5.0 Volt\n");
+ } else {
+ immap->im_ioport.iop_pcdat |= 0x0002;
+printf ("PCMCIA Power on 3.3 Volt\n");
+ }
+ immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
+
+ /* VCC switch error flag, PCMCIA slot INPACK_ pin */
+ cp->cp_pbdir &= ~(0x0020 | 0x0010);
+ cp->cp_pbpar &= ~(0x0020 | 0x0010);
+ udelay(500000);
+
+printf ("Enable PCMCIA buffers and stop RESET\n");
+ reg = PCMCIA_PGCRX(_slot_);
+ reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
+ PCMCIA_PGCRX(_slot_) = reg;
+ udelay(500);
+
+printf ("# hardware_enable done\n");
+ return (0);
+}
+
+
+
+static int hardware_disable(int slot)
+{
+ volatile immap_t *immap;
+ volatile pcmconf8xx_t *pcmp;
+ u_long reg;
+
+printf ("hardware_disable: TQM8xxL Slot %c\n", 'A'+slot);
+
+if (slot != 1) {
+ printf ("## Only Slot B supported for now ##\n");
+ return (1);
+}
+
+ immap = (immap_t *)CFG_IMMR;
+ pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
+
+ /* remove all power */
+ immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
+
+ /* Configure PCMCIA General Control Register */
+ PCMCIA_PGCRX(_slot_) = 0;
+
+ /*
+ * Disable PCMCIA buffers (isolate the interface)
+ */
+printf ("Disable PCMCIA buffers\n");
+ PCMCIA_PGCRX(_slot_) &= ~__MY_PCMCIA_GCRX_CXOE;
+ udelay(500);
+
+printf ("Disable PCMCIA buffers and assert RESET\n");
+ reg = PCMCIA_PGCRX(_slot_);
+ reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
+ PCMCIA_PGCRX(_slot_) = reg;
+
+ return (0);
+}
+
+
+
+static int voltage_set(int slot, int vcc, int vpp)
+{
+ volatile immap_t *immap;
+ volatile pcmconf8xx_t *pcmp;
+ u_long reg;
+
+printf ("voltage_set: TQM8xxL Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
+'A'+slot,vcc/10,vcc%10,vpp/10,vcc%10);
+
+if (slot != 1) {
+ printf ("## Only Slot B supported for now ##\n");
+ return (1);
+}
+
+ immap = (immap_t *)CFG_IMMR;
+ pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
+ /*
+ * Disable PCMCIA buffers (isolate the interface)
+ * and assert RESET signal
+ */
+printf ("Disable PCMCIA buffers and assert RESET\n");
+ reg = PCMCIA_PGCRX(_slot_);
+ reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
+ PCMCIA_PGCRX(_slot_) = reg;
+ udelay(500);
+
+ /*
+ * Configure Port C pins for
+ * 5 Volts Enable and 3 Volts enable,
+ * Turn off all power
+ */
+printf ("PCMCIA power OFF\n");
+ immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
+ immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
+ immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
+
+ reg = 0;
+ switch(vcc) {
+ case 0: break;
+ case 33: reg |= 0x0002; break;
+ case 50: reg |= 0x0004; break;
+ default: goto done;
+ }
+
+ /* Checking supported voltages */
+
+printf ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
+(pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
+
+ immap->im_ioport.iop_pcdat |= reg;
+ immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
+if (reg) {
+printf ("PCMCIA powered at %sV\n",(reg&0x0004)?"5.0":"3.3");
+} else {
+printf ("PCMCIA powered down\n");
+}
+
+done:
+printf ("Enable PCMCIA buffers and stop RESET\n");
+ reg = PCMCIA_PGCRX(_slot_);
+ reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
+ reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
+ PCMCIA_PGCRX(_slot_) = reg;
+ udelay(500);
+
+printf ("voltage_set: TQM8xxL Slot %c, DONE\n", slot+'A');
+ return (0);
+}
+
+#endif /* TQM8xxL */
+
+
+/* ---------------------------------------------------------------------------- */
+/* End of Board Specific Stuff */
+/* ---------------------------------------------------------------------------- */
+
+
+/* ---------------------------------------------------------------------------- */
+/* MPC8xx Specific Stuff - should go to MPC8xx directory */
+/* ---------------------------------------------------------------------------- */
+
+/*
+ * Search this table to see if the windowsize is
+ * supported...
+ */
+
+#define M8XX_SIZES_NO 32
+
+static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
+{ 0x00000001, 0x00000002, 0x00000008, 0x00000004,
+ 0x00000080, 0x00000040, 0x00000010, 0x00000020,
+ 0x00008000, 0x00004000, 0x00001000, 0x00002000,
+ 0x00000100, 0x00000200, 0x00000800, 0x00000400,
+
+ 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
+ 0x00010000, 0x00020000, 0x00080000, 0x00040000,
+ 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
+
+
+/* ---------------------------------------------------------------------------- */
+
+static u_int m8xx_get_graycode(u_int size)
+{
+ u_int k;
+
+ for (k = 0; k < M8XX_SIZES_NO; k++) {
+ if(m8xx_size_to_gray[k] == size)
+ break;
+ }
+
+ if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
+ k = -1;
+
+ return k;
+}
+
+/* ------------------------------------------------------------------------- */
+
+#if 0
+static u_int m8xx_get_speed(u_int ns, u_int is_io)
+{
+ u_int reg, clocks, psst, psl, psht;
+
+ if(!ns) {
+
+ /*
+ * We get called with IO maps setup to 0ns
+ * if not specified by the user.
+ * They should be 255ns.
+ */
+
+ if(is_io)
+ ns = 255;
+ else
+ ns = 100; /* fast memory if 0 */
+ }
+
+ /*
+ * In PSST, PSL, PSHT fields we tell the controller
+ * timing parameters in CLKOUT clock cycles.
+ * CLKOUT is the same as GCLK2_50.
+ */
+
+/* how we want to adjust the timing - in percent */
+
+#define ADJ 180 /* 80 % longer accesstime - to be sure */
+
+ clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
+ clocks = (clocks * ADJ) / (100*1000);
+
+ if(clocks >= PCMCIA_BMT_LIMIT) {
+ DEBUG(0, "Max access time limit reached\n");
+ clocks = PCMCIA_BMT_LIMIT-1;
+ }
+
+ psst = clocks / 7; /* setup time */
+ psht = clocks / 7; /* hold time */
+ psl = (clocks * 5) / 7; /* strobe length */
+
+ psst += clocks - (psst + psht + psl);
+
+ reg = psst << 12;
+ reg |= psl << 7;
+ reg |= psht << 16;
+
+ return reg;
+}
+#endif
+
+/* ------------------------------------------------------------------------- */
+
+
+/* ------------------------------------------------------------------------- */
+
#include <cmd_kgdb.h>
#include <cmd_ide.h>
#include <cmd_disk.h>
+#include <cmd_console.h>
/*
* HELP command
*/
#define CMD_TBL_HELP MK_CMD_TBL_ENTRY( \
- "help", 1, CFG_MAXARGS, do_help, \
+ "help", 1, CFG_MAXARGS, 1, do_help, \
"help - print online help\n", \
"[command ...]\n" \
" - show help information (for 'command')\n" \
),
#define CMD_TBL_QUES MK_CMD_TBL_ENTRY( \
- "?", 1, CFG_MAXARGS, do_help, \
+ "?", 1, CFG_MAXARGS, 1, do_help, \
"? - alias for 'help'\n", \
NULL \
),
#define CMD_TBL_VERS MK_CMD_TBL_ENTRY( \
- "version", 4, 1, do_version, \
+ "version", 4, 1, 1, do_version, \
"version - print monitor version\n", \
NULL \
),
}
/*
- * Use serial_putstr() instead of printf() to avoid printf buffer overflow
+ * Use puts() instead of printf() to avoid printf buffer overflow
* for long help messages
*/
void
if (argc == 1) { /* print short help (usage) */
for (cmdtp=&cmd_tbl[0]; cmdtp->name; cmdtp++) {
+ /* allow user abort */
+ if (tstc())
+ return;
+
if (cmdtp->usage == NULL)
continue;
- serial_putstr (cmdtp->usage);
+ puts (cmdtp->usage);
}
return;
if (strncmp(argv[i], cmdtp->name, cmdtp->lmin) == 0) {
#ifdef CFG_LONGHELP
/* found - print (long) help info */
- serial_putstr (cmdtp->name);
- serial_putc (' ');
+ puts (cmdtp->name);
+ putc (' ');
if (cmdtp->help) {
- serial_putstr (cmdtp->help);
+ puts (cmdtp->help);
} else {
- serial_putstr ("- No help available.\n");
+ puts ("- No help available.\n");
}
- serial_putc ('\n');
+ putc ('\n');
#else /* no long help available */
if (cmdtp->usage)
- serial_putstr (cmdtp->usage);
+ puts (cmdtp->usage);
#endif /* CFG_LONGHELP */
goto done;
}
CMD_TBL_BOOTP
CMD_TBL_TFTPB
CMD_TBL_RARPB
+ CMD_TBL_DISK
CMD_TBL_BOOTD
CMD_TBL_LOADS
CMD_TBL_LOADB
CMD_TBL_IMINFO
CMD_TBL_PCIINFO
CMD_TBL_IRQINFO
+ CMD_TBL_CONINFO
CMD_TBL_IDE
- CMD_TBL_PART
CMD_TBL_LOOP
CMD_TBL_MTEST
CMD_TBL_ICACHE
CMD_TBL_HELP
CMD_TBL_QUES
/* the following entry terminates this table */
- MK_CMD_TBL_ENTRY( NULL, 0, 0, NULL, NULL, NULL )
+ MK_CMD_TBL_ENTRY( NULL, 0, 0, 0, NULL, NULL, NULL )
};
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <stdarg.h>
+#include <malloc.h>
+#include <devices.h>
+
+static int console_setfile(int file, device_t *dev)
+{
+ int error = 0;
+
+ if (dev == NULL)
+ return -1 ;
+
+ switch (file)
+ {
+ case stdin:
+ case stdout:
+ case stderr:
+ // Start new device
+ if (dev->start)
+ {
+ error = dev->start() ;
+ // If it's not started dont use it
+ if (error < 0)
+ break;
+ }
+
+ // Assign the new device (leaving the existing one started)
+ stdio_devices[file] = dev ;
+
+ // Update monitor functions (to use the console stuff by other applications)
+ switch (file){
+ case stdin:
+ bd_ptr->bi_mon_fnc->getc = dev->getc ;
+ bd_ptr->bi_mon_fnc->tstc = dev->tstc ;
+ break;
+ case stdout:
+ bd_ptr->bi_mon_fnc->putc = dev->putc ;
+ bd_ptr->bi_mon_fnc->puts = dev->puts ;
+ bd_ptr->bi_mon_fnc->printf = printf ;
+ break;
+ }
+ break;
+
+ default: // Invalid file ID
+ error = -1 ;
+ }
+ return error ;
+}
+
+//** PPCBOOT INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************
+
+void serial_printf(const char *fmt, ...)
+{
+ va_list args;
+ uint i;
+ char printbuffer[CFG_PBSIZE];
+
+ va_start(args, fmt);
+
+ /* For this to work, printbuffer must be larger than
+ * anything we ever want to print.
+ */
+ i = vsprintf(printbuffer, fmt, args);
+ va_end(args);
+
+ serial_puts(printbuffer);
+}
+
+int fgetc(int file)
+{
+ if (file < MAX_FILES)
+ return stdio_devices[file]->getc();
+
+ return -1 ;
+}
+
+int ftstc(int file)
+{
+ if (file < MAX_FILES)
+ return stdio_devices[file]->tstc();
+
+ return -1 ;
+}
+
+void fputc(int file, const char c)
+{
+ if (file < MAX_FILES)
+ stdio_devices[file]->putc(c);
+}
+
+void fputs(int file, const char *s)
+{
+ if (file < MAX_FILES)
+ stdio_devices[file]->puts(s);
+}
+
+void fprintf(int file, const char *fmt, ...)
+{
+ va_list args;
+ uint i;
+ char printbuffer[CFG_PBSIZE];
+
+ va_start(args, fmt);
+
+ /* For this to work, printbuffer must be larger than
+ * anything we ever want to print.
+ */
+ i = vsprintf(printbuffer, fmt, args);
+ va_end(args);
+
+ // Send to desired file
+ fputs(file, printbuffer);
+}
+
+//** PPCBOOT INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************
+
+int getc(void)
+{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
+
+ if (idata->relocated)
+ // Get from the standard input
+ return fgetc (stdin);
+
+ // Send directly to the handler
+ return serial_getc();
+}
+
+int tstc(void)
+{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
+
+ if (idata->relocated)
+ // Test the standard input
+ return ftstc (stdin);
+
+ // Send directly to the handler
+ return serial_tstc();
+}
+
+void putc(const char c)
+{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
+
+ if (idata->relocated)
+ // Send to the standard output
+ fputc (stdout, c);
+ else
+ // Send directly to the handler
+ serial_putc(c);
+}
+
+void puts(const char *s)
+{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
+
+ if (idata->relocated)
+ // Send to the standard output
+ fputs (stdout, s);
+ else
+ // Send directly to the handler
+ serial_puts(s);
+}
+
+void printf(const char *fmt, ...)
+{
+ va_list args;
+ uint i;
+ char printbuffer[CFG_PBSIZE];
+
+ va_start(args, fmt);
+
+ /* For this to work, printbuffer must be larger than
+ * anything we ever want to print.
+ */
+ i = vsprintf(printbuffer, fmt, args);
+ va_end(args);
+
+ // Print the string
+ puts (printbuffer);
+}
+
+//** PPCBOOT INIT FUNCTIONS *************************************************
+
+int console_assign (int file, char *devname)
+{
+ int flag , i;
+
+ // Check for valid file
+ switch(file){
+ case stdin:
+ flag = DEV_FLAGS_INPUT ;
+ break;
+ case stdout:
+ case stderr:
+ flag = DEV_FLAGS_OUTPUT ;
+ break;
+ default:
+ return -1 ;
+ }
+
+ // Check for valid device name
+
+ for(i=1; i<=ListNumItems(devlist); i++)
+ {
+ device_t *dev = ListGetPtrToItem (devlist,i) ;
+
+ if (strcmp (devname, dev->name) == 0)
+ {
+ if (dev->flags & flag)
+ return console_setfile(file, dev) ;
+
+ return -1 ;
+ }
+ }
+
+ return -1 ;
+}
+
+// Called before relocation - use serial functions
+void console_init_f (void)
+{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
+
+ idata->relocated = 0 ; // Use these pointers before relocation
+ idata->bi_mon_fnc.getc = serial_getc;
+ idata->bi_mon_fnc.tstc = serial_tstc;
+ idata->bi_mon_fnc.putc = serial_putc;
+ idata->bi_mon_fnc.puts = serial_puts;
+ idata->bi_mon_fnc.printf = serial_printf;
+}
+
+// Called after the relocation - use desierd console functions
+void console_init_r (void)
+{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
+ device_t *inputdev = NULL, *outputdev = NULL ;
+ int i, items = ListNumItems(devlist) ;
+
+ // Global pointer to monitor structure (updated by the console stuff)
+ bd_ptr->bi_mon_fnc = &idata->bi_mon_fnc ;
+
+ // Scan devices looking for input and output devices
+ for (i=1; (i<=items) && ((inputdev == NULL) || (outputdev == NULL)); i++)
+ {
+ device_t *dev = ListGetPtrToItem(devlist, i) ;
+
+ if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev==NULL))
+ inputdev = dev ;
+
+ if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev==NULL))
+ outputdev = dev ;
+ }
+
+ // Initializes output console first
+ if (outputdev != NULL)
+ {
+ console_setfile(stdout, outputdev);
+ console_setfile(stderr, outputdev);
+ }
+
+ // Initializes input console
+ if (inputdev != NULL)
+ console_setfile(stdin, inputdev);
+
+ // Print informations
+ printf(" Input: ");
+ if (stdio_devices[stdin] == NULL)
+ printf("No input devices available!\n");
+ else
+ {
+ printf("%s\n", stdio_devices[stdin]->name);
+ }
+
+ printf(" Output: ");
+ if (stdio_devices[stdout] == NULL)
+ printf("No output devices available!\n");
+ else
+ printf("%s\n", stdio_devices[stdout]->name);
+
+ // Setting environment variables
+ for (i=0; i<3; i++)
+ setenv(stdio_names[i], stdio_devices[i]->name);
+
+ // If nothing usable installed, use only the initial console
+ if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
+ return ;
+
+ // Set the relocation flag
+ idata->relocated = 1 ;
+}
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <stdarg.h>
+#include <malloc.h>
+#include <devices.h>
+
+list_t devlist = 0 ;
+device_t *stdio_devices[] = {NULL,NULL,NULL} ;
+char *stdio_names[MAX_FILES] = {"stdin", "stdout", "stderr"} ;
+
+#ifdef CONFIG_VIDEO
+extern int drv_video_init(void);
+#endif
+#ifdef CONFIG_WL_4PPM_KEYBOARD
+extern int drv_wlkbd_init(void);
+#endif
+
+// **************************************************************************
+// * SYSTEM DRIVERS
+// **************************************************************************
+
+static int drv_system_init (void)
+{
+ int error, devices = 1 ;
+ device_t serdev ;
+
+ memset (&serdev, 0, sizeof(serdev));
+
+ strcpy(serdev.name, "serial");
+ serdev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
+ serdev.putc = serial_putc ;
+ serdev.puts = serial_puts ;
+ serdev.getc = serial_getc ;
+ serdev.tstc = serial_tstc ;
+
+ error = device_register (&serdev);
+
+ return (error == 0) ? devices : error ;
+}
+
+// **************************************************************************
+// * DEVICES
+// **************************************************************************
+
+int device_register (device_t *dev)
+{
+ ListInsertItem (devlist, dev, LIST_END);
+ return 0 ;
+}
+
+int devices_init (void)
+{
+ // Initialize the list
+ devlist = ListCreate(sizeof(device_t)) ;
+
+ if (devlist == NULL)
+ {
+ eputs("Cannot initialize the list of devices!\n");
+ return -1 ;
+ }
+
+#ifdef CONFIG_VIDEO
+ drv_video_init();
+#endif
+#ifdef CONFIG_WL_4PPM_KEYBOARD
+ drv_wlkbd_init();
+#endif
+ drv_system_init();
+
+ return ListNumItems(devlist) ;
+}
+
+int devices_done (void)
+{
+ ListDispose(devlist);
+
+ return 0 ;
+}
+
#include <config.h>
+#ifdef CONFIG_FLASH_ENV_ADDR
+ .set env_not_stored_with_text, 1
+#else
+
#define XMK_STR(x) #x
#define MK_STR(x) XMK_STR(x)
.long .L_end - environment
.globl env_offset
.set env_offset, CFG_FLASH_ENV_OFFSET
+
+#endif /* CONFIG_FLASH_ENV_ADDR */
--- /dev/null
+#include <ppcboot.h>
+#include <malloc.h>
+#include "lists.h"
+
+#define MAX(a,b) (((a)>(b)) ? (a) : (b))
+#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#define CAT4CHARS(a,b,c,d) ((a<<24) | (b<<16) | (c<<8) | d)
+
+#define kDefaultAllocationPercentIncrease 10 /* increase list size by 10% every time it is full */\r
+#define kDefaultAllocationminNumItemsIncrease 4 /* always increase list size by 4 items when it is full */\r
+\r
+ /* how many items to expand the list by when it becomes full = current listSize (in items) + (hiword percent of list size) + loword */\r
+#define NUMITEMSPERALLOC(list) MAX(((*list)->listSize * ((*list)->percentIncrease + 100)) / 100 , (*list)->minNumItemsIncrease)\r
+\r
+#define ITEMPTR(list, item) &(((char *)&(*list)->itemList)[ (*(list))->itemSize * (item)])\r
+\r
+#define LIST_SIGNATURE CAT4CHARS('L', 'I', 'S', 'T');\r
+
+#define calloc(size,num) malloc(size*num)
+\r
+/********************************************************************/\r
+\r
+Handle NewHandle(unsigned int numBytes)\r
+{\r
+ void *memPtr;\r
+ HandleRecord *hanPtr;\r
+\r
+ memPtr = calloc(numBytes, 1);\r
+ hanPtr = (HandleRecord*)calloc(sizeof(HandleRecord), 1);\r
+ if (hanPtr && (memPtr || numBytes == 0))\r
+ {\r
+ hanPtr->ptr = memPtr;\r
+ hanPtr->size = numBytes;\r
+ return (Handle)hanPtr;\r
+ }\r
+ else\r
+ {\r
+ free(memPtr);\r
+ free(hanPtr);\r
+ return NULL;\r
+ }\r
+}\r
+\r
+/********************************************************************/\r
+\r
+void DisposeHandle(Handle handle)\r
+{\r
+ if (handle)\r
+ {\r
+ free(*handle);\r
+ free((void *)handle);\r
+ }\r
+}\r
+\r
+/********************************************************************/\r
+\r
+unsigned int GetHandleSize(Handle handle)\r
+{\r
+ return ((HandleRecord *)handle)->size;\r
+}\r
+\r
+/********************************************************************/\r
+\r
+int SetHandleSize(Handle handle, unsigned int newSize)\r
+{\r
+ HandleRecord *hanRecPtr = (HandleRecord *)handle;\r
+ void *newPtr, *oldPtr;\r
+ unsigned int oldSize;\r
+\r
+
+ oldPtr = hanRecPtr->ptr;\r
+ oldSize = hanRecPtr->size;\r
+
+ if (oldSize == newSize)\r
+ return 1;\r
+\r
+ if (oldPtr == NULL)\r
+ {
+ newPtr = malloc(newSize);\r
+ }
+ else\r
+ {
+ newPtr = realloc(oldPtr, newSize);\r
+ }
+ if (newPtr || (newSize == 0))\r
+ {\r
+ hanRecPtr->ptr = newPtr;\r
+ hanRecPtr->size = newSize;\r
+ if (newSize > oldSize)\r
+ memset ((char *)newPtr+oldSize, 0, newSize-oldSize);\r
+ return 1;\r
+ }\r
+ else\r
+ return 0;\r
+}\r
+
+ /* Used to compare list elements by their raw data contents */\r
+static int ListMemBlockCmp(void *a, void *b, int size)\r
+{\r
+ return memcmp(a, b, size);\r
+}\r
+\r
+
+/***************************************************************************/\r
+\r
+ /* Binary search numElements of size elementSize in array for a match\r
+ to the. item. Return the index of the element that matches (0 - numElements - 1).\r
+ If no match is found return the -i-1 where i is the index (0 - numElements)\r
+ where the item should be placed. (*theCmp)(a,b) should return <0 if a<b,\r
+ 0 if a==b, >0 if a>b.\r
+\r
+ This function is like the C-Library function bsearch() except that this\r
+ function returns the index where the item should be placed if it is not\r
+ found.\r
+ */\r
+int BinSearch(void *array, int numElements, int elementSize, void *itemPtr, CompareFunction compareFunction)\r
+{\r
+ int low, high, mid, cmp;\r
+ void *arrayItemPtr;\r
+\r
+ for(low=0, high= numElements-1, mid=0, cmp= -1; low <= high; )\r
+ {\r
+ mid = (low + high) >> 1;\r
+\r
+ arrayItemPtr = (void *) (((char *)array) + (mid*elementSize));\r
+ cmp = compareFunction ? compareFunction(itemPtr, arrayItemPtr)\r
+ : ListMemBlockCmp(itemPtr, arrayItemPtr, elementSize);\r
+ if (cmp == 0)\r
+ return mid;\r
+ else\r
+ if (cmp < 0)\r
+ high= mid - 1;\r
+ else\r
+ low= mid + 1;\r
+ }\r
+ if (cmp > 0)\r
+ mid++;\r
+\r
+ return -mid-1;\r
+}\r
+\r
+/*******************************************************************************/\r
+\r
+ /* BEGIN PATCH to 4.0.1 - jag 8-29-96 */\r
+ /* If numNewItems == 0 then expand the list by the number of items
+ indicated by its allocation policy.\r
+ If numNewItems > 0 then expand the list by exactly the number of
+ items indicated.\r
+ If numNewItems < 0 then expand the list by the absolute value of
+ numNewItems plus the number of items indicated by its allocation
+ policy.\r
+ Returns 1 for success, 0 if out of memory\r
+ */\r
+static int ExpandListSpace (list_t list, int numNewItems)\r
+{\r
+ if (numNewItems == 0)\r
+ numNewItems = NUMITEMSPERALLOC(list);\r
+ else\r
+ if (numNewItems < 0)\r
+ numNewItems = (-numNewItems) + NUMITEMSPERALLOC(list);\r
+\r
+ if (SetHandleSize ((Handle)list,\r
+ sizeof(ListStruct) +\r
+ ((*list)->listSize + numNewItems) * (*list)->itemSize))
+ {\r
+ (*list)->listSize += numNewItems;\r
+ return 1;\r
+ }\r
+ else
+ {\r
+ return 0;\r
+ }
+}\r
+\r
+/*******************************/\r
+\r
+ /* This function reallocate the list, minus any currently unused portion of its allotted memory. */\r
+void ListCompact (list_t list)\r
+{\r
+\r
+ if (!SetHandleSize ((Handle)list,\r
+ sizeof (ListStruct) + (*list)->numItems * (*list)->itemSize))\r
+ return;\r
+\r
+ (*list)->listSize = (*list)->numItems;\r
+}\r
+\r
+/*******************************/\r
+\r
+list_t ListCreate (int elementSize)\r
+{\r
+ list_t list;\r
+\r
+ list = (list_t)(NewHandle (sizeof(ListStruct))); /* create empty list */\r
+ if (list) \r
+ {\r
+ (*list)->signature = LIST_SIGNATURE;\r
+ (*list)->numItems = 0;\r
+ (*list)->listSize = 0;\r
+ (*list)->itemSize = elementSize;\r
+ (*list)->percentIncrease = kDefaultAllocationPercentIncrease;\r
+ (*list)->minNumItemsIncrease = kDefaultAllocationminNumItemsIncrease;\r
+ }\r
+\r
+ return list;\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListSetAllocationPolicy (list_t list, int minItemsPerAlloc, int percentIncreasePerAlloc)\r
+{\r
+ \r
+ (*list)->percentIncrease = percentIncreasePerAlloc;\r
+ (*list)->minNumItemsIncrease = minItemsPerAlloc;\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListDispose (list_t list)\r
+{\r
+ DisposeHandle ((Handle)list);\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListDisposePtrList(list_t list)\r
+{\r
+ int index; \r
+ int numItems;\r
+ \r
+ if (list)\r
+ {\r
+ numItems = ListNumItems(list);\r
+ \r
+ for (index = 1; index <= numItems; index++)\r
+ free(*(void **)ListGetPtrToItem(list, index));\r
+ \r
+ ListDispose(list);\r
+ }\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListClear (list_t list) /* keeps memory, resets the number of items to 0 */\r
+{\r
+ if (!list)\r
+ return;\r
+ (*list)->numItems = 0;\r
+}\r
+\r
+/*******************************/\r
+\r
+list_t ListCopy (list_t originalList) /* copy is only as large as necessary */\r
+{\r
+ list_t tempList = NULL;\r
+ int numItems;\r
+\r
+ if (!originalList)\r
+ return NULL;\r
+\r
+ tempList = ListCreate ((*originalList)->itemSize);\r
+ if (tempList) {\r
+ numItems = ListNumItems (originalList);\r
+\r
+ if (!SetHandleSize ((Handle)tempList,\r
+ sizeof (ListStruct) + numItems * (*tempList)->itemSize)) {\r
+ ListDispose (tempList);\r
+ return NULL;\r
+ }\r
+\r
+ (*tempList)->numItems = (*originalList)->numItems;\r
+ (*tempList)->listSize = (*originalList)->numItems;\r
+ (*tempList)->itemSize = (*originalList)->itemSize;\r
+ (*tempList)->percentIncrease = (*originalList)->percentIncrease;\r
+ (*tempList)->minNumItemsIncrease = (*originalList)->minNumItemsIncrease;\r
+\r
+ memcpy (ITEMPTR(tempList,0), ITEMPTR(originalList,0),\r
+ numItems * (*tempList)->itemSize);\r
+ }\r
+\r
+ return tempList;\r
+}\r
+\r
+/********************************/\r
+\r
+int ListAppend (list_t list1, list_t list2) /* list1 = list1 + list2 */\r
+{\r
+ int numItemsL1, numItemsL2;\r
+\r
+ if (!list2)\r
+ return 1;\r
+\r
+ if (!list1)\r
+ return 0;\r
+ if ((*list1)->itemSize != (*list2)->itemSize)\r
+ return 0;\r
+\r
+ numItemsL1 = ListNumItems (list1);\r
+ numItemsL2 = ListNumItems (list2);\r
+\r
+ if (numItemsL2 == 0)\r
+ return 1;\r
+\r
+ if (!SetHandleSize ((Handle)list1,\r
+ sizeof (ListStruct) + (numItemsL1 + numItemsL2) * (*list1)->itemSize))\r
+ return 0;\r
+\r
+ (*list1)->numItems = numItemsL1 + numItemsL2;\r
+ (*list1)->listSize = numItemsL1 + numItemsL2;\r
+\r
+ memmove (ITEMPTR(list1,numItemsL1), ITEMPTR(list2,0),\r
+ numItemsL2 * (*list2)->itemSize);\r
+\r
+ return 1;\r
+}\r
+\r
+/*******************************/\r
+\r
+ /* returns 1 if the item is inserted, returns 0 if out of memory or\r
+ bad arguments were passed.\r
+ */\r
+int ListInsertItem (list_t list, void *ptrToItem, int itemPosition)\r
+{\r
+ return ListInsertItems (list, ptrToItem, itemPosition, 1);\r
+}\r
+\r
+/*******************************/\r
+\r
+int ListInsertItems (list_t list, void *ptrToItems, int firstItemPosition, int numItemsToInsert)\r
+{\r
+ int numItems = (*list)->numItems;\r
+
+ if (firstItemPosition == numItems + 1)\r
+ firstItemPosition = LIST_END;\r
+ else\r
+ if (firstItemPosition > numItems)\r
+ return 0;\r
+\r
+ if ((*list)->numItems >= (*list)->listSize)\r
+ {
+ if (!ExpandListSpace (list, -numItemsToInsert)) /* PATCH to 4.0.1 - jag 8-29-96 */\r
+ return 0;\r
+\r }
+
+ if (firstItemPosition == LIST_START)\r
+ {
+ if (numItems == 0)\r
+ firstItemPosition = LIST_END; /* special case for empty list */\r
+ else\r
+ firstItemPosition = 1;\r
+\r }
+
+ if (firstItemPosition == LIST_END) /* add at the end of the list */\r
+ {\r
+ if (ptrToItems)\r
+ memcpy (ITEMPTR(list, numItems), ptrToItems, \r(*list)->itemSize * numItemsToInsert);
+ else\r
+ memset (ITEMPTR(list, numItems), 0,\r
+ (*list)->itemSize * numItemsToInsert);\r
+\r
+ (*list)->numItems += numItemsToInsert;\r
+ }\r
+ else \r
+ { /* move part of list up to make room for new item */\r
+ memmove (ITEMPTR(list,firstItemPosition-1+numItemsToInsert),\r
+ ITEMPTR(list,firstItemPosition-1),\r
+ (numItems + 1 - firstItemPosition) * (*list)->itemSize);\r
+\r
+ if (ptrToItems)\r
+ memmove (ITEMPTR(list,firstItemPosition-1), ptrToItems,\r
+ (*list)->itemSize * numItemsToInsert);\r
+ else\r
+ memset (ITEMPTR(list,firstItemPosition-1), 0,\r
+ (*list)->itemSize * numItemsToInsert);\r
+\r
+ (*list)->numItems += numItemsToInsert;\r
+ }\r
+\r
+ return 1;\r
+}\r
+\r
+/*******************************/\r
+\r
+int ListEqual (list_t list1, list_t list2)\r
+{\r
+ if (list1 == list2)\r
+ return 1;\r
+\r
+ if (list1 == NULL || list2 == NULL)\r
+ return 0;\r
+\r
+ if ((*list1)->itemSize == (*list1)->itemSize)\r
+ if ((*list1)->numItems == (*list2)->numItems)\r
+ return (memcmp (ITEMPTR(list1,0), ITEMPTR(list2,0),\r
+ (*list1)->itemSize * (*list1)->numItems) == 0);\r
+\r
+ return 0;\r
+}\r
+\r
+/*******************************/\r
+\r
+ /* The item pointed to by ptrToItem is copied over the current item at itemPosition */\r
+void ListReplaceItem (list_t list, void *ptrToItem, int itemPosition)\r
+{\r
+ ListReplaceItems (list, ptrToItem, itemPosition, 1);\r
+}\r
+\r
+/*******************************/\r
+\r
+ /* The item pointed to by ptrToItems is copied over the current item at itemPosition */\r
+void ListReplaceItems (list_t list, void *ptrToItems, int firstItemPosition, int numItemsToReplace)\r
+{\r
+ \r
+ if (firstItemPosition == LIST_END)\r
+ firstItemPosition = (*list)->numItems;\r
+ else\r
+ if (firstItemPosition == LIST_START)\r
+ firstItemPosition = 1;\r
+\r
+ memmove (ITEMPTR(list,firstItemPosition-1), ptrToItems,\r
+ (*list)->itemSize * numItemsToReplace);\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListRemoveItem (list_t list, void *itemDestination, int itemPosition)\r
+{\r
+ ListRemoveItems (list, itemDestination, itemPosition, 1);\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListRemoveItems (list_t list, void *itemsDestination, int firstItemPosition, int numItemsToRemove)\r
+{\r
+ int firstItemAfterChunk, numToMove;\r
+\r
+ if (firstItemPosition == LIST_START)\r
+ firstItemPosition = 1;\r
+ else\r
+ if (firstItemPosition == LIST_END)\r
+ firstItemPosition = (*list)->numItems;\r
+\r
+ if (itemsDestination != NULL)\r
+ memcpy (itemsDestination, ITEMPTR(list,firstItemPosition-1),\r
+ (*list)->itemSize * numItemsToRemove);\r
+\r
+ firstItemAfterChunk = firstItemPosition + numItemsToRemove;\r
+ numToMove = (*list)->numItems - (firstItemAfterChunk - 1);\r
+\r
+ if (numToMove > 0) /* move part of list down to cover hole left by removed item */\r
+ memmove (ITEMPTR(list,firstItemPosition-1),\r
+ ITEMPTR(list,firstItemAfterChunk-1),\r
+ (*list)->itemSize * numToMove);\r
+\r
+ (*list)->numItems -= numItemsToRemove;\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListGetItem (list_t list, void *itemDestination, int itemPosition)\r
+{\r
+ ListGetItems (list, itemDestination, itemPosition, 1);\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListGetItems(list_t list, void *itemsDestination, int firstItemPosition, int numItemsToGet)\r
+{\r
+\r
+ if (firstItemPosition == LIST_START)\r
+ firstItemPosition = 1;\r
+ else \r
+ if (firstItemPosition == LIST_END)\r
+ firstItemPosition = (*list)->numItems;\r
+\r
+ memcpy (itemsDestination, ITEMPTR(list,firstItemPosition-1),\r
+ (*list)->itemSize * numItemsToGet);\r
+}\r
+\r
+/*******************************/\r
+\r
+ /* Returns a pointer to the item at itemPosition. returns null if an errors occurred.\r
+ */\r
+void * ListGetPtrToItem (list_t list, int itemPosition)\r
+{\r
+ if (itemPosition == LIST_START)\r
+ itemPosition = 1;\r
+ else\r
+ if (itemPosition == LIST_END)\r
+ itemPosition = (*list)->numItems;\r
+\r
+ return ITEMPTR(list,itemPosition-1);\r
+}\r
+\r
+/*******************************/\r
+\r
+ /* returns a pointer the lists data (abstraction violation for optimization) */\r
+void * ListGetDataPtr (list_t list)\r
+{\r
+ return &((*list)->itemList[0]);\r
+}\r
+\r
+/********************************/\r
+\r
+int ListApplyToEach (list_t list, int ascending, ListApplicationFunc funcToApply, void *callbackData)\r
+{\r
+ int result = 0, index;\r
+\r
+ if (!list || !funcToApply)\r
+ goto Error;\r
+\r
+ if (ascending) \r
+ {\r
+ for (index = 1; index <= ListNumItems (list); index++) \r
+ {\r
+ result = funcToApply (index, ListGetPtrToItem (list, index),\r
+ callbackData);\r
+ if (result < 0)\r
+ goto Error;\r
+ }\r
+ }\r
+ else \r
+ {\r
+ for (index = ListNumItems (list); index > 0 &&\r
+ index <= ListNumItems (list); index--) \r
+ {\r
+ result = funcToApply (index, ListGetPtrToItem (list, index),\r
+ callbackData);\r
+ if (result < 0)\r
+ goto Error;\r
+ }\r
+ }\r
+\r
+Error:\r
+ return result;\r
+}\r
+\r
+/********************************/\r
+\r
+int ListGetItemSize (list_t list)\r
+{\r
+ return (*list)->itemSize;\r
+}\r
+\r
+/********************************/\r
+\r
+int ListNumItems (list_t list)\r
+{\r
+ return (*list)->numItems;\r
+}\r
+\r
+/*******************************/\r
+\r
+void ListRemoveDuplicates (list_t list, CompareFunction compareFunction)\r
+{\r
+ int numItems, index, startIndexForFind, duplicatesIndex;\r
+\r
+ numItems = ListNumItems (list);\r
+\r
+ for (index = 1; index < numItems; index++) \r
+ {\r
+ startIndexForFind = index + 1;\r
+ while (startIndexForFind <= numItems) \r
+ {\r
+ duplicatesIndex = ListFindItem (list, ListGetPtrToItem (list, index),\r
+ startIndexForFind, compareFunction);\r
+ if (duplicatesIndex > 0) \r
+ {\r
+ ListRemoveItem (list, NULL, duplicatesIndex);\r
+ numItems--;\r
+ startIndexForFind = duplicatesIndex;\r
+ }\r
+ else\r
+ break;\r
+ }\r
+ }\r
+}\r
+
+/*******************************/\r
+
+\r
+/*******************************/\r
+\r
+int ListFindItem (list_t list, void *ptrToItem, int startingPosition, CompareFunction compareFunction)\r
+{\r
+ int numItems, size, index, cmp;\r
+ void *listItemPtr;\r
+\r
+ if ((numItems = (*list)->numItems) == 0)\r
+ return 0;\r
+\r
+ size = (*list)->itemSize;\r
+\r
+ if (startingPosition == LIST_START)\r
+ startingPosition = 1;\r
+ else\r
+ if (startingPosition == LIST_END)\r
+ startingPosition = numItems;\r
+\r
+ for (index = startingPosition; index <= numItems; index++)\r
+ {\r
+ listItemPtr = ITEMPTR(list,index-1);\r
+ cmp = compareFunction ? compareFunction(ptrToItem, listItemPtr)\r
+ : ListMemBlockCmp(ptrToItem, listItemPtr, size);\r
+ if (cmp == 0)\r
+ return index;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+/*******************************/\r
+\r
+int ShortCompare(void *a, void *b)\r
+{\r
+ if (*(short *)a < *(short *)b) return -1;\r
+ if (*(short *)a > *(short *)b) return 1;\r
+ return 0;\r
+}\r
+\r
+/*******************************/\r
+\r
+int IntCompare(void *a, void *b)\r
+{\r
+ if (*(int *)a < *(int *)b) return -1;\r
+ if (*(int *)a > *(int *)b) return 1;\r
+ return 0;\r
+}\r
+\r
+/*******************************/\r
+\r
+int CStringCompare(void *a, void *b)\r
+{\r
+ return strcmp(*(char **)a, *(char **)b);\r
+}\r
+\r
+/*******************************/\r
+\r
+\r
+int ListBinSearch (list_t list, void *ptrToItem, CompareFunction compareFunction)\r
+{\r
+ int index;\r
+\r
+ index = BinSearch (ITEMPTR(list,0), (int)(*list)->numItems,\r
+ (int)(*list)->itemSize, ptrToItem, compareFunction);\r
+\r
+ if (index >= 0)\r
+ index++; /* lists start from 1 */\r
+ else\r
+ index = 0; /* item not found */\r
+\r
+ return index;\r
+}\r
+\r
+/**************************************************************************/\r
+\r
+ /* Reserves memory for numItems in the list. If it succeeds then\r
+ numItems items can be inserted without possibility of an\r
+ out of memory error (useful to simplify error recovery in\r
+ complex functions). Returns 1 if success, 0 if\r
+ out of memory.\r
+ */\r
+int ListPreAllocate (list_t list, int numItems)\r
+{\r
+\r
+ if ((*list)->listSize - (*list)->numItems < numItems)\r
+ return ExpandListSpace (list,\r
+ numItems - ((*list)->listSize - (*list)->numItems));\r
+ else\r
+ return 1; /* enough items are already pre-allocated */\r
+}\r
+\r
static char erase_seq[] = "\b \b"; /* erase sequence */
static char tab_seq[] = " "; /* used to expand TABs */
-static char parse_buffer[CFG_CBSIZE]; /* cmd parse buffer */
-static int argc;
-static char *argv[CFG_MAXARGS+1]; /* NULL terminated */
/****************************************************************************/
printf ("### main_loop entered:\n\n");
#endif
- /* Set default arguments */
- argc = 0;
- argv[ argc ] = NULL ;
-
/*
* Main Loop for Monitor Command Processing
*/
-
+
for (;;) {
int flag = 0;
int len;
--bootdelay;
/* delay 100 * 10ms */
for (i=0; i<100; ++i) {
- if (serial_tstc()) { /* we got a key press */
+ if (tstc()) { /* we got a key press */
bootdelay = 0; /* no more delays */
autoboot = 0; /* don't auto boot */
- (void) serial_getc(); /* consume input */
+ (void) getc(); /* consume input */
break;
}
udelay (10000);
printf ("\b\b\b%2d ", bootdelay);
}
- serial_putc ('\n');
+ putc ('\n');
if (autoboot) {
autoboot = 0;
}
}
-/*----------------------------------------------------------*/
-
-void run_default_command (int l, cmd_tbl_t *cmdtp, bd_t *bd, int flag)
-{
- char *str = getenv("bootcmd");
-
- if (!str)
- return;
-
- while (*str) {
- char *sep;
- char *t;
-
- /* find separator, or string end */
- for (sep=str; *sep; sep++) {
- if (*sep == ';') break;
- }
-
- /* copy to console buffer */
-
- for (t=console_buffer; str<sep; ) {
- *t++ = *str++;
- if (t >= console_buffer+CFG_CBSIZE-1) {
- break; /* just in case */
- }
- }
- *t = '\0';
-
- run_command (l, cmdtp, bd, flag);
-
- if (*sep == '\0') {
- break;
- }
- str = sep + 1;
- }
-}
-
-/*----------------------------------------------------------*/
-/*
- * "len" is used to indicate if we're executing normal input
- * (len > 0), just re-executing the last command when the user
- * presses only ENTER (len == 0), or executing the default command
- * (len < 0).
- */
-static void run_command (int len,
- cmd_tbl_t *cmdtp, bd_t *bd, int flag)
-{
- extern void do_bootd (cmd_tbl_t *, bd_t *, int, int, char *[]);
-
- /*
- * If we have any new input, we parse the new command line.
- * Otherwise, we re-issue the previous command.
- */
- if (len != 0) {
- strcpy (parse_buffer, console_buffer);
-
- argc = parse_line (parse_buffer, argv);
- } else {
- flag |= CMD_FLAG_REPEAT;
- }
-#if 0
- { int i;
- printf ("ARGC = %d\n", argc);
- for (i=0; i<argc; ++i) {
- printf (">> ARGV[%d] = \"%s\"\n", i, argv[i]);
- }
- printf ("\n");
- }
-#endif
-
- if (argc == 0) { /* nothing to do */
- return;
- }
-
- /*
- * Search command table.
- * Use linear search - it's a small table
- */
- for (cmdtp=&cmd_tbl[0]; cmdtp->name; cmdtp++) {
- if (strncmp(argv[0], cmdtp->name, cmdtp->lmin) == 0) {
- /* found - check max args */
- if (argc > cmdtp->maxargs) {
- printf ("Usage:\n%s\n", cmdtp->usage);
- return;
- }
- /* avoid "bootd" recursion */
- if ((len < 0) && (cmdtp->cmd == do_bootd)) {
- printf ("'bootd' recursion detected\n");
- return;
- }
- /* OK - call function */
- (cmdtp->cmd)(cmdtp, bd, flag, argc, argv);
- return;
- }
- }
- printf ("Unknown command '%s' - try 'help'\n", argv[0]);
-}
-/*---------------------------------------------------------------*/
-
/****************************************************************************/
/*
/* print prompt */
if (prompt)
- serial_putstr (prompt);
+ puts (prompt);
col = plen;
for (;;) {
- c = serial_getc();
+ c = getc();
/*
* Special character handling
case '\r': /* Enter */
case '\n':
*p = '\0';
- serial_putstr ("\r\n");
+ puts ("\r\n");
return (p - console_buffer);
-
+
case 0x03: /* ^C - break */
return (-1);
-
+
case 0x15: /* ^U - erase line */
while (col > plen) {
- serial_putstr (erase_seq);
+ puts (erase_seq);
--col;
}
p = console_buffer;
*/
if (n < CFG_CBSIZE-2) {
if (c == '\t') { /* expand TABs */
- serial_putstr (tab_seq+(col&07));
+ puts (tab_seq+(col&07));
col += 8 - (col&07);
} else {
++col; /* echo input */
- serial_putc (c);
+ putc (c);
}
*p++ = c;
++n;
} else { /* Buffer full */
- serial_putc ('\a');
+ putc ('\a');
}
}
}
/****************************************************************************/
-/*
- * Some commands are too dangerous to repeat when the user just presses
- * enter to see if the box is still alive.
- *
- * This function will turn off repeating of the current command.
- */
-
-void command_repeat_off (void)
-{
- argc = 0;
-}
-
-/****************************************************************************/
-
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen)
{
char *s;
if (*(--p) == '\t') { /* will retype the whole line */
while (*colp > plen) {
- serial_putstr (erase_seq);
+ puts (erase_seq);
(*colp)--;
}
for (s=buffer; s<p; ++s) {
if (*s == '\t') {
- serial_putstr (tab_seq+((*colp) & 07));
+ puts (tab_seq+((*colp) & 07));
*colp += 8 - ((*colp) & 07);
} else {
++(*colp);
- serial_putc (*s);
+ putc (*s);
}
}
} else {
- serial_putstr (erase_seq);
+ puts (erase_seq);
(*colp)--;
}
(*np)--;
*line++ = '\0'; /* terminate current arg */
}
+ printf ("** Too many args (max. %d) **\n", CFG_MAXARGS);
+
return (nargs);
}
/****************************************************************************/
+static void process_macros (char *input, char *output)
+{
+ char c, *varname_start;
+ int inputcnt = strlen (input);
+ int outputcnt = CFG_CBSIZE;
+ int state = 0; /* 0 = waiting for '$' */
+ /* 1 = waiting for '(' */
+ /* 2 = waiting for ')' */
+
+#ifdef DEBUG_PARSER
+ char *output_start = output;
+
+ printf ("[PROCESS_MACROS] INPUT=%s\n", input);
+#endif
+
+ while (inputcnt && outputcnt) {
+ c = *input++;
+ inputcnt--;
+
+ switch (state) {
+ case 0: /* Waiting for $ */
+ if (c == '$') {
+ state++;
+ } else {
+ *(output++) = c;
+ outputcnt--;
+ }
+ break;
+ case 1: /* Waiting for ( */
+ if (c == '(') {
+ state++;
+ varname_start = input;
+ } else {
+ state = 0;
+ *(output++) = '$';
+ outputcnt--;
+
+ if (outputcnt) {
+ *(output++) = c;
+ outputcnt--;
+ }
+ }
+ break;
+ case 2: /* Waiting for ) */
+ if (c == ')') {
+ int i;
+ char envname[CFG_CBSIZE], *envval;
+ int envcnt = input-varname_start-1; /* Varname # of chars */
+
+ /* Get the varname */
+ for (i = 0; i < envcnt; i++) {
+ envname[i] = varname_start[i];
+ }
+ envname[i] = 0;
+
+ /* Get its value */
+ envval = getenv (envname);
+
+ /* Copy into the line if it exists */
+ if (envval != NULL)
+ while ((*envval) && outputcnt) {
+ *(output++) = *(envval++);
+ outputcnt--;
+ }
+ /* Look for another '$' */
+ state = 0;
+ }
+ break;
+ }
+ }
+
+ if (outputcnt)
+ *output = 0;
+
+#ifdef DEBUG_PARSER
+ printf ("[PROCESS_MACROS] OUTPUT=%s\n", output_start);
+#endif
+}
+
+/****************************************************************************/
+
+
+static int process_separators (char *s, int len,
+ cmd_tbl_t *cmdtp, bd_t *bd, int flag)
+{
+ extern void do_bootd (cmd_tbl_t *, bd_t *, int, int, char *[]);
+
+ char token[CFG_CBSIZE];
+ char finaltoken[CFG_CBSIZE];
+ char *str = s;
+ char *argv[CFG_MAXARGS + 1]; /* NULL terminated */
+ int argc;
+ int found;
+ int repeatable = 1;
+
+#ifdef DEBUG_PARSER
+ printf ("[PROCESS_SEPARATORS] %s\n", s);
+#endif
+ while (*s) {
+ char *sep;
+ char *t;
+
+ /* find separator, or string end */
+ for (sep = str; *sep; sep++) {
+ if (*sep == ';')
+ break;
+ }
+
+ /* extract the token between separators */
+ for (t = token; str < sep;) {
+ *t++ = *str++;
+ if (t >= token + CFG_CBSIZE - 1)
+ break; /* just in case */
+ }
+ *t = '\0';
+
+ /* Process macros into this token and replace them */
+ process_macros (token, finaltoken);
+
+ /* Extract arguments */
+ argc = parse_line (finaltoken, argv);
+
+ /* Search command table - Use linear search - it's a small table */
+ found = 0;
+ for (cmdtp = &cmd_tbl[0]; (!found) && cmdtp->name; cmdtp++) {
+ if (strncmp (argv[0], cmdtp->name, cmdtp->lmin) == 0) {
+ /* found - check max args */
+ if (argc > cmdtp->maxargs) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 0;
+ }
+
+ /* avoid "bootd" recursion */
+ if ((len < 0) && (cmdtp->cmd == do_bootd)) {
+#ifdef DEBUG_PARSER
+ printf ("[%s]\n", finaltoken);
+#endif
+ printf ("'bootd' recursion detected\n");
+ return 0;
+ }
+
+ /* OK - call function */
+ (cmdtp->cmd) (cmdtp, bd, flag, argc, argv);
+
+ repeatable &= cmdtp->repeatable;
+ found = 1;
+ }
+ }
+ if (!found)
+ printf ("Unknown command '%s' - try 'help'\n", argv[0]);
+
+ /* Did the user stop this? */
+ if (tstc ())
+ return 0;
+
+ if (*sep == '\0')
+ break;
+
+ str = sep + 1;
+ }
+
+ return repeatable;
+}
+
+/****************************************************************************/
+
+/*
+ * "len" is used to indicate if we're executing normal input
+ * (len > 0), just re-executing the last command when the user
+ * presses only ENTER (len == 0), or executing the default command
+ * (len < 0).
+ */
+
+static void run_command (int len,
+ cmd_tbl_t *cmdtp, bd_t *bd, int flag)
+{
+ static char lastcommand[CFG_CBSIZE] = { 0, };
+ static int lastlen = 0;
+
+ if (len > 0) { /* Process a new command */
+ memcpy (lastcommand, console_buffer, len);
+ lastcommand[len] = 0;
+ lastlen = len;
+ } else if (len < 0) { /* Process default command */
+ char *str = getenv ("bootcmd");
+
+ if (!str)
+ return;
+
+ strcpy (lastcommand, str);
+ lastlen = len;
+ } else { /* Process last command (len = 0) */
+ /* Check if we have a valid command stored */
+ if (lastcommand[0] == 0)
+ return;
+
+ flag |= CMD_FLAG_REPEAT;
+ }
+
+#ifdef DEBUG_PARSER
+printf ("[RUN_COMMAND] lastlen=%d -> %s\n", lastlen, lastcommand);
+#endif
+ /* Process separators and check for non-valid repeatable commands */
+ if (process_separators (lastcommand, lastlen, cmdtp, bd, flag) == 0) {
+ lastcommand[0] = 0;
+ lastlen = 0;
+ }
+}
+
+/****************************************************************************/
+
+void run_default_command (int l, cmd_tbl_t *cmdtp, bd_t *bd, int flag)
+{
+ run_command(-1, cmdtp, bd, flag) ;
+}
+
+/****************************************************************************/
#########################################################################
+PLATFORM_RELFLAGS=
+PLATFORM_CPPFLAGS=
+
ifdef ARCH
sinclude $(TOPDIR)/$(ARCH)/config.mk # include architecture dependend rules
endif
OBJDUMP = $(CROSS_COMPILE)objdump
RANLIB = $(CROSS_COMPILE)RANLIB
-RELFLAGS= -mrelocatable -ffixed-r14
+RELFLAGS= $(PLATFORM_RELFLAGS)
DBGFLAGS= #-g -DDEBUG
OPTFLAGS= -O2 -fomit-frame-pointer
#LDSCRIPT := $(BOARD)/ppcboot.lds.debug
LDSCRIPT := $(BOARD)/ppcboot.lds
CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
- -D__KERNEL__ -D__powerpc__ \
+ -D__KERNEL__ \
-I$(TOPDIR)/include \
- -msoft-float -fno-builtin \
- -pipe -ffixed-r2 -mstring
-
-ifeq ($(CPU),mpc8xx)
-CPPFLAGS += -mcpu=860 -DCONFIG_8xx
-endif
-
-ifeq ($(CPU),ppc4xx)
-CPPFLAGS += -mcpu=403 -DCONFIG_4xx
-endif
+ -fno-builtin \
+ -pipe $(PLATFORM_CPPFLAGS)
CFLAGS := $(CPPFLAGS) -Wall -Wno-uninitialized -Wstrict-prototypes
AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
}
for ( ; s<e; ++s) {
- serial_putc (*s);
+ putc (*s);
}
/*
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
}
#CFLAGS += -DET_DEBUG -DDEBUG
-DIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
-NAME = $(shell basename $(DIR))
-LIB = lib$(NAME).a
+LIB = libdisk.a
OBJS = part_mac.o
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
-void do_partition (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+static int part_mac_read_ddb (int dev, mac_driver_desc_t *ddb_p);
+static int part_mac_read_pdb (int dev, int part, mac_partition_t *pdb_p);
+
+
+void print_part_mac (int dev)
{
- int dev;
ulong i, n;
mac_driver_desc_t ddesc;
mac_partition_t mpart;
ldiv_t mb, gb;
- if (argc != 2) {
- printf ("Usage:\n%s\n", cmdtp->usage);
- return;
- }
-
- dev = (int)simple_strtoul(argv[1], NULL, 16);
-
printf ("\nPartition Map for IDE device %d:\n", dev);
- if (ide_read (dev, 0, 1, (ulong *)&ddesc) != 1) {
- printf ("** Can't read Driver Desriptor Block **\n");
- return;
- }
-
- if (ddesc.signature != MAC_DRIVER_MAGIC) {
- printf ("** Bad Signature: expected 0x%04x, got 0x%04x\n",
- MAC_DRIVER_MAGIC, ddesc.signature);
+ if (part_mac_read_ddb (dev, &ddesc)) {
+ /* error reading Driver Desriptor Block, or no valid Signature */
return;
}
n = ddesc.blk_count;
- mb = ldiv(n, (1024 / ddesc.blk_size)); /* MB; assumes blk_size == 512 */
- gb = ldiv(n, ((1024 * 1024) / ddesc.blk_size));
+
+ mb = ldiv(n, ((1024 * 1024) / ddesc.blk_size)); /* MB */
/* round to 1 digit */
- mb.rem += (1024 / 2); gb.rem += ((1024 * 1024) / 2);
- mb.rem /= 1024; gb.rem /= (1024 * 1024);
+ mb.rem *= 10 * ddesc.blk_size;
+ mb.rem += 512 * 1024;
+ mb.rem /= 1024 * 1024;
+
+ gb = ldiv(10 * mb.quot + mb.rem, 10240);
+ gb.rem += 512;
+ gb.rem /= 1024;
+
printf ("Block Size=%d, Number of Blocks=%d, "
"Total Capacity: %ld.%ld MB = %ld.%ld GB\n"
printf ("%4ld: ", i);
if (ide_read (dev, i, 1, (ulong *)&mpart) != 1) {
- printf ("** Can't read Partition Map **\n");
+ printf ("** Can't read Partition Map on %d:%ld **\n",
+ dev, i);
return;
}
if (mpart.signature != MAC_PARTITION_MAGIC) {
- printf ("** Bad Signature: expected 0x%04x, got 0x%04x\n",
- MAC_PARTITION_MAGIC, mpart.signature);
+ printf ("** Bad Signature on %d:%ld - "
+ "expected 0x%04x, got 0x%04x\n",
+ dev, i, MAC_PARTITION_MAGIC, mpart.signature);
return;
}
bytes, c
);
}
- printf ("\n");
}
-#endif /* _CMD_IDE_H */
+
+/*
+ * Read Device Descriptor Block
+ */
+static int part_mac_read_ddb (int dev, mac_driver_desc_t *ddb_p)
+{
+ if (ide_read (dev, 0, 1, (ulong *)ddb_p) != 1) {
+ printf ("** Can't read Driver Desriptor Block **\n");
+ return (-1);
+ }
+
+ if (ddb_p->signature != MAC_DRIVER_MAGIC) {
+ printf ("** Bad Signature: expected 0x%04x, got 0x%04x\n",
+ MAC_DRIVER_MAGIC, ddb_p->signature);
+ return (-1);
+ }
+ return (0);
+}
+
+/*
+ * Read Partition Descriptor Block
+ */
+static int part_mac_read_pdb (int dev, int part, mac_partition_t *pdb_p)
+{
+ int n = 1;
+
+ for (;;) {
+ /*
+ * We must always read the descritpor block for
+ * partition 1 first since this is the only way to
+ * know how many partitions we have.
+ */
+ if (ide_read (dev, n, 1, (ulong *)pdb_p) != 1) {
+ printf ("** Can't read Partition Map on %d:%d **\n",
+ dev, n);
+ return (-1);
+ }
+
+ if (pdb_p->signature != MAC_PARTITION_MAGIC) {
+ printf ("** Bad Signature on %d:%d: "
+ "expected 0x%04x, got 0x%04x\n",
+ dev, n, MAC_PARTITION_MAGIC, pdb_p->signature);
+ return (-1);
+ }
+
+ if (n == part)
+ return (0);
+
+ if ((part < 1) || (part > pdb_p->map_count)) {
+ printf ("** Invalid partition %d:%d [%d:1...%d:%d only]\n",
+ dev, part,
+ dev,
+ dev, pdb_p->map_count);
+ return (-1);
+ }
+
+ /* update partition count */
+ n = part;
+ }
+
+ /* NOTREACHED */
+}
+
+/*
+ * The following code could / should be moved to a more general layer
+ * (common/disk.c ?) when we have to support more than one partition
+ * type one day.
+ */
+int get_partition_info (int dev, int part, disk_partition_t *info)
+{
+ mac_driver_desc_t ddesc;
+ mac_partition_t mpart;
+
+ if (part_mac_read_ddb (dev, &ddesc)) {
+ return (-1);
+ }
+
+ info->blksz = ddesc.blk_size;
+
+ if (part_mac_read_pdb (dev, part, &mpart)) {
+ return (-1);
+ }
+
+ info->start = mpart.start_block;
+ info->size = mpart.block_count;
+ memcpy (info->type, mpart.type, sizeof(info->type));
+ memcpy (info->name, mpart.name, sizeof(info->name));
+
+ return (0);
+}
+
+#endif /* CONFIG_COMMANDS & CFG_CMD_IDE */
}
for ( ; s<e; ++s) {
- serial_putc (*s);
+ putc (*s);
}
- serial_putc ('\n');
+ putc ('\n');
return (1);
}
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
}
#include <ppcboot.h>
#define MON_PRINT(fmt,args...) \
- (*(void (*)(const char *, ...))(bd->bi_mon_fnc.printf)) (fmt ,##args)
+ (*(void (*)(const char *, ...))(bd->bi_mon_fnc->printf)) (fmt ,##args)
#define MON_GETC \
- (*(int (*)(void))(bd->bi_mon_fnc.getc))
+ (*(int (*)(void))(bd->bi_mon_fnc->getc))
#define MON_TSTC \
- (*(int (*)(void))(bd->bi_mon_fnc.tstc))
+ (*(int (*)(void))(bd->bi_mon_fnc->tstc))
int hello_world (bd_t *bd, int argc, char *argv[])
{
#define MON_PRINT(fmt,args...) \
- (*(void (*)(const char *, ...))(bd->bi_mon_fnc.printf)) (fmt ,##args)
+ (*(void (*)(const char *, ...))(bd->bi_mon_fnc->printf)) (fmt ,##args)
#define MON_GETC \
- (*(int (*)(void))(bd->bi_mon_fnc.getc))
+ (*(int (*)(void))(bd->bi_mon_fnc->getc))
#define MON_TSTC \
- (*(int (*)(void))(bd->bi_mon_fnc.tstc))
+ (*(int (*)(void))(bd->bi_mon_fnc->tstc))
#define MON_INSTALL_HANDLER \
- (*(int (*)(int, void (*)(void *), void *))(bd->bi_mon_fnc.install_hdlr))
+ (*(int (*)(int, void (*)(void *), void *))(bd->bi_mon_fnc->install_hdlr))
#define MON_FREE_HANDLER \
- (*(int (*)(int))(bd->bi_mon_fnc.free_hdlr))
+ (*(int (*)(int))(bd->bi_mon_fnc->free_hdlr))
void setPeriod (bd_t * bd, tid_8xx_cpmtimer_t *hwp, ulong interval);
/* ------------------------------------------------------------------------- */
-static long int dram_size (long int, long int *, long int);
-#define PCMCIA_MAP 0xf0130000
-volatile unsigned char *pcmcia_mem = (unsigned char*)PCMCIA_MAP;
+#ifdef CFG_PCMCIA_MEM_ADDR
+volatile unsigned char *pcmcia_mem = (unsigned char*)CFG_PCMCIA_MEM_ADDR;
+#endif
/* ------------------------------------------------------------------------- */
0x8fffec24, 0x0fffec04, 0x08ffec04, 0x00ffec0c,
0x03ffec00, 0x00ffec44, 0x00ffcc08, 0x0cffcc44,
0x00ffec0c, 0x03ffec00, 0x00ffec44, 0x00ffcc00,
- 0x3fffc847, 0xffffffff, 0xffffffff, 0xffffffff,
+ 0x3fffc847, 0xffffffff, 0xffffffff, 0xffffffff,
0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c,
*
* Check for "L" type (no second DRAM bank),
* otherwise "L" type is assumed as default.
- *
+ *
* Return 1 for "L" type, 0 else.
*/
case 0x21 :
case 0x22 :
case 0x23 :
- case 0x24 :
+ case 0x24 :
case 0x3f :
- printf("FADS");
+ printf("FADS");
break;
- default :
- printf("unknown board (0x%02x)\n", k);
+ default :
+ printf("unknown board (0x%02x)\n", k);
return -1;
}
switch(k)
{
- case 0x03 :
- printf("MPC823");
+ case 0x03 :
+ printf("MPC823");
break;
- case 0x20 :
- printf("MPC801");
+ case 0x20 :
+ printf("MPC801");
break;
- case 0x21 :
+ case 0x21 :
printf("MPC850");
break;
- case 0x22 :
+ case 0x22 :
printf("MPC821, MPC860 / MPC860SAR / MPC860T");
break;
- case 0x23 :
- printf("MPC860SAR");
+ case 0x23 :
+ printf("MPC860SAR");
break;
- case 0x24 :
+ case 0x24 :
printf("MPC860T");
break;
- case 0x3f :
- printf("MPC850SAR");
+ case 0x3f :
+ printf("MPC850SAR");
break;
}
printf(" rev ");
- k = (((*((uint *)BCSR3) >> 23) & 1) << 3)
+ k = (((*((uint *)BCSR3) >> 23) & 1) << 3)
| (((*((uint *)BCSR3) >> 19) & 1) << 2)
| (((*((uint *)BCSR3) >> 16) & 3));
switch(k)
{
- case 0x01 :
- printf("ENG or PILOT\n");
+ case 0x01 :
+ printf("ENG or PILOT\n");
break;
-
+
default:
- printf("unknown (0x%x)\n", k);
+ printf("unknown (0x%x)\n", k);
return -1;
}
int _draminit(uint base, uint noMbytes, uint edo, uint delay)
{
volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile memctl8xx_t *memctl = &immap->im_memctl;
-
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
+
/* init upm */
switch(delay)
{
- case 70:
+ case 70:
{
if(edo)
{
break;
}
- case 60:
+ case 60:
{
if(edo)
{
break;
}
- default :
+ default :
return -1;
}
-
+
memctl->memc_mptpr = 0x0400; /* divide by 16 */
switch(noMbytes)
{
memctl->memc_mamr = 0x13a01114;
memctl->memc_or3 = 0xffc00800;
- memctl->memc_br3 = 0x00400081 + base;
+ memctl->memc_br3 = 0x00400081 + base;
memctl->memc_or2 = 0xffc00800;
break;
}
-
+
case 4: /* 4 Mbyte uses only CS2 */
{
memctl->memc_mamr = 0x13a01114;
{
memctl->memc_mamr = 0x13b01114;
memctl->memc_or3 = 0xff000800;
- memctl->memc_br3 = 0x01000081 + base;
+ memctl->memc_br3 = 0x01000081 + base;
memctl->memc_or2 = 0xff000800;
break;
}
-
+
case 16: /* 16 Mbyte uses only CS2 */
{
memctl->memc_mamr = 0x13b01114;
memctl->memc_or2 = 0xff000800;
break;
}
-
+
default:
return -1;
}
void _dramdisable(void)
{
volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile memctl8xx_t *memctl = &immap->im_memctl;
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
memctl->memc_br2 = 0x00000000;
memctl->memc_br3 = 0x00000000;
#define SDRAM_MARVALUE 0x88
#define SDRAM_MCRVALUE0 0x80808111 /* run pattern 0x11 */
-#define SDRAM_MCRVALUE1 SDRAM_MCRVALUE0
+#define SDRAM_MCRVALUE1 SDRAM_MCRVALUE0
const uint sdram_table[] =
{
/* single read. (offset 0 in upm RAM) */
0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00,
- 0x1ff77c47,
+ 0x1ff77c47,
/* MRS initialization (offset 5) */
/* burst read. (offset 8 in upm RAM) */
0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00,
0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47,
- _not_used_, _not_used_, _not_used_, _not_used_,
- _not_used_, _not_used_, _not_used_, _not_used_,
+ _not_used_, _not_used_, _not_used_, _not_used_,
+ _not_used_, _not_used_, _not_used_, _not_used_,
/* single write. (offset 18 in upm RAM) */
0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47,
- _not_used_, _not_used_, _not_used_, _not_used_,
+ _not_used_, _not_used_, _not_used_, _not_used_,
/* burst write. (offset 20 in upm RAM) */
0x1f07fc04, 0xeeaebc00, 0x10ad7c00, 0xf0affc00,
- 0xf0affc00, 0xe1bbbc04, 0x1ff77c47, _not_used_,
- _not_used_, _not_used_, _not_used_, _not_used_,
- _not_used_, _not_used_, _not_used_, _not_used_,
+ 0xf0affc00, 0xe1bbbc04, 0x1ff77c47, _not_used_,
+ _not_used_, _not_used_, _not_used_, _not_used_,
+ _not_used_, _not_used_, _not_used_, _not_used_,
/* refresh. (offset 30 in upm RAM) */
0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04,
0xfffffc84, 0xfffffc07, _not_used_, _not_used_,
- _not_used_, _not_used_, _not_used_, _not_used_,
+ _not_used_, _not_used_, _not_used_, _not_used_,
/* exception. (offset 3c in upm RAM) */
0x7ffffc07, _not_used_, _not_used_, _not_used_ };
int _initsdram(uint base, uint noMbytes)
{
volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile memctl8xx_t *memctl = &immap->im_memctl;
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
if(noMbytes != 4)
{
void _sdramdisable(void)
{
volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile memctl8xx_t *memctl = &immap->im_memctl;
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
memctl->memc_br4 = 0x00000000;
void initflash(uint *noMbytes, uint *delay)
{
volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile memctl8xx_t *memctl = &immap->im_memctl;
-
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
+
uint k, m;
k = *((uint *)BCSR2) >> 28;
{
#ifdef CONFIG_FADS
/* "SM732A2000 / SM73228" */
- case 0x04 :
- m = 8;
- break;
+ case 0x04 :
+ m = 8;
+ break;
/* "SM732A1000A / SM73218" */
- case 0x05 :
- m = 4;
- break;
+ case 0x05 :
+ m = 4;
+ break;
#endif
/* "MCM29080" */
- case 0x06 :
- m = 8;
- break;
+ case 0x06 :
+ m = 8;
+ break;
/* "MCM29040" */
- case 0x07 :
- m = 4;
- break;
+ case 0x07 :
+ m = 4;
+ break;
/* "MCM29020" */
- case 0x08 :
- m = 2;
- break;
+ case 0x08 :
+ m = 2;
+ break;
#ifdef CONFIG_ADS
/* "SM732A1000A" */
case 0x0a :
- m = 4;
- break;
+ m = 4;
+ break;
/* "SM732A2000" */
case 0x0b :
- m = 8;
- break;
+ m = 8;
+ break;
#endif
- default :
- printf("unknown flashsize (0x%x) - defaulting to 2 Mbyte", k);
+ default :
+ printf("unknown flashsize (0x%x) - defaulting to 2 Mbyte", k);
m = 2;
break;
}
switch(k)
{
- case 0x01 :
- k = 150;
+ case 0x01 :
+ k = 150;
break;
- case 0x02 :
- k = 120;
+ case 0x02 :
+ k = 120;
break;
- case 0x03 :
- k = 90;
+ case 0x03 :
+ k = 90;
break;
- default :
- printf("unknown flashdelay(0x%x) - defaulting to 150 ns", k);
- k = 150;
+ default :
+ printf("unknown flashdelay(0x%x) - defaulting to 150 ns", k);
+ k = 150;
break;
}
-
+
/* we're supposed to set the correct number of waitstates
* but today we just set it to maximum, no hurry */
*noMbytes = m;
*delay = k;
-
+
}
long int initdram (int board_type)
switch(k & 0x3)
{
/* "MCM36100 / MT8D132X" */
- case 0x00 :
- m = 4;
- break;
-
+ case 0x00 :
+ m = 4;
+ break;
+
/* "MCM36800 / MT16D832X" */
- case 0x01 :
- m = 32;
- break;
+ case 0x01 :
+ m = 32;
+ break;
/* "MCM36400 / MT8D432X" */
- case 0x02 :
- m = 16;
- break;
+ case 0x02 :
+ m = 16;
+ break;
/* "MCM36200 / MT16D832X ?" */
- case 0x03 :
- m = 8;
+ case 0x03 :
+ m = 8;
break;
}
switch(k >> 2)
{
- case 0x02 :
- k = 70;
+ case 0x02 :
+ k = 70;
break;
-
- case 0x03 :
- k = 60;
+
+ case 0x03 :
+ k = 60;
break;
-
- default :
- printf("unknown dramdelay (0x%x) - defaulting to 70 ns", k);
- k = 70;
+
+ default :
+ printf("unknown dramdelay (0x%x) - defaulting to 70 ns", k);
+ k = 70;
}
#ifdef CONFIG_FADS
/* the FADS is missing this bit, all rams treated as non-edo */
- s = 0;
+ s = 0;
#else
s = (*((uint *)BCSR2) >> 27) & 0x01;
#endif
*DRAM ERROR, HALT PROCESSOR
*********************************/
while(1);
-
- return -1;
+
+ return -1;
}
#endif
*DRAM ERROR, HALT PROCESSOR
*********************************/
while(1);
-
- return -1;
+
+ return -1;
}
}
return (0);
}
-static int voltage_set(int vcc, int vpp)
-{
- u_int reg = 0;
-
- switch(vpp) {
- case 0: reg = 0; break;
- case 50: reg = 1; break;
- case 120: reg = 2; break;
- default: return 1;
- }
-
- switch(vcc) {
- case 0: reg = 0; break;
-#ifdef CONFIG_ADS
- case 50: reg = BCSR1_PCCVCCON; break;
-#endif
-#ifdef CONFIG_FADS
- case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
- case 50: reg = BCSR1_PCCVCC1; break;
-#endif
- default: return 1;
- }
-
- /* first, turn off all power */
-
-#ifdef CONFIG_ADS
- *((uint *)BCSR1) |= BCSR1_PCCVCCON;
-#endif
-#ifdef CONFIG_FADS
- *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
-#endif
- *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
-
- /* enable new powersettings */
-
-#ifdef CONFIG_ADS
- *((uint *)BCSR1) &= ~reg;
-#endif
-#ifdef CONFIG_FADS
- *((uint *)BCSR1) |= reg;
-#endif
-
- *((uint *)BCSR1) |= reg << 20;
-
- return 0;
-}
-
-static void hardware_enable(void)
-{
- *((uint *)BCSR1) &= ~BCSR1_PCCEN;
-}
-
-static void hardware_disable(void)
-{
- *((uint *)BCSR1) &= ~BCSR1_PCCEN;
-}
-
int pcmcia_init(void)
{
volatile pcmconf8xx_t *pcmp;
- uint v;
+ uint v, slota, slotb;
- /* Enable the PCMCIA for a Flash card.
+ /*
+ ** Enable the PCMCIA for a Flash card.
*/
-
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
- pcmp->pcmc_pbr0 = PCMCIA_MAP;
+#if 0
+ pcmp->pcmc_pbr0 = CFG_PCMCIA_MEM_ADDR;
pcmp->pcmc_por0 = 0xc00ff05d;
+#endif
+
/* Set all slots to zero by default. */
pcmp->pcmc_pgcra = 0;
pcmp->pcmc_pgcrb = 0;
*((uint *)BCSR1) &= ~BCSR1_PCCEN;
/* Check if any PCMCIA card is luged in. */
- if (pcmp->pcmc_pipr & 0x18001800)
+
+ slota = (pcmp->pcmc_pipr & 0x18000000) == 0 ;
+ slotb = (pcmp->pcmc_pipr & 0x00001800) == 0 ;
+
+ if (!(slota || slotb))
{
- printf("No card present.\n");
+ printf("No card present\n");
#ifdef PCMCIA_SLOT_A
pcmp->pcmc_pgcra = 0;
#endif
#endif
return -1;
}
+ else
+ printf("Unknown card (");
v = 0;
- /* both the ADS and the FADS have a 5V keyed pcmcia connector (?)*/
+ /* both the ADS and the FADS have a 5V keyed pcmcia connector (?)
+ **
+ ** Paolo - Yes, but i have to insert some 3.3V card in that slot on
+ ** my FADS... :-)
+ */
#if defined(CONFIG_MPC860)
switch( (pcmp->pcmc_pipr >> 30) & 3 )
switch( (pcmp->pcmc_pipr >> 14) & 3 )
#endif
{
- case 0x00 :
- printf("5V\n");
- v = 5;
+ case 0x00 :
+ printf("5V");
+ v = 5;
break;
- case 0x01 :
- printf("5V and 3V\n");
- v = 5;
+ case 0x01 :
+ printf("5V and 3V");
+#ifdef CONFIG_FADS
+ v = 3; // User lower voltage if supported!
+#else
+ v = 5;
+#endif
break;
- case 0x03 :
- printf("5V, 3V and x.xV\n");
- v = 5;
+ case 0x03 :
+ printf("5V, 3V and x.xV");
+#ifdef CONFIG_FADS
+ v = 3; // User lower voltage if supported!
+#else
+ v = 5;
+#endif
break;
}
- if(v == 5)
- {
-
-#ifdef CONFIG_ADS
- /* Enable 5 volt Vcc.
- */
- *((uint *)BCSR1) &= ~BCSR1_PCCVCCON;
-#endif
+ switch(v){
#ifdef CONFIG_FADS
- /* Enable 5 volt Vcc.
- */
- *((uint *)BCSR1) &= ~BCSR1_PCCVCC0;
- *((uint *)BCSR1) |= BCSR1_PCCVCC1;
-#if 0
- /* Enable PCMCIA drivers and 3.3 voltage.
- */
- *((uint *)BCSR1) |= 0x00400000;
- *((uint *)BCSR1) &= ~0x00b10000;
+ case 3:
+ printf("; using 3V");
+ /*
+ ** Enable 3 volt Vcc.
+ */
+ *((uint *)BCSR1) &= ~BCSR1_PCCVCC1;
+ *((uint *)BCSR1) |= BCSR1_PCCVCC0;
+ break;
#endif
+ case 5:
+ printf("; using 5V");
+#ifdef CONFIG_ADS
+ /*
+ ** Enable 5 volt Vcc.
+ */
+ *((uint *)BCSR1) &= ~BCSR1_PCCVCCON;
#endif
- }
- else
- {
+#ifdef CONFIG_FADS
+ /*
+ ** Enable 5 volt Vcc.
+ */
+ *((uint *)BCSR1) &= ~BCSR1_PCCVCC0;
+ *((uint *)BCSR1) |= BCSR1_PCCVCC1;
+#endif
+ break;
+
+ default:
*((uint *)BCSR1) |= BCSR1_PCCEN; /* disable pcmcia */
- printf("unknown voltage\n");
+ printf("; unknown voltage");
return -1;
}
-
+ printf(")\n");
/* disable pcmcia reset after a while */
udelay(20);
return 0;
}
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Check memory range for valid RAM. A simple memory test determines
- * the actually available RAM size between addresses `base' and
- * `base + maxsize'. Some (not all) hardware errors are detected:
- * - short between address lines
- * - short between data lines
- */
-
-static long int dram_size (long int mamr_value, long int *base, long int maxsize)
-{
- volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile memctl8xx_t *memctl = &immap->im_memctl;
- volatile long int *addr;
- long int cnt, val;
-
- memctl->memc_mamr = mamr_value;
-
- for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
- addr = base + cnt; /* pointer arith! */
-
- *addr = ~cnt;
- }
-
- /* write 0 to base address */
- addr = base;
- *addr = 0;
-
- /* check at base address */
- if ((val = *addr) != 0)
- {
- return (0);
- }
-
- for (cnt = 1; ; cnt <<= 1)
- {
- addr = base + cnt; /* pointer arith! */
-
- val = *addr;
-
- if (val != (~cnt))
- {
- return (cnt * sizeof(long));
- }
- }
- /* NOTREACHED */
-}
int i;
/* Init: no FLASHes known */
- for (i=0; i < CFG_MAX_FLASH_BANKS; ++i)
+ for (i=0; i < CFG_MAX_FLASH_BANKS; ++i)
{
flash_info[i].flash_id = FLASH_UNKNOWN;
}
size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
- if (flash_info[0].flash_id == FLASH_UNKNOWN)
+ if (flash_info[0].flash_id == FLASH_UNKNOWN)
{
printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",size_b0, size_b0<<20);
}
/* monitor protection ON by default */
(void)flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE,CFG_FLASH_BASE+CFG_MONITOR_LEN-1, &flash_info[0]);
- if (size_b1)
+ if (size_b1)
{
memctl->memc_or1 = CFG_OR1_PRELIM;
memctl->memc_br1 = CFG_BR1_PRELIM;
/* monitor protection ON by default */
(void)flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE, CFG_FLASH_BASE+CFG_MONITOR_LEN-1, &flash_info[1]);
- }
- else
+ }
+ else
{
memctl->memc_or1 = CFG_OR1_PRELIM;
memctl->memc_br1 = CFG_BR1_PRELIM;
int i;
/* set up sector start adress table */
- if (info->flash_id & FLASH_BTYPE)
+ if (info->flash_id & FLASH_BTYPE)
{
/* set sector offsets for bottom boot block type */
- for (i = 0; i < info->sector_count; i++)
+ for (i = 0; i < info->sector_count; i++)
{
info->start[i] = base + (i * 0x00040000);
}
- }
- else
+ }
+ else
{
/* set sector offsets for top boot block type */
i = info->sector_count - 1;
- for (; i >= 0; i--)
+ for (; i >= 0; i--)
{
info->start[i] = base + i * 0x00040000;
}
{
int i;
- if (info->flash_id == FLASH_UNKNOWN)
+ if (info->flash_id == FLASH_UNKNOWN)
{
printf ("missing or unknown FLASH type\n");
return;
}
- switch (info->flash_id & FLASH_VENDMASK)
+ switch (info->flash_id & FLASH_VENDMASK)
{
case FLASH_MAN_AMD: printf ("AMD "); break;
case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
default: printf ("Unknown Vendor "); break;
}
- switch (info->flash_id & FLASH_TYPEMASK)
+ switch (info->flash_id & FLASH_TYPEMASK)
{
case FLASH_AM040B: printf ("AM29F040B (4 Mbit, bottom boot sect)\n");
break;
printf (" Sector Start Addresses:");
- for (i=0; i<info->sector_count; ++i)
+ for (i=0; i<info->sector_count; ++i)
{
if ((i % 5) == 0)
{
printf ("\n ");
}
-
+
printf (" %08lX%s", info->start[i],info->protect[i] ? " (RO)" : " " );
}
value = addr[0];
- switch (value)
+ switch (value)
{
case AMD_MANUFACT:case 0x01:
info->flash_id = FLASH_MAN_AMD;
case FUJ_MANUFACT:
info->flash_id = FLASH_MAN_FUJ;
break;
-
+
default:
info->flash_id = FLASH_UNKNOWN;
info->sector_count = 0;
value = addr[1]; /* device ID */
- switch (value)
+ switch (value)
{
case AMD_ID_F040B:
info->flash_id += FLASH_AM040B;
#endif
/* check for protected sectors */
- for (i = 0; i < info->sector_count; i++)
+ for (i = 0; i < info->sector_count; i++)
{
/* read sector protection at sector address, (A7 .. A0) = 0x02 */
/* D0 = 1 if protected */
/*
* Prevent writes to uninitialized FLASH.
*/
- if (info->flash_id != FLASH_UNKNOWN)
+ if (info->flash_id != FLASH_UNKNOWN)
{
addr = (volatile unsigned long *)info->start[0];
#if 0
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
}
/* finally write data to flash */
for (info = info_first; info <= info_last && cnt>0; ++info) {
ulong len;
-
+
len = info->start[0] + info->size - addr;
if (len > cnt)
len = cnt;
for (; i<4; ++i, ++cp) {
data = (data << 8) | (*(uchar *)cp);
}
-
+
return (write_word(info, wp, data));
}
--- /dev/null
+#
+# (C) Copyright 2000
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = lib$(BOARD).a
+
+OBJS = $(BOARD).o flash.o
+
+$(LIB): .depend $(OBJS)
+ $(AR) crv $@ $^
+
+#########################################################################
+
+.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
+ $(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+
+sinclude .depend
+
+#########################################################################
--- /dev/null
+#
+# (C) Copyright 2000
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+TEXT_BASE = 0x02800000
+OBJCFLAGS = --set-section-flags=.ppcenv=contents,alloc,load,data
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <mpc8xx.h>
+
+flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
+
+/*-----------------------------------------------------------------------
+ * Functions
+ */
+ulong flash_get_size (vu_long *addr, flash_info_t *info);
+
+int flash_write (uchar *, ulong, ulong);
+flash_info_t *addr2info (ulong);
+
+static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
+static int write_word (flash_info_t *info, ulong dest, ulong data);
+static void flash_get_offsets (ulong base, flash_info_t *info);
+static int flash_protect (int flag, ulong from, ulong to, flash_info_t *info);
+
+/*-----------------------------------------------------------------------
+ * Protection Flags:
+ */
+#define FLAG_PROTECT_SET 0x01
+#define FLAG_PROTECT_CLEAR 0x02
+
+/*-----------------------------------------------------------------------
+ */
+
+unsigned long flash_init (void)
+{
+ volatile immap_t *immap = (immap_t *)CFG_IMMR;
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
+ unsigned long size_b0, size_b1;
+ int i;
+
+ /* Init: no FLASHes known */
+ for (i=0; i < CFG_MAX_FLASH_BANKS; ++i)
+ {
+ flash_info[i].flash_id = FLASH_UNKNOWN;
+ }
+
+ /* Static FLASH Bank configuration here - FIXME XXX */
+
+ size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
+
+ if (flash_info[0].flash_id == FLASH_UNKNOWN)
+ {
+ printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",size_b0, size_b0<<20);
+ }
+
+ if (FLASH_BASE1_PRELIM != 0x0) {
+ size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
+
+ if (size_b1 > size_b0) {
+ printf ("## ERROR: Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",size_b1, size_b1<<20,size_b0, size_b0<<20);
+
+ flash_info[0].flash_id = FLASH_UNKNOWN;
+ flash_info[1].flash_id = FLASH_UNKNOWN;
+ flash_info[0].sector_count = -1;
+ flash_info[1].sector_count = -1;
+ flash_info[0].size = 0;
+ flash_info[1].size = 0;
+ return (0);
+ }
+ } else {
+ size_b1 = 0;
+ }
+
+ /* Remap FLASH according to real size */
+ memctl->memc_or0 = CFG_OR0_PRELIM;
+ memctl->memc_br0 = CFG_BR0_PRELIM;
+
+ /* Re-do sizing to get full correct info */
+ size_b0 = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
+
+ flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);
+
+ /* monitor protection ON by default */
+ (void)flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE,CFG_FLASH_BASE+CFG_MONITOR_LEN-1, &flash_info[0]);
+
+ if (size_b1)
+ {
+ memctl->memc_or1 = CFG_OR1_PRELIM;
+ memctl->memc_br1 = CFG_BR1_PRELIM;
+
+ /* Re-do sizing to get full correct info */
+ size_b1 = flash_get_size((vu_long *)(CFG_FLASH_BASE + size_b0), &flash_info[1]);
+
+ flash_get_offsets (CFG_FLASH_BASE + size_b0, &flash_info[1]);
+
+ /* monitor protection ON by default */
+ (void)flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE, CFG_FLASH_BASE+CFG_MONITOR_LEN-1, &flash_info[1]);
+ }
+ else
+ {
+ memctl->memc_or1 = CFG_OR1_PRELIM;
+ memctl->memc_br1 = CFG_BR1_PRELIM;
+
+ flash_info[1].flash_id = FLASH_UNKNOWN;
+ flash_info[1].sector_count = -1;
+ }
+
+ flash_info[0].size = size_b0;
+ flash_info[1].size = size_b1;
+
+ return (size_b0 + size_b1);
+}
+
+/*-----------------------------------------------------------------------
+ * Check or set protection status for monitor sectors
+ *
+ * The monitor always occupies the _first_ part of the _first_ Flash bank.
+ */
+static int flash_protect (int flag, ulong from, ulong to, flash_info_t *info)
+{
+ ulong b_end = info->start[0] + info->size - 1; /* bank end address */
+ int rc = 0;
+ int first = -1;
+ int last = -1;
+ int i;
+
+ if (to < info->start[0]) {
+ return (0);
+ }
+
+ for (i=0; i<info->sector_count; ++i) {
+ ulong end; /* last address in current sect */
+ short s_end;
+
+ s_end = info->sector_count - 1;
+
+ end = (i == s_end) ? b_end : info->start[i + 1] - 1;
+
+ if (from > end) {
+ continue;
+ }
+ if (to < info->start[i]) {
+ continue;
+ }
+
+ if (from == info->start[i]) {
+ first = i;
+ if (last < 0) {
+ last = s_end;
+ }
+ }
+ if (to == end) {
+ last = i;
+ if (first < 0) {
+ first = 0;
+ }
+ }
+ }
+
+ for (i=first; i<=last; ++i) {
+ if (flag & FLAG_PROTECT_CLEAR) {
+ info->protect[i] = 0;
+ } else if (flag & FLAG_PROTECT_SET) {
+ info->protect[i] = 1;
+ }
+ if (info->protect[i]) {
+ rc = 1;
+ }
+ }
+ return (rc);
+}
+
+
+/*-----------------------------------------------------------------------
+ */
+static void flash_get_offsets (ulong base, flash_info_t *info)
+{
+ int i;
+
+ /* set up sector start adress table */
+ if (info->flash_id & FLASH_BTYPE)
+ {
+ /* set sector offsets for bottom boot block type */
+ for (i = 0; i < info->sector_count; i++)
+ {
+ info->start[i] = base + (i * 0x00040000);
+ }
+ }
+ else
+ {
+ /* set sector offsets for top boot block type */
+ i = info->sector_count - 1;
+ for (; i >= 0; i--)
+ {
+ info->start[i] = base + i * 0x00040000;
+ }
+ }
+
+}
+
+/*-----------------------------------------------------------------------
+ */
+void flash_print_info (flash_info_t *info)
+{
+ int i;
+
+ if (info->flash_id == FLASH_UNKNOWN)
+ {
+ printf ("missing or unknown FLASH type\n");
+ return;
+ }
+
+ switch (info->flash_id & FLASH_VENDMASK)
+ {
+ case FLASH_MAN_AMD: printf ("AMD "); break;
+ case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
+ default: printf ("Unknown Vendor "); break;
+ }
+
+ switch (info->flash_id & FLASH_TYPEMASK)
+ {
+ case FLASH_AM040B: printf ("AM29F040B (4 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM040T: printf ("AM29F040T (4 Mbit, top boot sect)\n");
+ break;
+ case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM320B: printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM320T: printf ("AM29LV320T (32 Mbit, top boot sector)\n");
+ break;
+ default: printf ("Unknown Chip Type\n");
+ break;
+ }
+
+ printf (" Size: %ld MB in %d Sectors\n",info->size >> 20, info->sector_count);
+
+ printf (" Sector Start Addresses:");
+
+ for (i=0; i<info->sector_count; ++i)
+ {
+ if ((i % 5) == 0)
+ {
+ printf ("\n ");
+ }
+
+ printf (" %08lX%s", info->start[i],info->protect[i] ? " (RO)" : " " );
+ }
+
+ printf ("\n");
+}
+
+/*-----------------------------------------------------------------------
+ */
+
+
+/*-----------------------------------------------------------------------
+ */
+
+/*
+ * The following code cannot be run from FLASH!
+ */
+
+ulong flash_get_size (vu_long *addr, flash_info_t *info)
+{
+ short i;
+#if 0
+ ulong base = (ulong)addr;
+#endif
+ uchar value;
+
+ /* Write auto select command: read Manufacturer ID */
+#if 0
+ addr[0x0555] = 0x00AA00AA;
+ addr[0x02AA] = 0x00550055;
+ addr[0x0555] = 0x00900090;
+#else
+ addr[0x0555] = 0xAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+ addr[0x0555] = 0x90909090;
+#endif
+
+ value = addr[0];
+
+ switch (value)
+ {
+ case AMD_MANUFACT:case 0x01:
+ info->flash_id = FLASH_MAN_AMD;
+ break;
+
+ case FUJ_MANUFACT:
+ info->flash_id = FLASH_MAN_FUJ;
+ break;
+
+ default:
+ info->flash_id = FLASH_UNKNOWN;
+ info->sector_count = 0;
+ info->size = 0;
+ break;
+ }
+
+ value = addr[1]; /* device ID */
+
+ switch (value)
+ {
+ case AMD_ID_F040B:
+ info->flash_id += FLASH_AM040B;
+ info->sector_count = 8;
+ info->size = 0x00200000;
+ break; /* => 2 MB */
+
+ case AMD_ID_LV400T:
+ info->flash_id += FLASH_AM400T;
+ info->sector_count = 11;
+ info->size = 0x00100000;
+ break; /* => 1 MB */
+
+ case AMD_ID_LV400B:
+ info->flash_id += FLASH_AM400B;
+ info->sector_count = 11;
+ info->size = 0x00100000;
+ break; /* => 1 MB */
+
+ case AMD_ID_LV800T:
+ info->flash_id += FLASH_AM800T;
+ info->sector_count = 19;
+ info->size = 0x00200000;
+ break; /* => 2 MB */
+
+ case AMD_ID_LV800B:
+ info->flash_id += FLASH_AM800B;
+ info->sector_count = 19;
+ info->size = 0x00200000;
+ break; /* => 2 MB */
+
+ case AMD_ID_LV160T:
+ info->flash_id += FLASH_AM160T;
+ info->sector_count = 35;
+ info->size = 0x00400000;
+ break; /* => 4 MB */
+
+ case AMD_ID_LV160B:
+ info->flash_id += FLASH_AM160B;
+ info->sector_count = 35;
+ info->size = 0x00400000;
+ break; /* => 4 MB */
+#if 0 /* enable when device IDs are available */
+ case AMD_ID_LV320T:
+ info->flash_id += FLASH_AM320T;
+ info->sector_count = 67;
+ info->size = 0x00800000;
+ break; /* => 8 MB */
+
+ case AMD_ID_LV320B:
+ info->flash_id += FLASH_AM320B;
+ info->sector_count = 67;
+ info->size = 0x00800000;
+ break; /* => 8 MB */
+#endif
+ default:
+ info->flash_id = FLASH_UNKNOWN;
+ return (0); /* => no or unknown flash */
+
+ }
+
+#if 0
+ /* set up sector start adress table */
+ if (info->flash_id & FLASH_BTYPE) {
+ /* set sector offsets for bottom boot block type */
+ info->start[0] = base + 0x00000000;
+ info->start[1] = base + 0x00008000;
+ info->start[2] = base + 0x0000C000;
+ info->start[3] = base + 0x00010000;
+ for (i = 4; i < info->sector_count; i++) {
+ info->start[i] = base + (i * 0x00020000) - 0x00060000;
+ }
+ } else {
+ /* set sector offsets for top boot block type */
+ i = info->sector_count - 1;
+ info->start[i--] = base + info->size - 0x00008000;
+ info->start[i--] = base + info->size - 0x0000C000;
+ info->start[i--] = base + info->size - 0x00010000;
+ for (; i >= 0; i--) {
+ info->start[i] = base + i * 0x00020000;
+ }
+ }
+#else
+ flash_get_offsets ((ulong)addr, &flash_info[0]);
+#endif
+
+ /* check for protected sectors */
+ for (i = 0; i < info->sector_count; i++)
+ {
+ /* read sector protection at sector address, (A7 .. A0) = 0x02 */
+ /* D0 = 1 if protected */
+ addr = (volatile unsigned long *)(info->start[i]);
+ info->protect[i] = addr[2] & 1;
+ }
+
+ /*
+ * Prevent writes to uninitialized FLASH.
+ */
+ if (info->flash_id != FLASH_UNKNOWN)
+ {
+ addr = (volatile unsigned long *)info->start[0];
+#if 0
+ *addr = 0x00F000F0; /* reset bank */
+#else
+ *addr = 0xF0F0F0F0; /* reset bank */
+#endif
+ }
+
+ return (info->size);
+}
+
+
+/*-----------------------------------------------------------------------
+ */
+
+void flash_erase (flash_info_t *info, int s_first, int s_last)
+{
+ vu_long *addr = (vu_long*)(info->start[0]);
+ int flag, prot, sect, l_sect;
+ ulong start, now, last;
+
+ if ((s_first < 0) || (s_first > s_last)) {
+ if (info->flash_id == FLASH_UNKNOWN) {
+ printf ("- missing\n");
+ } else {
+ printf ("- no sectors to erase\n");
+ }
+ return;
+ }
+
+ if ((info->flash_id == FLASH_UNKNOWN) ||
+ (info->flash_id > FLASH_AMD_COMP)) {
+ printf ("Can't erase unknown flash type - aborted\n");
+ return;
+ }
+
+ prot = 0;
+ for (sect=s_first; sect<=s_last; ++sect) {
+ if (info->protect[sect]) {
+ prot++;
+ }
+ }
+
+ if (prot) {
+ printf ("- Warning: %d protected sectors will not be erased!\n",
+ prot);
+ } else {
+ printf ("\n");
+ }
+
+ l_sect = -1;
+
+ /* Disable interrupts which might cause a timeout here */
+ flag = disable_interrupts();
+
+#if 0
+ addr[0x0555] = 0x00AA00AA;
+ addr[0x02AA] = 0x00550055;
+ addr[0x0555] = 0x00800080;
+ addr[0x0555] = 0x00AA00AA;
+ addr[0x02AA] = 0x00550055;
+#else
+ addr[0x0555] = 0xAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+ addr[0x0555] = 0x80808080;
+ addr[0x0555] = 0xAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+#endif
+
+ /* Start erase on unprotected sectors */
+ for (sect = s_first; sect<=s_last; sect++) {
+ if (info->protect[sect] == 0) { /* not protected */
+ addr = (vu_long*)(info->start[sect]);
+#if 0
+ addr[0] = 0x00300030;
+#else
+ addr[0] = 0x30303030;
+#endif
+ l_sect = sect;
+ }
+ }
+
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ /* wait at least 80us - let's wait 1 ms */
+ udelay (1000);
+
+ /*
+ * We wait for the last triggered sector
+ */
+ if (l_sect < 0)
+ goto DONE;
+
+ start = get_timer (0);
+ last = start;
+ addr = (vu_long*)(info->start[l_sect]);
+#if 0
+ while ((addr[0] & 0x00800080) != 0x00800080)
+#else
+ while ((addr[0] & 0xFFFFFFFF) != 0xFFFFFFFF)
+#endif
+ {
+ if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+ printf ("Timeout\n");
+ return;
+ }
+ /* show that we're waiting */
+ if ((now - last) > 1000) { /* every second */
+ serial_putc ('.');
+ last = now;
+ }
+ }
+
+DONE:
+ /* reset to read mode */
+ addr = (volatile unsigned long *)info->start[0];
+#if 0
+ addr[0] = 0x00F000F0; /* reset bank */
+#else
+ addr[0] = 0xF0F0F0F0; /* reset bank */
+#endif
+
+ printf (" done\n");
+}
+
+/*-----------------------------------------------------------------------
+ */
+
+flash_info_t *addr2info (ulong addr)
+{
+ flash_info_t *info;
+ int i;
+
+ for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
+ if ((addr >= info->start[0]) &&
+ (addr < (info->start[0] + info->size)) ) {
+ return (info);
+ }
+ }
+
+ return (NULL);
+}
+
+/*-----------------------------------------------------------------------
+ * Copy memory to flash.
+ * Make sure all target addresses are within Flash bounds,
+ * and no protected sectors are hit.
+ * Returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ * 4 - target range includes protected sectors
+ * 8 - target address not in Flash memory
+ */
+int flash_write (uchar *src, ulong addr, ulong cnt)
+{
+ int i;
+ ulong end = addr + cnt - 1;
+ flash_info_t *info_first = addr2info (addr);
+ flash_info_t *info_last = addr2info (end );
+ flash_info_t *info;
+
+ if (cnt == 0) {
+ return (0);
+ }
+
+ if (!info_first || !info_last) {
+ return (8);
+ }
+
+ for (info = info_first; info <= info_last; ++info) {
+ ulong b_end = info->start[0] + info->size; /* bank end addr */
+ short s_end = info->sector_count - 1;
+ for (i=0; i<info->sector_count; ++i) {
+ ulong e_addr = (i == s_end) ? b_end : info->start[i + 1];
+
+ if ((end >= info->start[i]) && (addr < e_addr) &&
+ (info->protect[i] != 0) ) {
+ return (4);
+ }
+ }
+ }
+
+ /* finally write data to flash */
+ for (info = info_first; info <= info_last && cnt>0; ++info) {
+ ulong len;
+
+ len = info->start[0] + info->size - addr;
+ if (len > cnt)
+ len = cnt;
+ if ((i = write_buff(info, src, addr, len)) != 0) {
+ return (i);
+ }
+ cnt -= len;
+ addr += len;
+ src += len;
+ }
+ return (0);
+}
+
+/*-----------------------------------------------------------------------
+ * Copy memory to flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+
+static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+{
+ ulong cp, wp, data;
+ int i, l, rc;
+
+ wp = (addr & ~3); /* get lower word aligned address */
+
+ /*
+ * handle unaligned start bytes
+ */
+ if ((l = addr - wp) != 0) {
+ data = 0;
+ for (i=0, cp=wp; i<l; ++i, ++cp) {
+ data = (data << 8) | (*(uchar *)cp);
+ }
+ for (; i<4 && cnt>0; ++i) {
+ data = (data << 8) | *src++;
+ --cnt;
+ ++cp;
+ }
+ for (; cnt==0 && i<4; ++i, ++cp) {
+ data = (data << 8) | (*(uchar *)cp);
+ }
+
+ if ((rc = write_word(info, wp, data)) != 0) {
+ return (rc);
+ }
+ wp += 4;
+ }
+
+ /*
+ * handle word aligned part
+ */
+ while (cnt >= 4) {
+ data = 0;
+ for (i=0; i<4; ++i) {
+ data = (data << 8) | *src++;
+ }
+ if ((rc = write_word(info, wp, data)) != 0) {
+ return (rc);
+ }
+ wp += 4;
+ cnt -= 4;
+ }
+
+ if (cnt == 0) {
+ return (0);
+ }
+
+ /*
+ * handle unaligned tail bytes
+ */
+ data = 0;
+ for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+ data = (data << 8) | *src++;
+ --cnt;
+ }
+ for (; i<4; ++i, ++cp) {
+ data = (data << 8) | (*(uchar *)cp);
+ }
+
+ return (write_word(info, wp, data));
+}
+
+/*-----------------------------------------------------------------------
+ * Write a word to Flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+static int write_word (flash_info_t *info, ulong dest, ulong data)
+{
+ vu_long *addr = (vu_long*)(info->start[0]);
+ ulong start;
+ int flag;
+
+ /* Check if Flash is (sufficiently) erased */
+ if ((*((vu_long *)dest) & data) != data) {
+ return (2);
+ }
+ /* Disable interrupts which might cause a timeout here */
+ flag = disable_interrupts();
+
+#if 0
+ addr[0x0555] = 0x00AA00AA;
+ addr[0x02AA] = 0x00550055;
+ addr[0x0555] = 0x00A000A0;
+#else
+ addr[0x0555] = 0xAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+ addr[0x0555] = 0xA0A0A0A0;
+#endif
+
+ *((vu_long *)dest) = data;
+
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ /* data polling for D7 */
+ start = get_timer (0);
+#if 0
+ while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080))
+#else
+ while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080))
+#endif
+ {
+ if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+ return (1);
+ }
+ }
+ return (0);
+}
+
+/*-----------------------------------------------------------------------
+ */
--- /dev/null
+/*
+ * genietv/genietv.c
+ *
+ * The GENIETV is using the following physical memorymap (copied from
+ * the FADS configuration):
+ *
+ * ff020000 -> ff02ffff : pcmcia
+ * ff010000 -> ff01ffff : BCSR connected to CS1, setup by 8xxROM
+ * ff000000 -> ff00ffff : IMAP internal in the cpu
+ * 02800000 -> 0287ffff : flash connected to CS0
+ * 00000000 -> nnnnnnnn : sdram setup by PPCBOOT
+ *
+ * CS pins are connected as follows:
+ *
+ * CS0 -512Kb boot flash
+ * CS1 - SDRAM #1
+ * CS2 - SDRAM #2
+ * CS3 - Flash #1
+ * CS4 - Flash #2
+ * CS5 - LON (if present)
+ * CS6 - PCMCIA #1
+ * CS7 - PCMCIA #2
+ *
+ * Ports are configured as follows:
+ *
+ * PA7 - SDRAM banks enable
+ */
+
+#include <ppcboot.h>
+#include "mpc8xx.h"
+
+#define CFG_PA7 0x0100
+
+/* ------------------------------------------------------------------------- */
+
+static long int dram_size (long int, long int *, long int);
+
+/* ------------------------------------------------------------------------- */
+
+#define _NOT_USED_ 0xFFFFFFFF
+
+const uint sdram_table[] =
+{
+ /*
+ * Single Read. (Offset 0 in UPMB RAM)
+ */
+ 0x1F0DFC04, 0xEEAFBC04, 0x11AF7C04, 0xEFBEEC00,
+ 0x1FFDDC47, /* last */
+ /*
+ * SDRAM Initialization (offset 5 in UPMB RAM)
+ *
+ * This is no UPM entry point. The following definition uses
+ * the remaining space to establish an initialization
+ * sequence, which is executed by a RUN command.
+ *
+ */
+ 0x1FFDDC34, 0xEFEEAC34, 0x1FBD5C35, /* last */
+ /*
+ * Burst Read. (Offset 8 in UPMB RAM)
+ */
+ 0x1F0DFC04, 0xEEAFBC04, 0x10AF7C04, 0xF0AFFC00,
+ 0xF0AFFC00, 0xF1AFFC00, 0xEFBEEC00, 0x1FFDDC47, /* last */
+ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+ /*
+ * Single Write. (Offset 18 in UPMB RAM)
+ */
+ 0x1F2DFC04, 0xEEAFAC00, 0x01BE4C04, 0x1FFDDC47, /* last */
+ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+ /*
+ * Burst Write. (Offset 20 in UPMB RAM)
+ */
+ 0x1F0DFC04, 0xEEAFAC00, 0x10AF5C00, 0xF0AFFC00,
+ 0xF0AFFC00, 0xE1BEEC04, 0x1FFDDC47, /* last */
+ _NOT_USED_,
+ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+ /*
+ * Refresh (Offset 30 in UPMB RAM)
+ */
+ 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
+ 0xFFFFFC84, 0xFFFFFC07, /* last */
+ _NOT_USED_, _NOT_USED_,
+ _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
+ /*
+ * Exception. (Offset 3c in UPMB RAM)
+ */
+ 0x7FFFFC07, /* last */
+ _NOT_USED_, _NOT_USED_, _NOT_USED_,
+};
+
+/* ------------------------------------------------------------------------- */
+
+
+/*
+ * Check Board Identity
+ */
+
+int checkboard (void)
+{
+ printf("GenieTV\n");
+ return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+long int initdram (int board_type)
+{
+ volatile immap_t *im = (immap_t *)CFG_IMMR;
+ volatile memctl8xx_t *memctl = &im->im_memctl;
+ long int size_b0, size_b1, size8;
+
+ /* Enable SDRAM */
+
+ // Configuring PA7 for general purpouse output pin
+ im->im_ioport.iop_papar &= ~CFG_PA7 ; // 0 = general purpouse
+ im->im_ioport.iop_padir |= CFG_PA7 ; // 1 = output
+
+ // Enable SDRAM - PA7 = 1
+ im->im_ioport.iop_padat |= CFG_PA7 ; // value of PA7
+
+ /*
+ * Preliminary prescaler for refresh (depends on number of
+ * banks): This value is selected for four cycles every 62.4 us
+ * with two SDRAM banks or four cycles every 31.2 us with one
+ * bank. It will be adjusted after memory sizing.
+ */
+ memctl->memc_mptpr = CFG_MPTPR_2BK_4K;
+
+ memctl->memc_mbmr = CFG_MBMR_8COL;
+
+ printf ("\nConfiguring UPMB...");
+ upmconfig(UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
+
+ /*
+ * Map controller banks 1 and 2 to the SDRAM banks 1 and 2 at
+ * preliminary addresses - these have to be modified after the
+ * SDRAM size has been determined.
+ */
+ memctl->memc_or1 = CFG_OR1_PRELIM;
+ memctl->memc_br1 = CFG_BR1_PRELIM;
+
+ memctl->memc_or2 = CFG_OR2_PRELIM;
+ memctl->memc_br2 = CFG_BR2_PRELIM;
+
+ /* perform SDRAM initializsation sequence */
+ memctl->memc_mar = 0x00000088;
+
+ memctl->memc_mcr = 0x80802105; /* SDRAM bank 0 */
+
+ memctl->memc_mcr = 0x80804105; /* SDRAM bank 1 */
+
+ memctl->memc_mcr = 0x80802230; /* SDRAM bank 0 - execute twice */
+
+ memctl->memc_mcr = 0x80804230; /* SDRAM bank 1 - execute twice */
+
+ /*
+ * Check Bank 0 Memory Size for re-configuration
+ *
+ * try 8 column mode
+ */
+ printf ("\nChecking bank1...");
+ size8 = dram_size (CFG_MBMR_8COL, (ulong *)SDRAM_BASE1_PRELIM, SDRAM_MAX_SIZE);
+
+ size_b0 = size8 ;
+ memctl->memc_mbmr = CFG_MBMR_8COL;
+
+ printf ("\nChecking bank2...");
+ size_b1 = dram_size (memctl->memc_mbmr, (ulong *)SDRAM_BASE2_PRELIM,SDRAM_MAX_SIZE);
+
+ /*
+ * Adjust refresh rate depending on SDRAM type, both banks
+ * For types > 128 MBit leave it at the current (fast) rate
+ */
+ if ((size_b0 < 0x02000000) && (size_b1 < 0x02000000))
+ {
+ printf("\nReducing refresh rate!");
+ /* reduce to 15.6 us (62.4 us / quad) */
+ memctl->memc_mptpr = CFG_MPTPR_2BK_4K;
+ }
+
+ /*
+ * Final mapping: map bigger bank first
+ */
+
+ memctl->memc_or1 = ((-size_b0) & 0xFFFF0000) | CFG_OR_TIMING_SDRAM;
+ memctl->memc_br1 = (CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMB | BR_V;
+
+ if (size_b1 > 0)
+ {
+ /*
+ * Position Bank 1 immediately above Bank 0
+ */
+ memctl->memc_or2 = ((-size_b1) & 0xFFFF0000) | CFG_OR_TIMING_SDRAM;
+ memctl->memc_br2 = ((CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMB | BR_V) + size_b0;
+ }
+ else
+ {
+ unsigned long reg;
+ /*
+ * No bank 1
+ *
+ * invalidate bank
+ */
+ memctl->memc_br2 = 0;
+
+ /* adjust refresh rate depending on SDRAM type, one bank */
+ reg = memctl->memc_mptpr;
+ reg >>= 1; /* reduce to CFG_MPTPR_1BK_8K / _4K */
+ memctl->memc_mptpr = reg;
+ }
+
+ // If no memory detected, disable SDRAM
+ if ((size_b0 + size_b1) == 0)
+ {
+ printf("disabling SDRAM!\n");
+ // Disable SDRAM - PA7 = 1
+ im->im_ioport.iop_padat &= ~CFG_PA7 ; // value of PA7
+ }
+ else
+ printf("done! (%08lx)\n", size_b0 + size_b1);
+
+ return (size_b0 + size_b1);
+}
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Check memory range for valid RAM. A simple memory test determines
+ * the actually available RAM size between addresses `base' and
+ * `base + maxsize'. Some (not all) hardware errors are detected:
+ * - short between address lines
+ * - short between data lines
+ */
+
+static long int dram_size (long int mbmr_value, long int *base, long int maxsize)
+{
+ volatile immap_t *immap = (immap_t *)CFG_IMMR;
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
+ volatile long int *addr;
+ long int cnt, val;
+
+ memctl->memc_mbmr = mbmr_value;
+
+ for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
+ addr = base + cnt; /* pointer arith! */
+
+ *addr = ~cnt;
+ }
+
+ /* write 0 to base address */
+ addr = base;
+ *addr = 0;
+
+ /* check at base address */
+ if ((val = *addr) != 0) {
+ printf("(0)");
+ return (0);
+ }
+
+ for (cnt = 1; ; cnt <<= 1) {
+ addr = base + cnt; /* pointer arith! */
+
+ val = *addr;
+
+ if (val != (~cnt)) {
+ printf("(%08lx)", cnt*sizeof(long));
+ return (cnt * sizeof(long));
+ }
+ }
+ /* NOTREACHED */
+}
--- /dev/null
+/*
+ * The GENIETV is using the following physical memorymap (copied from
+ * the FADS configuration):
+ *
+ * ff020000 -> ff02ffff : pcmcia
+ * ff010000 -> ff01ffff : BCSR connected to CS1, setup by 8xxROM
+ * ff000000 -> ff00ffff : IMAP internal in the cpu
+ * 02800000 -> 0287ffff : flash connected to CS0
+ * 00000000 -> nnnnnnnn : sdram setup by PPCBOOT
+ *
+ * CS pins are connected as follows:
+ *
+ * CS0 -512Kb boot flash
+ * CS1 - SDRAM #1
+ * CS2 - SDRAM #2
+ * CS3 - Flash #1
+ * CS4 - Flash #2
+ * CS5 - LON (if present)
+ * CS6 - PCMCIA #1
+ * CS7 - PCMCIA #2
+ *
+ * Ports are configured as follows:
+ *
+ * PA7 - SDRAM banks enable
+ */
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = + SIZEOF_HEADERS;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .rel.text : { *(.rel.text) }
+ .rela.text : { *(.rela.text) }
+ .rel.data : { *(.rel.data) }
+ .rela.data : { *(.rela.data) }
+ .rel.rodata : { *(.rel.rodata) }
+ .rela.rodata : { *(.rela.rodata) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { *(.init) }
+ .plt : { *(.plt) }
+ .text :
+ {
+ /* WARNING - the following is hand-optimized to fit within */
+ /* the sector layout of our flash chips! XXX FIXME XXX */
+
+ mpc8xx/start.o (.text)
+/*
+ mpc8xx/start.o (.text)
+ common/dlmalloc.o (.text)
+ ppc/ppcstring.o (.text)
+ ppc/vsprintf.o (.text)
+ ppc/crc32.o (.text)
+ ppc/zlib.o (.text)
+
+ . = env_offset;
+ common/environment.o(.text)
+*/
+
+ *(.text)
+ *(.fixup)
+ *(.got1)
+ }
+ _etext = .;
+ PROVIDE (etext = .);
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata1)
+ }
+ .fini : { *(.fini) } =0
+ .ctors : { *(.ctors) }
+ .dtors : { *(.dtors) }
+
+ /* Read-write section, merged into data segment: */
+ . = (. + 0x0FFF) & 0xFFFFF000;
+ _erotext = .;
+ PROVIDE (erotext = .);
+ .reloc :
+ {
+ *(.got)
+ _GOT2_TABLE_ = .;
+ *(.got2)
+ _FIXUP_TABLE_ = .;
+ *(.fixup)
+ }
+ __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+ __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+ .data :
+ {
+ *(.data)
+ *(.data1)
+ *(.sdata)
+ *(.sdata2)
+ *(.dynamic)
+ CONSTRUCTORS
+ }
+ _edata = .;
+ PROVIDE (edata = .);
+
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ . = ALIGN(4096);
+ __init_begin = .;
+ .text.init : { *(.text.init) }
+ .data.init : { *(.data.init) }
+ . = ALIGN(4096);
+ __init_end = .;
+
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss) *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ . = 0x02840000;
+ .ppcenv :
+ {
+ common/environment.o (.ppcenv)
+ }
+ _end = . ;
+ PROVIDE (end = .);
+}
+
#if (CONFIG_COMMANDS & CFG_CMD_BDI)
#define CMD_TBL_BDINFO MK_CMD_TBL_ENTRY( \
- "bdinfo", 2, 1, do_bdinfo, \
+ "bdinfo", 2, 1, 1, do_bdinfo, \
"bdinfo - print Board Info structure\n", \
NULL \
),
#define CMD_TBL_GO MK_CMD_TBL_ENTRY( \
- "go", 2, CFG_MAXARGS, do_go, \
+ "go", 2, CFG_MAXARGS, 1, do_go, \
"go - start application at address 'addr'\n", \
"addr [arg ...]\n - start application at address 'addr'\n" \
" passing 'arg' as arguments\n" \
#if (CONFIG_COMMANDS & CFG_CMD_LOADS)
#ifdef CFG_LOADS_BAUD_CHANGE
#define CMD_TBL_LOADS MK_CMD_TBL_ENTRY( \
- "loads", 5, 3, do_load_serial, \
+ "loads", 5, 3, 0, do_load_serial, \
"loads - load S-Record file over serial line\n", \
"[ off ] [ baud ]\n" \
" - load S-Record file over serial line" \
),
#else /* ! CFG_LOADS_BAUD_CHANGE */
#define CMD_TBL_LOADS MK_CMD_TBL_ENTRY( \
- "loads", 5, 2, do_load_serial, \
+ "loads", 5, 2, 0, do_load_serial, \
"loads - load S-Record file over serial line\n", \
"[ off ]\n" \
" - load S-Record file over serial line with offset 'off'\n" \
#if (CONFIG_COMMANDS & CFG_CMD_LOADB)
#define CMD_TBL_LOADB MK_CMD_TBL_ENTRY( \
- "loadb", 5, 3, do_load_serial_bin, \
+ "loadb", 5, 3, 0, do_load_serial_bin, \
"loadb - load binary file over serial line (kermit mode)\n", \
"[ off ] [ baud ]\n" \
" - load binary file over serial line" \
#endif /* CFG_CMD_LOADB */
#define CMD_TBL_RESET MK_CMD_TBL_ENTRY( \
- "reset", 5, 1, do_reset, \
+ "reset", 5, 1, 0, do_reset, \
"reset - Perform RESET of the CPU\n", \
NULL \
),
void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
#define CMD_TBL_BOOTM MK_CMD_TBL_ENTRY( \
- "bootm", 5, CFG_MAXARGS, do_bootm, \
+ "bootm", 5, CFG_MAXARGS, 1, do_bootm, \
"bootm - boot application image from memory\n", \
"addr [arg ...]\n - boot application image stored in memory\n" \
" passing arguments 'arg ...'; when booting a Linux kernel,\n" \
void do_bootd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
#define CMD_TBL_BOOTD MK_CMD_TBL_ENTRY( \
- "bootd", 4, 1, do_bootd, \
+ "bootd", 4, 1, 1, do_bootd, \
"bootd - boot default, i.e., run 'bootcmd'\n", \
NULL \
),
void do_iminfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
#define CMD_TBL_IMINFO MK_CMD_TBL_ENTRY( \
- "iminfo", 3, CFG_MAXARGS, do_iminfo, \
+ "iminfo", 3, CFG_MAXARGS, 1, do_iminfo, \
"iminfo - print header information for application image\n", \
"addr [addr ...]\n" \
" - print header information for application image starting at\n" \
#if (CONFIG_COMMANDS & CFG_CMD_CACHE)
#define CMD_TBL_ICACHE MK_CMD_TBL_ENTRY( \
- "icache", 2, 2, do_icache, \
+ "icache", 2, 2, 1, do_icache, \
"icache - enable or disable instruction cache\n", \
"[on, off]\n" \
" - enable or disable instruction cache\n" \
),
#define CMD_TBL_DCACHE MK_CMD_TBL_ENTRY( \
- "dcache", 2, 2, do_dcache, \
+ "dcache", 2, 2, 1, do_dcache, \
"dcache - enable or disable data cache\n", \
"[on, off]\n" \
" - enable or disable data (writethrough) cache\n" \
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Definitions for Configuring the monitor commands
+ */
+#ifndef _CMD_CONFIG_H
+#define _CMD_CONFIG_H
+
+/*
+ * Configurable monitor commands
+ */
+#define CFG_CMD_BDI 0x00000001 /* bdinfo */
+#define CFG_CMD_LOADS 0x00000002 /* loads */
+#define CFG_CMD_LOADB 0x00000004 /* loadb */
+#define CFG_CMD_IMI 0x00000008 /* iminfo */
+#define CFG_CMD_CACHE 0x00000010 /* icache, dcache */
+#define CFG_CMD_FLASH 0x00000020 /* flinfo, erase, protect */
+#define CFG_CMD_MEMORY 0x00000040 /* md, mm, nm, mw, cp, cmp, */
+ /* crc, base, loop, mtest */
+#define CFG_CMD_NET 0x00000080 /* bootp, tftpboot, rarpboot */
+#define CFG_CMD_ENV 0x00000100 /* saveenv */
+#define CFG_CMD_KGDB 0x00000200 /* kgdb */
+#define CFG_CMD_IDE 0x00000400 /* IDE harddisk support */
+#define CFG_CMD_PCI 0x00000800 /* pciinfo */
+#define CFG_CMD_IRQ 0x00001000 /* irqinfo */
+#define CFG_CMD_BOOTD 0x00002000 /* bootd */
+#define CFG_CMD_CONSOLE 0x00004000 /* coninfo */
+
+#define CFG_CMD_ALL 0xFFFFFFFF /* ALL commands */
+
+/* Commands that are considered "non-standard" for some reason
+ * (memory hogs, requires special hardware, not fully tested, etc.)
+ */
+#define CFG_CMD_NONSTD (CFG_CMD_KGDB | CFG_CMD_IDE | CFG_CMD_PCI | CFG_CMD_IRQ)
+
+/* Default configuration
+ */
+#define CONFIG_CMD_DFL (CFG_CMD_ALL & ~CFG_CMD_NONSTD)
+
+#ifndef CONFIG_COMMANDS
+#define CONFIG_COMMANDS CONFIG_CMD_DFL
+#endif
+
+#endif /* _CMD_CONFIG_H */
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Network boot support
+ */
+#ifndef _CMD_CONSOLE_H
+#define _CMD_CONSOLE_H
+
+#if (CONFIG_COMMANDS & CFG_CMD_CONSOLE)
+#define CMD_TBL_CONINFO MK_CMD_TBL_ENTRY( \
+ "coninfo", 5, 3, 1, do_coninfo, \
+ "coninfo - print console devices and informations\n", \
+ "" \
+),
+
+void do_coninfo (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+
+#endif /* CFG_CMD_CONSOLE */
+
+#endif
#include <ppcboot.h>
#include <command.h>
-#if (CONFIG_COMMANDS & CFG_CMD_IDE)
-#define CMD_TBL_PART MK_CMD_TBL_ENTRY( \
- "partition", 4, 2, do_partition, \
- "partition - print harddisk partition map", \
- NULL \
-),
+/*
+ * Type string for PPC bootable partitions
+ */
+#define BOOT_PART_TYPE "PPCBoot"
+
+typedef struct disk_partition {
+ ulong start; /* # of first block in partition */
+ ulong size; /* number of blocks in partition */
+ ulong blksz; /* block size in bytes */
+ uchar name[32]; /* partition name */
+ uchar type[32]; /* string type description */
+} disk_partition_t;
-void do_partition (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
-#else
-#define CMD_TBL_PART
-#endif
+int get_partition_info (int dev, int part, disk_partition_t *info);
#endif /* _CMD_DISK_H */
#if (CONFIG_COMMANDS & CFG_CMD_FLASH)
#define CMD_TBL_FLINFO MK_CMD_TBL_ENTRY( \
- "flinfo", 3, 2, do_flinfo, \
+ "flinfo", 3, 2, 1, do_flinfo, \
"flinfo - print FLASH memory information\n", \
"\n - print information for all FLASH memory banks\n" \
"flinfo N\n - print information for FLASH memory bank # N\n" \
),
#define CMD_TBL_FLERASE MK_CMD_TBL_ENTRY( \
- "erase", 3, 3, do_flerase, \
+ "erase", 3, 3, 1, do_flerase, \
"erase - erase FLASH memory\n", \
"start end\n" \
" - erase FLASH from addr 'start' to addr 'end'\n" \
),
#define CMD_TBL_PROTECT MK_CMD_TBL_ENTRY( \
- "protect", 4, 4, do_protect, \
+ "protect", 4, 4, 1, do_protect, \
"protect - enable or disable FLASH write protection\n", \
"on start end\n" \
" - protect FLASH from addr 'start' to addr 'end'\n" \
#endif /* CFG_CMD_FLASH */
#endif /* _CMD_FLASH_H */
-
#include <ppcboot.h>
#include <command.h>
+
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
#define CMD_TBL_IDE MK_CMD_TBL_ENTRY( \
- "ide", 3, 5, do_ide, \
+ "ide", 3, 5, 1, do_ide, \
"ide - IDE sub-system", \
"reset - reset IDE controller\n" \
"ide info - show available IDE devices\n" \
"ide device [dev] - show or set current device\n" \
+ "ide part [dev] - print partition table of one or all IDE devices\n" \
"ide read addr blk# cnt\n" \
"ide write addr blk# cnt - read/write `cnt'" \
" blocks starting at block `blk#'\n" \
" to/from memory address `addr'\n" \
),
+#define CMD_TBL_DISK MK_CMD_TBL_ENTRY( \
+ "diskboot", 4, 3, 1, do_diskboot, \
+ "diskboot- boot from IDE device", \
+ "diskboot loadAddr dev:part\n" \
+),
+
void do_ide (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+void do_diskboot (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
+
#else
#define CMD_TBL_IDE
+#define CMD_TBL_DISK
#endif
#endif /* _CMD_IDE_H */
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CMD_TBL_KGDB MK_CMD_TBL_ENTRY( \
- "kgdb", 4, CFG_MAXARGS, do_kgdb, \
+ "kgdb", 4, CFG_MAXARGS, 1, do_kgdb, \
"kgdb - enter gdb remote debug mode\n", \
"\n - executes a breakpoint so that kgdb mode is\n" \
" entered via the exception handler. To return\n" \
#if (CONFIG_COMMANDS & CFG_CMD_MEMORY)
#define CMD_TBL_MD MK_CMD_TBL_ENTRY( \
- "md", 2, 3, do_mem_md, \
+ "md", 2, 3, 1, do_mem_md, \
"md - memory display\n", \
"[.b, .w, .l] address [# of objects]\n - memory display\n" \
),
#define CMD_TBL_MM MK_CMD_TBL_ENTRY( \
- "mm", 2, 2, do_mem_mm, \
+ "mm", 2, 2, 1, do_mem_mm, \
"mm - memory modify (auto-incrementing)\n", \
"[.b, .w, .l] address\n" \
" - memory modify, auto increment address\n" \
),
#define CMD_TBL_NM MK_CMD_TBL_ENTRY( \
- "nm", 2, 2, do_mem_nm, \
+ "nm", 2, 2, 1, do_mem_nm, \
"nm - memory modify (constant address)\n", \
"[.b, .w, .l] address\n - memory modify, read and keep address\n" \
),
#define CMD_TBL_MW MK_CMD_TBL_ENTRY( \
- "mw", 2, 4, do_mem_mw, \
+ "mw", 2, 4, 1, do_mem_mw, \
"mw - memory write (fill)\n", \
"[.b, .w, .l] address value [count]\n - write memory\n" \
),
#define CMD_TBL_CP MK_CMD_TBL_ENTRY( \
- "cp", 2, 4, do_mem_cp, \
+ "cp", 2, 4, 1, do_mem_cp, \
"cp - memory copy\n", \
"[.b, .w, .l] source target count\n - copy memory\n" \
),
#define CMD_TBL_CMP MK_CMD_TBL_ENTRY( \
- "cmp", 3, 4, do_mem_cmp, \
+ "cmp", 3, 4, 1, do_mem_cmp, \
"cmp - memory compare\n", \
"[.b, .w, .l] addr1 addr2 count\n - compare memory\n" \
),
#define CMD_TBL_CRC MK_CMD_TBL_ENTRY( \
- "crc32", 3, 4, do_mem_crc, \
+ "crc32", 3, 4, 1, do_mem_crc, \
"crc32 - checksum calculation\n", \
"address count\n - compute CRC32 checksum\n" \
),
#define CMD_TBL_BASE MK_CMD_TBL_ENTRY( \
- "base", 2, 2, do_mem_base, \
+ "base", 2, 2, 1, do_mem_base, \
"base - print or set address offset\n", \
"\n - print address offset fpr memory commands\n" \
"base off\n - set address offset for memory commands to 'off'\n" \
* Require full name for "loop" and "mtest" because these are infinite loops!
*/
#define CMD_TBL_LOOP MK_CMD_TBL_ENTRY( \
- "loop", 4, 3, do_mem_loop, \
+ "loop", 4, 3, 1, do_mem_loop, \
"loop - infinite loop on address range\n", \
"[.b, .w, .l] address number_of_objects\n" \
" - loop on a set of addresses\n" \
),
#define CMD_TBL_MTEST MK_CMD_TBL_ENTRY( \
- "mtest", 5, 1, do_mem_mtest, \
+ "mtest", 5, 1, 1, do_mem_mtest, \
"mtest - simple RAM test\n", \
"\n - simple SDRAM read/write test\n" \
),
#if (CONFIG_COMMANDS & CFG_CMD_PCI)
#define CMD_TBL_PCIINFO MK_CMD_TBL_ENTRY( \
- "pciinfo", 3, 2, do_pciinfo, \
+ "pciinfo", 3, 2, 1, do_pciinfo, \
"pciinfo - print information about PCI devices\n", \
"[ bus ]\n" \
" - print information about PCI devices on PCI-Bus 'bus'\n" \
#if (CONFIG_COMMANDS & CFG_CMD_IRQ)
#define CMD_TBL_IRQINFO MK_CMD_TBL_ENTRY( \
- "irqinfo", 3, 1, do_irqinfo, \
+ "irqinfo", 3, 1, 1, do_irqinfo, \
"irqinfo - print information about IRQs\n", \
NULL \
),
#if (CONFIG_COMMANDS & CFG_CMD_NET)
#define CMD_TBL_BOOTP MK_CMD_TBL_ENTRY( \
- "bootp", 5, 3, do_bootp, \
- "bootp - boot image via network using BootP/TFTP protocol\n", \
+ "bootp", 5, 3, 1, do_bootp, \
+ "bootp - boot image via network using BootP/TFTP protocol\n", \
"[loadAddress] [bootfilename]\n" \
),
void do_bootp (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
#define CMD_TBL_TFTPB MK_CMD_TBL_ENTRY( \
- "tftpboot", 4, 3, do_tftpb, \
+ "tftpboot", 4, 3, 1, do_tftpb, \
"tftpboot- boot image via network using TFTP protocol\n" \
" and env variables ipaddr and serverip\n", \
"[loadAddress] [bootfilename]\n" \
#define CMD_TBL_RARPB MK_CMD_TBL_ENTRY( \
- "rarpboot", 4, 3, do_rarpb, \
+ "rarpboot", 4, 3, 1, do_rarpb, \
"rarpboot- boot image via network using RARP/TFTP protocol\n", \
"[loadAddress] [bootfilename]\n" \
),
#define _CMD_NVEDIT_H
#define CMD_TBL_PRINTENV MK_CMD_TBL_ENTRY( \
- "printenv", 8, CFG_MAXARGS, do_printenv, \
+ "printenv", 8, CFG_MAXARGS, 1, do_printenv, \
"printenv- print environment variables\n", \
"\n - print values of all environment variables\n" \
"printenv name ...\n" \
void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
#define CMD_TBL_SETENV MK_CMD_TBL_ENTRY( \
- "setenv", 6, CFG_MAXARGS, do_setenv, \
+ "setenv", 6, CFG_MAXARGS, 1, do_setenv, \
"setenv - set environment variables\n", \
"name value ...\n" \
" - set environment variable 'name' to 'value ...'\n" \
#if ((CONFIG_COMMANDS & (CFG_CMD_ENV|CFG_CMD_FLASH)) == (CFG_CMD_ENV|CFG_CMD_FLASH))
#define CMD_TBL_SAVEENV MK_CMD_TBL_ENTRY( \
- "saveenv", 4, 1, do_saveenv, \
+ "saveenv", 4, 1, 1, do_saveenv, \
"saveenv - save environment variables to persistent storage\n", \
NULL \
),
#define _CMD_PCMCIA_H
#define CMD_TBL_PINIT MK_CMD_TBL_ENTRY( \
- "pinit", 4, 2, do_pinit, \
+ "pinit", 4, 2, 1, do_pinit, \
"pinit - initialize PCMCIA sub-system\n", \
NULL \
),
char *name; /* Command Name */
int lmin; /* minimum abbreviated length */
int maxargs; /* maximum number of arguments */
+ int repeatable; /* autorepeat allowed? */
/* Implementation function */
void (*cmd)(struct cmd_tbl_s *, bd_t *, int, int, char *[]);
char *usage; /* Usage message (short) */
extern cmd_tbl_t cmd_tbl[];
#ifdef CFG_LONGHELP
-#define MK_CMD_TBL_ENTRY(name,lmin,maxargs,cmd,usage,help) \
- { name, lmin, maxargs, cmd, usage, help }
+#define MK_CMD_TBL_ENTRY(name,lmin,maxargs,rep,cmd,usage,help) \
+ { name, lmin, maxargs, rep, cmd, usage, help }
#else /* no help info */
-#define MK_CMD_TBL_ENTRY(name,lmin,maxargs,cmd,usage,help) \
- { name, lmin, maxargs, cmd, usage }
+#define MK_CMD_TBL_ENTRY(name,lmin,maxargs,rep,cmd,usage,help) \
+ { name, lmin, maxargs, rep, cmd, usage }
#endif
/*
* Command Flags:
*/
-#define CMD_FLAG_REPEAT 0x0001 /* repeat same command as before */
+#define CMD_FLAG_REPEAT 0x0001 /* repeat last command */
/*
- * Configurable monitor commands
+ * Configurable monitor commands definitions have been moved
+ * to include/cmd_confdefs.h
*/
-#define CFG_CMD_BDI 0x00000001 /* bdinfo */
-#define CFG_CMD_LOADS 0x00000002 /* loads */
-#define CFG_CMD_LOADB 0x00000004 /* loadb */
-#define CFG_CMD_IMI 0x00000008 /* iminfo */
-#define CFG_CMD_CACHE 0x00000010 /* icache, dcache */
-#define CFG_CMD_FLASH 0x00000020 /* flinfo, erase, protect */
-#define CFG_CMD_MEMORY 0x00000040 /* md, mm, nm, mw, cp, cmp, */
- /* crc, base, loop, mtest */
-#define CFG_CMD_NET 0x00000080 /* bootp, tftpboot, rarpboot */
-#define CFG_CMD_ENV 0x00000100 /* saveenv */
-#define CFG_CMD_KGDB 0x00000200 /* kgdb */
-#define CFG_CMD_IDE 0x00000400 /* IDE harddisk support */
-#define CFG_CMD_PCI 0x00000800 /* pciinfo */
-#define CFG_CMD_IRQ 0x00001000 /* irqinfo */
-#define CFG_CMD_BOOTD 0x00002000 /* bootd */
-
-#define CFG_CMD_ALL 0xFFFFFFFF /* ALL commands */
-
-/* Commands that are considered "non-standard" for some reason
- * (memory hogs, requires special hardware, not fully tested, etc.)
- */
-#define CFG_CMD_NONSTD (CFG_CMD_KGDB | CFG_CMD_IDE | CFG_CMD_PCI | CFG_CMD_IRQ)
-
-/* Default configuration
- */
-#define CONFIG_CMD_DFL (CFG_CMD_ALL & ~CFG_CMD_NONSTD)
-
-#ifndef CONFIG_COMMANDS
-#define CONFIG_COMMANDS CONFIG_CMD_DFL
-#endif
#endif /* __COMMAND_H */
#endif /* CONFIG_FADS823FADS */
+/*** GENIETV ********************************************************/
+
+#if defined(CONFIG_GENIETV)
+// Ethernet is only on SCC2
+
+#define CONFIG_SCC2_ENET
+#define PROFF_ENET PROFF_SCC2
+#define CPM_CR_ENET CPM_CR_CH_SCC2
+#define SCC_ENET 1
+#define CPMVEC_ENET CPMVEC_SCC2
+
+#define PA_ENET_RXD ((ushort)0x0004)
+#define PA_ENET_TXD ((ushort)0x0008)
+#define PA_ENET_TCLK ((ushort)0x0400)
+#define PA_ENET_RCLK ((ushort)0x0200)
+
+#define PB_ENET_TENA ((uint)0x00002000)
+
+#define PC_ENET_CLSN ((ushort)0x0040)
+#define PC_ENET_RENA ((ushort)0x0080)
+
+#define SICR_ENET_MASK ((uint)0x0000ff00)
+#define SICR_ENET_CLKRT ((uint)0x00002e00)
+
+/* 68160 PHY control */
+
+#define PC_ENET_ETHLOOP ((ushort)0x0800)
+#define PC_ENET_TPFLDL ((ushort)0x0400)
+#define PC_ENET_TPSQEL ((ushort)0x0200)
+
+#endif /* CONFIG_GENIETV */
+
/*** FADS850SAR ********************************************************/
#if defined(CONFIG_MPC850SAR) && defined(CONFIG_FADS)
ushort iic_tbptr; /* Internal */
ushort iic_tbc; /* Internal */
uint iic_txtmp; /* Internal */
+ uint iic_res; /* reserved */
+ ushort iic_rpbase; /* Relocation pointer */
+ ushort iic_res2; /* reserved */
} iic_t;
#define BD_IIC_START ((ushort)0x0400)
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#define CFG_LOADS_BAUD_CHANGE 1 /* allow baudrate change */
-#define CONFIG_DRAM_SPEED (CONFIG_BUSCLOCK) /* MHz */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
#define CONFIG_COMMANDS (CONFIG_CMD_DFL & ~CFG_CMD_NET) /* no network on ADCIOP */
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
*/
#define CFG_SDRAM_BASE 0x00000000
#define CFG_FLASH_BASE 0xFFFE0000
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*
* Init Memory Controller:
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "=> " /* Monitor Command Prompt */
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif /* CONFIG_WATCHDOG */
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
/*
* 1999-nov-26: The FADS is using the following physical memorymap:
*
- * f4000000 -> f400ffff : pcmcia
- * 02100000 -> 0210ffff : BCSR connected to CS1, setup by 8xxROM
+ * ff020000 -> ff02ffff : pcmcia io remapping
+ * ff010000 -> ff01ffff : BCSR connected to CS1, setup by PPCBOOT
* ff000000 -> ff00ffff : IMAP internal in the cpu
- * 02800000 -> 028nnnnn : flash connected to CS0, setup by 8xxROM
- * 00000000 -> nnnnnnnn : sdram/dram setup by 8xxrom
- */
+ * e0000000 -> f3ffffff : pcmcia memory remapping by m8xx_pcmcia
+ * fe000000 -> fe1fffff : flash connected to CS0, setup by PPCBOOT
+ * 00000000 -> nnnnnnnn : sdram/dram setup by PPCBOOT
+*/
+
+#define CFG_PCMCIA_IO_ADDR 0xff020000
+#define CFG_PCMCIA_IO_SIZE 0x10000
+#define CFG_PCMCIA_MEM_ADDR 0xe0000000
+#define CFG_PCMCIA_MEM_SIZE 0x10000
+#define CFG_IMMR 0xFF000000
+#define CFG_SDRAM_BASE 0x00000000
+#define CFG_FLASH_BASE 0x02800000
+#define BCSR_ADDR ((uint) 0xff010000)
+#define FLASH_BASE0_PRELIM 0x02800000 /* FLASH bank #0 */
/* ------------------------------------------------------------------------- */
#define CONFIG_ETHADDR 08:00:22:50:70:63 // Ethernet address
#define CONFIG_ENV_OVERWRITE 1 // Overwrite the environment
-#define CONFIG_VIDEO 1 // To enable the video initialization
-#define CONFIG_PCMCIA 1 // To enable the PCMCIA initialization
-#define CONFIG_I2C 1 // To enable I2C support
+#define CONFIG_VIDEO 1 // To enable the video initialization
+#define CONFIG_PCMCIA 1 // To enable the PCMCIA initialization
/* Video related */
#define CONFIG_VIDEO_ENCODER_AD7176 1 // Enable this encoder
#define CONFIG_VIDEO_ENCODER_AD7176_ADDR 0x54 // Default on fads
#define CONFIG_VIDEO_SIZE (2*1024*1024)
-#define CONFIG_VIDEO_ADDR (bd->bi_memsize - CONFIG_VIDEO_SIZE) // Frame buffer address
+#define CONFIG_VIDEO_ADDR (bd_ptr->bi_memsize - CONFIG_VIDEO_SIZE) // Frame buffer address
/* Wireless 56Khz 4PPM keyboard on SMCx */
-#define CONFIG_WL_4PPM_KEYBOARD 1
+//#define CONFIG_WL_4PPM_KEYBOARD 1
#define CONFIG_WL_4PPM_KEYBOARD_SMC 0 // SMC to use (0 indexed)
/*
#define CONFIG_MPC823 1
#define CONFIG_MPC823FADS 1
-#define CONFIG_FADS 1
-
-#define CONFIG_8xx_CPUCLOCK 50
-#define CONFIG_8xx_BUSCLOCK (CONFIG_8xx_CPUCLOCK)
+#define CONFIG_FADS 1
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
// Set the CPU speed to 50Mhz on the FADS
#if 0
#define MPC8XX_FACT 10 /* Multiply by 10 */
-#define MPC8XX_XIN 50000000 /* 50 MHz in */
+#define MPC8XX_XIN 5000000 /* 5 MHz in */
#else
#define MPC8XX_FACT 10 /* Multiply by 10 */
#define MPC8XX_XIN 5000000 /* 5 MHz in */
#if 1
#define CONFIG_BOOTDELAY 2 /* autoboot after 2 seconds */
#define CONFIG_LOADS_ECHO 0 /* Dont echoes received characters */
-#define CONFIG_BOOTCOMMAND "bootp" /* autoboot command */
-#define CONFIG_BOOTARGS ""
+#define CONFIG_BOOTARGS ""
+#define CONFIG_BOOTCOMMAND \
+"bootp ;" \
+"setenv bootargs console=tty0 console=ttyS0 " \
+"root=/dev/nfs nfsroot=$(serverip):$(rootpath) " \
+"ip=$(ipaddr):$(serverip):$(gatewayip):$(subnetmask):$(hostname):eth0:off ;" \
+"bootm"
#else
#define CONFIG_BOOTDELAY 0 /* autoboot disabled */
#endif
-#define CONFIG_DRAM_SPEED (CONFIG_8xx_BUSCLOCK) /* MHz */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#define CFG_LONGHELP /* undef to save memory */
-#define CFG_PROMPT "=:>" /* Monitor Command Prompt */
+#define CFG_PROMPT ":>" /* Monitor Command Prompt */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
+#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
+#endif
#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
#define CFG_MAXARGS 16 /* max number of command args */
#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
#define CFG_MEMTEST_START 0x00000000 /* memtest works on */
-#define CFG_MEMTEST_END 0x00800000 /* 4 ... 8 MB in DRAM */
+#define CFG_MEMTEST_END 0x01000000 /* 4 ... 16 MB in DRAM */
#define CFG_TFTP_LOADADDR 0x00100000 /* default load address */
/*
/*-----------------------------------------------------------------------
* Internal Memory Mapped Register
*/
-#define CFG_IMMR 0xFF000000
#define CFG_IMMR_SIZE ((uint)(64 * 1024))
/*-----------------------------------------------------------------------
*/
#define CFG_INIT_RAM_ADDR CFG_IMMR
#define CFG_INIT_RAM_END 0x3000 /* End of used area in DPRAM */
-#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
+#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
#define CFG_INIT_SP_OFFSET CFG_INIT_DATA_OFFSET
-
/*-----------------------------------------------------------------------
* Start addresses for the final memory configuration
* (Set up by the startup code)
* Please note that CFG_SDRAM_BASE _must_ start at 0
* Also NOTE that it doesn't mean SDRAM - it means MEMORY.
*/
-#define CFG_SDRAM_BASE 0x00000000
-#define CFG_FLASH_BASE 0x02800000
#define CFG_FLASH_SIZE ((uint)(8 * 1024 * 1024)) /* max 8Mbyte */
#if 0
-#define CFG_MONITOR_LEN (256 << 10) /* Reserve 128 kB for Monitor */
+#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#else
-#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
+#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
#endif
-#define CFG_MALLOC_LEN (256 << 10) /* Reserve 128 kB for malloc() */
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
+#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* For booting Linux, the board info and command line data
/*-----------------------------------------------------------------------
* FLASH organization
*/
-#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
-#define CFG_MAX_FLASH_SECT 8 /* max number of sectors on one chip */
+#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
+#define CFG_MAX_FLASH_SECT 8 /* max number of sectors on one chip */
#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */
#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */
/*-----------------------------------------------------------------------
* Cache Configuration
*/
-#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
SCCR_DFALCD00)
/*-----------------------------------------------------------------------
- *
+ *
*-----------------------------------------------------------------------
*
*/
*/
/* the other CS:s are determined by looking at parameters in BCSRx */
-#define BCSR_ADDR ((uint) 0x02100000)
#define BCSR_SIZE ((uint)(64 * 1024))
-#define FLASH_BASE0_PRELIM 0x02800000 /* FLASH bank #0 */
#define FLASH_BASE1_PRELIM 0x00000000 /* FLASH bank #1 */
#define CFG_REMAP_OR_AM 0x80000000 /* OR addr mask */
/* values according to the manual */
-#define PCMCIA_MEM_ADDR ((uint)0xf4000000)
-#define PCMCIA_MEM_SIZE ((uint)(64 * 1024))
-
#define BCSR0 ((uint) (BCSR_ADDR + 00))
#define BCSR1 ((uint) (BCSR_ADDR + 0x04))
#define BCSR2 ((uint) (BCSR_ADDR + 0x08))
#define BCSR0_DBGC_MASK ((uint)0x00600000)
#define BCSR0_DBPC_MASK ((uint)0x00180000)
#define BCSR0_EBDF_MASK ((uint)0x00060000)
-
+
#define BCSR1_FLASH_EN ((uint)0x80000000)
#define BCSR1_DRAM_EN ((uint)0x40000000)
#define BCSR1_ETHEN ((uint)0x20000000)
#define BCSR1_RS232EN_2 ((uint)0x00040000)
#define BCSR1_SDRAM_EN ((uint)0x00020000)
#define BCSR1_PCCVCC1 ((uint)0x00010000)
-
+
#define BCSR2_FLASH_PD_MASK ((uint)0xF0000000)
#define BCSR2_DRAM_PD_MASK ((uint)0x07800000)
#define BCSR2_DRAM_PD_SHIFT (23)
#define BCSR2_EXTTOLI_MASK ((uint)0x00780000)
#define BCSR2_DBREVNR_MASK ((uint)0x00030000)
-
+
#define BCSR3_DBID_MASK ((ushort)0x3800)
#define BCSR3_CNT_REG_EN_PROTECT ((ushort)0x0400)
#define BCSR3_BREVNR0 ((ushort)0x0080)
#define BCSR3_FLASH_PD_MASK ((ushort)0x0070)
#define BCSR3_BREVN1 ((ushort)0x0008)
#define BCSR3_BREVN2_MASK ((ushort)0x0003)
-
+
#define BCSR4_ETHLOOP ((uint)0x80000000)
#define BCSR4_TFPLDL ((uint)0x40000000)
#define BCSR4_TPSQEL ((uint)0x20000000)
#define CONFIG_MPC850SAR 1
#define CONFIG_FADS 1
-#define CONFIG_8xx_CPUCLOCK 50
-#define CONFIG_8xx_BUSCLOCK (CONFIG_8xx_CPUCLOCK)
-
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 9600
#if 0
#define MPC8XX_HZ ((MPC8XX_XIN) * (MPC8XX_FACT))
#if 1
-#define CONFIG_8xx_BOOTDELAY -1 /* autoboot disabled */
-#define CONFIG_8xx_TFTP_MODE
+#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#else
-#define CONFIG_8xx_BOOTDELAY 5 /* autoboot after 5 seconds */
-#undef CONFIG_8xx_TFTP_MODE
+#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
#endif
-#define CONFIG_DRAM_SPEED (CONFIG_8xx_BUSCLOCK) /* MHz */
#define CONFIG_BOOTCOMMAND "bootm 02880000" /* autoboot command */
#define CONFIG_BOOTARGS " "
+
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#undef CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT ":>" /* Monitor Command Prompt */
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#define CFG_FLASH_BASE 0x02800000
#define CFG_FLASH_SIZE ((uint)(8 * 1024 * 1024)) /* max 8Mbyte */
#if 0
-#define CFG_MONITOR_LEN (256 << 10) /* Reserve 128 kB for Monitor */
+#define CFG_MONITOR_LEN (256 << 10) /* Reserve 128 kB for Monitor */
#else
-#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
+#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
#endif
-#define CFG_MALLOC_LEN (256 << 10) /* Reserve 128 kB for malloc() */
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
+#define CFG_MALLOC_LEN (256 << 10) /* Reserve 128 kB for malloc() */
/*
* For booting Linux, the board info and command line data
/*-----------------------------------------------------------------------
* FLASH organization
*/
-#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
-#define CFG_MAX_FLASH_SECT 8 /* max number of sectors on one chip */
+#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
+#define CFG_MAX_FLASH_SECT 8 /* max number of sectors on one chip */
#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */
-#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */
+#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */
#define CFG_FLASH_ENV_OFFSET 0x00040000 /* Offset of Environment Sector */
#define CFG_FLASH_ENV_SIZE 0x40000 /* Total Size of Environment Sector */
/*-----------------------------------------------------------------------
* Cache Configuration
*/
-#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#define CONFIG_MPC860T 1
#define CONFIG_FADS 1
-#define CONFIG_8xx_CPUCLOCK 50
-#define CONFIG_8xx_BUSCLOCK (CONFIG_8xx_CPUCLOCK)
-
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 9600
#if 0
#endif
#if 1
-#define CONFIG_8xx_BOOTDELAY -1 /* autoboot disabled */
-#define CONFIG_8xx_TFTP_MODE
-#define CONFIG_BOOTDELAY CONFIG_8xx_BOOTDELAY
+#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#else
-#define CONFIG_8xx_BOOTDELAY 5 /* autoboot after 5 seconds */
-#undef CONFIG_8xx_TFTP_MODE
+#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
#endif
-#define CONFIG_DRAM_SPEED (CONFIG_8xx_BUSCLOCK) /* MHz */
#define CONFIG_BOOTCOMMAND "bootm 2800100" /* autoboot command */
#define CONFIG_BOOTARGS ""
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#undef CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "=>" /* Monitor Command Prompt */
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#define CFG_FLASH_SIZE ((uint)(8 * 1024 * 1024)) /* max 8Mbyte */
#define CFG_MONITOR_LEN (384 << 10) /* Reserve 384 kB for Monitor */
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_HWINFO_LEN 0x0040 /* Length of HW Info Data */
#define CFG_MALLOC_LEN (384 << 10) /* Reserve 384 kB for malloc() */
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#undef CONFIG_8xx_CONS_SMC1
#define CONFIG_8xx_CONS_SMC2 1 /* Console is on SMC2 */
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
--- /dev/null
+ /*
+ * A collection of structures, addresses, and values associated with
+ * the Motorola 860T FADS board. Copied from the MBX stuff.
+ * Magnus Damm added defines for 8xxrom and extended bd_info.
+ * Helmut Buchsbaum added bitvalues for BCSRx
+ *
+ * Copyright (c) 1998 Dan Malek (dmalek@jlc.net)
+ */
+
+/*
+ * The GENIETV is using the following physical memorymap (copied from
+ * the FADS configuration):
+ *
+ * ff020000 -> ff02ffff : pcmcia
+ * ff010000 -> ff01ffff : BCSR connected to CS1, setup by 8xxROM
+ * ff000000 -> ff00ffff : IMAP internal in the cpu
+ * 02800000 -> 0287ffff : flash connected to CS0
+ * 00000000 -> nnnnnnnn : sdram setup by PPCBOOT
+ *
+ * CS pins are connected as follows:
+ *
+ * CS0 -512Kb boot flash
+ * CS1 - SDRAM #1
+ * CS2 - SDRAM #2
+ * CS3 - Flash #1
+ * CS4 - Flash #2
+ * CS5 - Lon (if present)
+ * CS6 - PCMCIA #1
+ * CS7 - PCMCIA #2
+ */
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * board/config.h - configuration options, board specific
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_ETHADDR 08:00:22:50:70:63 // Ethernet address
+#define CONFIG_ENV_OVERWRITE 1 // Overwrite the environment
+
+//#define CONFIG_VIDEO 1 // To enable the video initialization
+//#define CONFIG_PCMCIA 0 // To enable the PCMCIA initialization
+
+/* Video related */
+
+#define CONFIG_VIDEO_LOGO 1 // Show the logo
+#define CONFIG_VIDEO_ENCODER_AD7177 1 // Enable this encoder
+#define CONFIG_VIDEO_ENCODER_AD7177_ADDR 0xF4 // ALSB to ground
+#define CONFIG_VIDEO_SIZE (2*1024*1024)
+#define CONFIG_VIDEO_ADDR (bd_ptr->bi_memsize - CONFIG_VIDEO_SIZE) // Frame buffer address
+
+/* Wireless 56Khz 4PPM keyboard on SMCx */
+
+#define CONFIG_WL_4PPM_KEYBOARD 0
+#define CONFIG_WL_4PPM_KEYBOARD_SMC 0 // SMC to use (0 indexed)
+
+/*
+ * High Level Configuration Options
+ * (easy to change)
+ */
+#include <mpc8xx_irq.h>
+
+#define CONFIG_GENIETV 1
+#define CONFIG_MPC823 1
+
+#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
+#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
+#define CONFIG_BAUDRATE 9600
+
+#if 0 // Debugging
+#define MPC8XX_FACT 5 /* Multiply by 5 */
+#else
+#define MPC8XX_FACT 12 /* Multiply by 12 */
+#endif
+#define MPC8XX_XIN 4000000 /* 4 MHz clock */
+
+#define MPC8XX_HZ ((MPC8XX_XIN) * (MPC8XX_FACT))
+#define CFG_PLPRCR_MF ((MPC8XX_FACT-1) << 20)
+#define CONFIG_8xx_GCLK_FREQ MPC8XX_HZ /* Force it - dont measure it */
+
+#define CONFIG_BOOTDELAY 2 /* autoboot after 2 seconds */
+#define CONFIG_LOADS_ECHO 0 /* Dont echoes received characters */
+#define CONFIG_BOOTCOMMAND "" /* autoboot command */
+#define CONFIG_BOOTARGS ""
+
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CFG_LONGHELP /* undef to save memory */
+#define CFG_PROMPT ":>" /* Monitor Command Prompt */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
+#else
+#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
+#endif
+#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
+#define CFG_MAXARGS 8 /* max number of command args */
+#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
+
+#define CFG_MEMTEST_START 0x00000000 /* memtest works on */
+#define CFG_MEMTEST_END 0x00800000 /* 4 ... 8 MB in DRAM */
+
+#define CFG_TFTP_LOADADDR 0x00100000 /* default load address */
+/*
+ * Low Level Configuration Settings
+ * (address mappings, register initial values, etc.)
+ * You should know what you are doing if you make changes here.
+ */
+/*-----------------------------------------------------------------------
+ * Internal Memory Mapped Register
+ */
+#define CFG_IMMR 0xFF000000
+#define CFG_IMMR_SIZE ((uint)(64 * 1024))
+
+/*-----------------------------------------------------------------------
+ * Definitions for initial stack pointer and data area (in DPRAM)
+ */
+#define CFG_INIT_RAM_ADDR CFG_IMMR
+#define CFG_INIT_RAM_END 0x3000 /* End of used area in DPRAM */
+#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
+#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
+#define CFG_INIT_SP_OFFSET CFG_INIT_DATA_OFFSET
+
+/*-----------------------------------------------------------------------
+ * Start addresses for the final memory configuration
+ * (Set up by the startup code)
+ * Please note that CFG_SDRAM_BASE _must_ start at 0
+ * Also NOTE that it doesn't mean SDRAM - it means MEMORY.
+ */
+#define CFG_SDRAM_BASE 0x00000000
+#define CFG_FLASH_BASE 0x02800000
+#define CFG_FLASH_SIZE ((uint)(8 * 1024 * 1024)) /* max 8Mbyte */
+#if 0
+#define CFG_MONITOR_LEN (256 << 10) /* Reserve 128 kB for Monitor */
+#else
+#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
+#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
+#define CFG_MALLOC_LEN (256 << 10) /* Reserve 128 kB for malloc() */
+
+/*
+ * For booting Linux, the board info and command line data
+ * have to be in the first 8 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
+/*-----------------------------------------------------------------------
+ * FLASH organization
+ */
+#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
+#define CFG_MAX_FLASH_SECT 8 /* max number of sectors on one chip */
+
+#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */
+#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */
+
+#define CFG_FLASH_ENV_OFFSET 0x00040000 /* Offset of Environment Sector */
+#define CFG_FLASH_ENV_SIZE 0x40000 /* Total Size of Environment Sector */
+/* the other CS:s are determined by looking at parameters in BCSRx */
+
+/* values according to the manual */
+
+/*-----------------------------------------------------------------------
+ * Cache Configuration
+ */
+#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
+
+/*-----------------------------------------------------------------------
+ * SYPCR - System Protection Control 11-9
+ * SYPCR can only be written once after reset!
+ *-----------------------------------------------------------------------
+ * Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
+ */
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
+
+/*-----------------------------------------------------------------------
+ * SUMCR - SIU Module Configuration 11-6
+ *-----------------------------------------------------------------------
+ * PCMCIA config., multi-function pin tri-state
+ *
+#define CFG_SIUMCR (SIUMCR_DBGC00 | SIUMCR_DBPC00 | SIUMCR_MLRC01)
+ */
+#define CFG_SIUMCR (SIUMCR_DBGC00 | SIUMCR_DBPC00 | SIUMCR_MLRC10)
+
+/*-----------------------------------------------------------------------
+ * TBSCR - Time Base Status and Control 11-26
+ *-----------------------------------------------------------------------
+ * Clear Reference Interrupt Status, Timebase freezing enabled
+ */
+#define CFG_TBSCR (TBSCR_REFA | TBSCR_REFB | TBSCR_TBE)
+
+/*-----------------------------------------------------------------------
+ * PISCR - Periodic Interrupt Status and Control 11-31
+ *-----------------------------------------------------------------------
+ * Clear Periodic Interrupt Status, Interrupt Timer freezing enabled
+ */
+#define CFG_PISCR (PISCR_PS | PISCR_PITF)
+
+/*-----------------------------------------------------------------------
+ * PLPRCR - PLL, Low-Power, and Reset Control Register 15-30
+ *-----------------------------------------------------------------------
+ * Reset PLL lock status sticky bit, timer expired status bit and timer *
+ * interrupt status bit - leave PLL multiplication factor unchanged !
+ *
+ * #define CFG_PLPRCR (PLPRCR_SPLSS | PLPRCR_TEXPS | PLPRCR_TMIST)
+ */
+#define CFG_PLPRCR (PLPRCR_SPLSS | PLPRCR_TEXPS | PLPRCR_TMIST | CFG_PLPRCR_MF)
+
+/*-----------------------------------------------------------------------
+ * SCCR - System Clock and reset Control Register 15-27
+ *-----------------------------------------------------------------------
+ * Set clock output, timebase and RTC source and divider,
+ * power management and some other internal clocks
+ */
+#define SCCR_MASK SCCR_EBDF11
+#define CFG_SCCR (SCCR_TBS | \
+ SCCR_COM00 | SCCR_DFSYNC00 | SCCR_DFBRG00 | \
+ SCCR_DFNL000 | SCCR_DFNH000 | SCCR_DFLCD000 | \
+ SCCR_DFALCD00)
+
+/*-----------------------------------------------------------------------
+ *
+ *-----------------------------------------------------------------------
+ *
+ */
+#define CFG_DER 0
+
+/* Because of the way the 860 starts up and assigns CS0 the
+* entire address space, we have to set the memory controller
+* differently. Normally, you write the option register
+* first, and then enable the chip select by writing the
+* base register. For CS0, you must write the base register
+* first, followed by the option register.
+*/
+
+/*
+ * Init Memory Controller:
+ *
+ * BR0 and OR0(FLASH)
+ */
+
+#define FLASH_BASE0_PRELIM 0x02800000 /* FLASH bank #0 */
+#define FLASH_BASE1_PRELIM 0x00000000 /* FLASH bank #1 (not present) */
+
+#define CFG_REMAP_OR_AM 0x80000000 /* OR addr mask */
+#define CFG_PRELIM_OR_AM 0xE0000000 /* OR addr mask (512Kb) */
+
+/* FLASH timing: ACS = 10, TRLX = 1, CSNT = 1, SCY = 3, EHTR = 0 */
+#define CFG_OR_TIMING_FLASH (OR_CSNT_SAM | OR_ACS_DIV4 | OR_BI | OR_SCY_3_CLK | OR_TRLX)
+
+#define CFG_OR0_REMAP (CFG_REMAP_OR_AM | CFG_OR_TIMING_FLASH)
+#define CFG_OR0_PRELIM (CFG_PRELIM_OR_AM | CFG_OR_TIMING_FLASH)
+/*
+** Was:
+** #define CFG_BR0_PRELIM ((FLASH_BASE0_PRELIM & BR_BA_MSK) | BR_V)
+*/
+#define CFG_BR0_PRELIM ((FLASH_BASE0_PRELIM & BR_BA_MSK) | BR_V | BR_PS_8)
+
+/*
+ * BR1/2 and OR1/2 (SDRAM)
+*/
+
+#define CFG_OR_TIMING_SDRAM 0x0000000A
+
+#define SDRAM_MAX_SIZE 0x04000000 // 64Mb
+#define SDRAM_BASE1_PRELIM 0x00000000 // First bank
+#define SDRAM_BASE2_PRELIM 0x20000000 // Second bank
+
+#define CFG_OR1_PRELIM (CFG_PRELIM_OR_AM | CFG_OR_TIMING_SDRAM)
+#define CFG_BR1_PRELIM ((SDRAM_BASE1_PRELIM & BR_BA_MSK) | BR_MS_UPMB | BR_V)
+
+#define CFG_OR2_PRELIM CFG_OR1_PRELIM
+#define CFG_BR2_PRELIM ((SDRAM_BASE2_PRELIM & BR_BA_MSK) | BR_MS_UPMB | BR_V)
+
+/*
+ * Memory Periodic Timer Prescaler
+ */
+
+/* periodic timer for refresh */
+#define CFG_MBMR_PTB 17 /* start with divider for 100 MHz */
+
+/* refresh rate 15.6 us (= 64 ms / 4K = 62.4 / quad bursts) for <= 128 MBit */
+#define CFG_MPTPR_2BK_4K MPTPR_PTP_DIV16 /* setting for 2 banks */
+
+/*
+ * MBMR settings for SDRAM
+ */
+
+/* 8 column SDRAM */
+#define CFG_MBMR_8COL ((CFG_MBMR_PTB << MAMR_PTA_SHIFT) | MAMR_PTAE | \
+ MAMR_AMA_TYPE_0 | MAMR_DSA_1_CYCL | MAMR_G0CLA_A11 | \
+ MAMR_RLFA_1X | MAMR_WLFA_1X | MAMR_TLFA_4X)
+
+/*
+ * Internal Definitions
+ *
+ * Boot Flags
+ */
+#define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */
+#define BOOTFLAG_WARM 0x02 /* Software reboot */
+
+/* values according to the manual */
+
+#define PCMCIA_MEM_ADDR ((uint)0xff020000)
+#define PCMCIA_MEM_SIZE ((uint)(64 * 1024))
+
+#define CONFIG_DRAM_50MHZ 1
+#define CONFIG_SDRAM_50MHZ
+
+#ifdef CONFIG_MPC860T
+
+/* Interrupt level assignments.
+*/
+#define FEC_INTERRUPT SIU_LEVEL1 /* FEC interrupt */
+
+#endif /* CONFIG_MPC860T */
+
+/* We don't use the 8259.
+*/
+#define NR_8259_INTS 0
+
+/* Machine type
+*/
+#define _MACH_8xx (_MACH_fads)
+
+/*
+ * MPC8xx CPM Options
+ */
+#define CONFIG_SCC_ENET 1
+
+#define CONFIG_DISK_SPINUP_TIME 1000000
+
+/* PCMCIA configuration */
+
+#define PCMCIA_MAX_SLOTS 1
+
+#ifdef CONFIG_MPC860
+#define PCMCIA_SLOT_A 1
+#endif
+
+#endif /* __CONFIG_H */
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * Configuation settings for the MBX8xx board.
+ *
+ * -----------------------------------------------------------------
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * board/config.h - configuration options, board specific
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ * (easy to change)
+ */
+
+#define CONFIG_MPC860 1 /* This is a MPC860 CPU */
+#define CONFIG_MBX 1 /* ...on an MBX module */
+
+#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
+#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
+#define CONFIG_BAUDRATE 9600
+#if 1
+#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
+#else
+#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
+#endif
+#define CONFIG_BOOTCOMMAND "bootm 20000" /* autoboot command */
+
+#define CONFIG_BOOTARGS "root=/dev/nfs rw " \
+ "nfsroot=10.0.0.2:/LinuxPPC " \
+ "nfsaddrs=10.0.0.99:10.0.0.2"
+
+#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
+#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CFG_LONGHELP /* undef to save memory */
+#define CFG_PROMPT "=> " /* Monitor Command Prompt */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
+#else
+#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
+#endif
+#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
+#define CFG_MAXARGS 16 /* max number of command args */
+#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
+
+#define CFG_MEMTEST_START 0x0400000 /* memtest works on */
+#define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */
+
+#define CFG_TFTP_LOADADDR 0x100000 /* default load address */
+
+/*
+ * Low Level Configuration Settings
+ * (address mappings, register initial values, etc.)
+ * You should know what you are doing if you make changes here.
+ */
+
+/*-----------------------------------------------------------------------
+ * Turn on use of board support functions board_xxx()
+ */
+#define CFG_HAVE_BSP
+
+#define CFG_IMMR 0xFA200000 /* Internal Memory Mapped Register*/
+#define CFG_CSR_BASE 0xFA100000 /* Control/Status Registers */
+#define CFG_CSR_OR 0xffe00000 /* w/o speed dependent flags!! */
+#define CFG_PCIMEM_BASE 0x80000000 /* PCI I/O and Memory Spaces */
+#define CFG_PCIMEM_OR 0xA0000108
+#define CFG_PCIBRIDGE_BASE 0xFA210000 /* PCI-Bus Bridge Registers */
+#define CFG_PCIBRIDGE_OR 0xFFFF0108
+#define CFG_BOOTROM_BASE 0xFE000000 /* Boot ROM Base */
+
+/*-----------------------------------------------------------------------
+ * Definitions for initial stack pointer and data area (in DPRAM)
+ */
+#define CFG_INIT_RAM_ADDR CFG_IMMR
+#define CFG_INIT_RAM_END 0x2f00 /* End of used area in DPRAM */
+#define CFG_INIT_DATA_SIZE 64 /* size in bytes reserved for initial data */
+#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
+#define CFG_INIT_SERIAL_SIZE 64 /* size in bytes reserved for serial rx/tx bd+buffers */
+#define CFG_INIT_SERIAL_OFFSET (CFG_INIT_DATA_OFFSET - CFG_INIT_SERIAL_SIZE)
+#define CFG_INIT_VPD_SIZE 256 /* size in bytes reserved for vpd buffer */
+#define CFG_INIT_VPD_OFFSET (CFG_INIT_SERIAL_OFFSET - CFG_INIT_VPD_SIZE)
+#define CFG_INIT_SP_OFFSET (CFG_INIT_VPD_OFFSET-8)
+
+/*-----------------------------------------------------------------------
+ * Offset in DPMEM where we keep serial BDs and buffers
+ */
+#define CFG_DPRAMSERIAL (CFG_INIT_SERIAL_OFFSET - 0x2000)
+
+/*-----------------------------------------------------------------------
+ * Offset in DPMEM where we keep the VPD data
+ */
+#define CFG_DPRAMVPD (CFG_INIT_VPD_OFFSET - 0x2000)
+
+/*-----------------------------------------------------------------------
+ * Start addresses for the final memory configuration
+ * (Set up by the startup code)
+ * Please note that CFG_SDRAM_BASE _must_ start at 0
+ */
+#define CFG_SDRAM_BASE 0x00000000
+#define CFG_FLASH_BASE 0xfe000000
+#ifdef DEBUG
+#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
+#else
+#define CFG_MONITOR_LEN (512 << 10) /* Reserve 512 kB for Monitor */
+#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
+#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
+
+/*
+ * For booting Linux, the board info and command line data
+ * have to be in the first 8 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
+
+/*-----------------------------------------------------------------------
+ * FLASH organization
+ */
+#define CFG_MAX_FLASH_BANKS 4 /* max number of memory banks */
+#define CFG_MAX_FLASH_SECT 16 /* max number of sectors on one chip */
+
+#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */
+#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */
+
+#define CFG_FLASH_ENV_OFFSET 0x40000 /* Offset of Environment Sector */
+#define CFG_FLASH_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
+
+/*-----------------------------------------------------------------------
+ * Cache Configuration
+ */
+#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
+
+/*-----------------------------------------------------------------------
+ * SYPCR - System Protection Control 11-9
+ * SYPCR can only be written once after reset!
+ *-----------------------------------------------------------------------
+ * Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
+ */
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
+
+/*-----------------------------------------------------------------------
+ * SUMCR - SIU Module Configuration 11-6
+ *-----------------------------------------------------------------------
+ * PCMCIA config., multi-function pin tri-state
+ */
+#define CFG_SIUMCR (SIUMCR_DBGC00 | SIUMCR_DBPC00 | SIUMCR_MLRC01)
+
+/*-----------------------------------------------------------------------
+ * TBSCR - Time Base Status and Control 11-26
+ *-----------------------------------------------------------------------
+ * Clear Reference Interrupt Status, Timebase freezing enabled
+ */
+#define CFG_TBSCR (TBSCR_REFA | TBSCR_REFB | TBSCR_TBF)
+
+/*-----------------------------------------------------------------------
+ * PISCR - Periodic Interrupt Status and Control 11-31
+ *-----------------------------------------------------------------------
+ * Clear Periodic Interrupt Status, Interrupt Timer freezing enabled
+ */
+#define CFG_PISCR (PISCR_PS | PISCR_PITF)
+
+/*-----------------------------------------------------------------------
+ * PLPRCR - PLL, Low-Power, and Reset Control Register 15-30
+ *-----------------------------------------------------------------------
+ * Reset PLL lock status sticky bit, timer expired status bit and timer
+ * interrupt status bit - leave PLL multiplication factor unchanged !
+ */
+#define CFG_PLPRCR (PLPRCR_SPLSS | PLPRCR_TEXPS | PLPRCR_TMIST)
+
+/*-----------------------------------------------------------------------
+ * SCCR - System Clock and reset Control Register 15-27
+ *-----------------------------------------------------------------------
+ * Set clock output, timebase and RTC source and divider,
+ * power management and some other internal clocks
+ */
+#define CFG_SCCR (SCCR_TBS | SCCR_COM11)
+
+/*-----------------------------------------------------------------------
+ * PCMCIA stuff
+ *-----------------------------------------------------------------------
+ *
+ */
+#define CFG_PCMCIA_MEM_ADDR (0xE0000000)
+#define CFG_PCMCIA_MEM_SIZE ( 64 << 20 )
+#define CFG_PCMCIA_DMA_ADDR (0xE4000000)
+#define CFG_PCMCIA_DMA_SIZE ( 64 << 20 )
+#define CFG_PCMCIA_ATTRB_ADDR (0xE8000000)
+#define CFG_PCMCIA_ATTRB_SIZE ( 64 << 20 )
+#define CFG_PCMCIA_IO_ADDR (0xEC000000)
+#define CFG_PCMCIA_IO_SIZE ( 64 << 20 )
+
+#define CFG_PCMCIA_INTERRUPT SIU_LEVEL6
+
+/*-----------------------------------------------------------------------
+ * Debug Entry Mode
+ *-----------------------------------------------------------------------
+ *
+ */
+#define CFG_DER 0
+
+/*
+ * Internal Definitions
+ *
+ * Boot Flags
+ */
+#define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */
+#define BOOTFLAG_WARM 0x02 /* Software reboot */
+
+#endif /* __CONFIG_H */
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
#define CONFIG_COMMANDS \
((CONFIG_CMD_DFL & ~(CFG_CMD_FLASH)) | CFG_CMD_IDE) /* no Flash, but IDE */
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*----------------------------------------------------------------------*/
#define CONFIG_ETHADDR 00:d0:93:00:01:cb
#define CONFIG_IPADDR 10.0.0.98
*/
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "=> " /* Monitor Command Prompt */
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#else
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#define CFG_BR4 ((PER8_BASE & BR_BA_MSK) | BR_PS_8 | BR_V )
#define CFG_OR_TIMING_SHARC 0x00000700 /* SHARC-Timing */
-#define CFG_OR5 (SHARC_OR_AM | CFG_OR_TIMING_PER8 )
+#define CFG_OR5 (SHARC_OR_AM | CFG_OR_TIMING_SHARC )
#define CFG_BR5 ((SHARC_BASE & BR_BA_MSK) | BR_PS_32 | BR_MS_UPMA | BR_V )
/*
* Memory Periodic Timer Prescaler
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200 /* console baudrate = 115kbps */
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "=> " /* Monitor Command Prompt */
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */
#undef CONFIG_8xx_CONS_SMC2
+#undef CONFIG_8xx_CONS_NONE
#define CONFIG_BAUDRATE 115200
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
#undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */
+#undef CONFIG_WATCHDOG /* watchdog disabled */
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
/*
* Miscellaneous configurable options
*/
#else
#define CFG_MONITOR_LEN (128 << 10) /* Reserve 128 kB for Monitor */
#endif
+#define CFG_MONITOR_BASE CFG_FLASH_BASE
#define CFG_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
/*
* the maximum mapped by the Linux kernel during initialization.
*/
#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
+
/*-----------------------------------------------------------------------
* FLASH organization
*/
#define CFG_FLASH_ENV_OFFSET 0x8000 /* Offset of Environment Sector */
#define CFG_FLASH_ENV_SIZE 0x4000 /* Total Size of Environment Sector */
+
/*-----------------------------------------------------------------------
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
+#if defined(CONFIG_WATCHDOG)
+#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | \
+ SYPCR_SWE | SYPCR_SWP)
+#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
+#endif
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
#if defined(CONFIG_CMA286_60_OLD)
#define CONFIG_8xx_GCLK_FREQ 33333000/* define if cant use get_gclk_freq */
#endif
-#define CONFIG_8xx_WATCHDOG /* enables watchdog in 8xx SIU */
#undef CONFIG_8xx_CONS_SMC1
#undef CONFIG_8xx_CONS_SMC2
#define CONFIG_8xx_CONS_NONE 1 /* Console is on the m/b serial */
#define CONFIG_BAUDRATE 230400
+#define CONFIG_8xx_WATCHDOG /* turn on platform specific watchdog */
+
+#define CONFIG_COMMANDS ((CONFIG_CMD_DFL | CFG_CMD_KGDB) & ~CFG_CMD_NET)
+
+/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
+#include <cmd_confdefs.h>
+
#if 0
#define CONFIG_BOOTDELAY -1 /* autoboot disabled */
#else
*/
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "=> " /* Monitor Command Prompt */
-#if (CONFIG_COMMANDS & CFG_CMD_KGDB) && defined(KGDB_DEBUG)
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 16 /* For all MPC8xx CPUs */
+#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
+#define CFG_CACHELINE_SHIFT 4 /* log base 2 of the above value */
+#endif
+
/*-----------------------------------------------------------------------
* SYPCR - System Protection Control 11-9
*-----------------------------------------------------------------------
* Software & Bus Monitor Timer max, Bus Monitor enable, SW Watchdog freeze
*/
-#if defined(CONFIG_8xx_WATCHDOG)
+#if defined(CONFIG_WATCHDOG)
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWE | SYPCR_SWP)
#else
#define CFG_SYPCR (SYPCR_SWTC | SYPCR_BMT | SYPCR_BME | SYPCR_SWF | SYPCR_SWP)
-#endif
+#endif /* CONFIG_WATCHDOG */
/*-----------------------------------------------------------------------
* SUMCR - SIU Module Configuration 11-6
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <lists.h>
+
+#ifndef _DEVICES_H_
+#define _DEVICES_H_
+
+/*
+** CONSOLE DEVICES
+*/
+
+#define DEV_FLAGS_INPUT 0x00000001 // The device can be used as input console
+#define DEV_FLAGS_OUTPUT 0x00000002 // The device can be used as output console
+#define DEV_FLAGS_SYSTEM 0x80000000 // The device is a system device
+#define DEV_EXT_VIDEO 0x00000001 // Video extensions supported
+
+// Device informations
+typedef struct {
+ int flags, // Device flags: input/output/system
+ ext; // Supported extensions
+ char name[8]; // Device name
+
+// GENERAL functions
+
+ int (*start)(void); // To start the device
+ int (*stop)(void); // To stop the device
+
+// OUTPUT functions
+
+ void (*putc)(const char c) ; // To put a char
+ void (*puts)(const char *s) ; // To put a string (accelerator)
+
+// INPUT functions
+
+ int (*tstc)(void) ; // To test if a char is ready...
+ int (*getc)(void) ; // To get that char
+
+// Other functions
+
+ void *priv ; // Private extensions
+} device_t ;
+
+/*
+** VIDEO EXTENSIONS
+*/
+
+#define VIDEO_FORMAT_RGB_INDEXED 0x0000
+#define VIDEO_FORMAT_RGB_DIRECTCOLOR 0x0001
+#define VIDEO_FORMAT_YUYV_4_4_4 0x0010
+#define VIDEO_FORMAT_YUYV_4_2_2 0x0011
+
+typedef struct {
+ void *address ; // Address of framebuffer
+ unsigned short
+ width, // Horizontal resolution
+ height; // Vertical resolution
+ unsigned char
+ format, // Format
+ colors; // Colors number or color depth
+
+ void (*setcolreg)(int,int,int,int);
+ void (*getcolreg)(int, void *);
+} video_ext_t ;
+
+/*
+** VARIABLES
+*/
+
+extern list_t devlist;
+extern device_t *stdio_devices[] ;
+extern char *stdio_names[MAX_FILES] ;
+
+/*
+** PROTOTYPES
+*/
+
+int device_register (device_t *dev);
+int devices_init(void);
+int devices_done(void);
+
+#endif
\ No newline at end of file
#define SST_MANUFACT 0x00BF00BF /* SST manuf. ID in D23..D16, D7..D0 */
#define AMD_ID_F040B 0xA4 /* 29F040B ID ( 4 M, bottom boot sect) */
+#define AMD_ID_F080B 0xD5 /* 29F0B0 ID ( 1 M) */
#define AMD_ID_LV400T 0x22B922B9 /* 29LV400T ID ( 4 M, top boot sector) */
#define AMD_ID_LV400B 0x22BA22BA /* 29LV400B ID ( 4 M, bottom boot sect) */
#define FLASH_SST800A 0x0C /* SST 39xF800A ID ( 8M = 512K x 16 ) */
#define FLASH_SST160A 0x0D /* SST 39xF160A ID (16M = 1M x 16 ) */
+#define FLASH_28F008S5 0x0E /* Intel 28F008S5 ( 1M = 64K x 16 ) */
+
#define FLASH_STM800AB 0x0F /* STM M29WF800AB ID ( 8M = 512K x 16 ) */
#define FLASH_UNKNOWN 0xFF /* unknown flash type */
#define FLASH_MAN_FUJ 0x10
#define FLASH_MAN_SST 0x20
#define FLASH_MAN_STM 0x40
+#define FLASH_MAN_INTEL 0x80
#define FLASH_TYPEMASK 0x0F /* extract FLASH type information */
--- /dev/null
+#ifndef _LISTS_H_
+#define _LISTS_H_
+
+#define LIST_START -1 // Handy Constants that substitute for item positions
+#define LIST_END 0 // END_OF_LIST means one past current length of list when
+ // inserting. Otherwise it refers the last item in the list.
+
+typedef struct\r
+ {\r
+ void *ptr;\r
+ unsigned int size;\r
+ } HandleRecord;\r
+
+typedef void **Handle;\r
+
+typedef int (*CompareFunction)(void *data1, void *data2) ;
+
+typedef struct ListStructTag\r
+ {\r
+ int signature; /* debugging aid */\r
+ int percentIncrease; /* %of current size to increase by when list is out of space */\r
+ int minNumItemsIncrease; /* fixed number of items to increase by when list is out of space */\r
+ int listSize; /* number of items than can fit in the currently allocated memory */\r
+ int itemSize; /* the size of each item in the list (same for every item) */\r
+ int numItems; /* number of items currently in the list */\r
+ unsigned char itemList[1]; /* resizable array of list elements */\r
+ } ListStruct;\r
+\r
+typedef struct ListStructTag **list_t; /* The list abstract data type */\r
+typedef int ( * ListApplicationFunc)(int index, void *ptrToItem, void *callbackData);\r
+\r
+ /* Basic List Operations */\r
+list_t ListCreate(int elementSize);\r
+void ListDispose(list_t list);\r
+void ListDisposePtrList(list_t list); /* no function panel yet */\r
+int ListNumItems(list_t list);\r
+int ListInsertItem(list_t list, void *ptrToItem, int itemPosition);\r
+void ListGetItem(list_t list, void *itemDestination, int itemPosition);\r
+void ListReplaceItem(list_t list, void *ptrToItem, int itemPosition);\r
+void ListRemoveItem(list_t list, void *itemDestination, int itemPosition);\r
+\r
+int ListInsertItems(list_t list, void *ptrToItems, int firstItemPosition, int numItemsToInsert);\r
+void ListGetItems(list_t list, void *itemsDestination, int firstItemPosition, int numItemsToGet);\r
+void ListReplaceItems(list_t list, void *ptrToItems, int firstItemPosition, int numItemsToReplace);\r
+void ListRemoveItems(list_t list, void *itemsDestination, int firstItemPosition, int numItemsToRemove);\r
+\r
+list_t ListCopy(list_t originalList);\r
+int ListAppend(list_t list1, list_t list2);\r
+void ListClear(list_t list);\r
+int ListEqual(list_t list1, list_t list2);\r
+int ListInsertInOrder(list_t list, void *ptrToItem, CompareFunction compareFunction);\r
+void *ListGetPtrToItem(list_t list, int itemPosition);\r
+void *ListGetDataPtr(list_t list);\r
+int ListApplyToEach(list_t list, int ascending, ListApplicationFunc funcToApply, void *callbackData);\r
+\r
+ /* List Searching and Sorting */\r
+int ListFindItem(list_t list, void *ptrToItem, int startingPosition, CompareFunction compareFunction);\r
+void ListRemoveDuplicates(list_t list, CompareFunction compareFunction);\r
+int ListBinSearch(list_t list, void *itemPtr, CompareFunction compareFunction);\r
+void ListQuickSort(list_t list, CompareFunction compareFunction);\r
+void ListHeapSort(list_t list, CompareFunction compareFunction);\r
+void ListInsertionSort(list_t list, CompareFunction compareFunction);\r
+int ListIsSorted(list_t list, CompareFunction compareFunction);\r
+\r
+ /* Advanced List Functions */\r
+void ListSetAllocationPolicy(list_t list, int minItemsPerAlloc, int percentIncreasePerAlloc);\r
+void ListCompact(list_t list);\r
+int ListPreAllocate(list_t list, int numItems);\r
+int ListGetItemSize(list_t list);\r
+int GetIntListFromParmInfo(va_list parmInfo, int numIntegers, list_t *integerList); /* no function panel, too obscure */\r
+int ListInsertAfterItem(list_t list, void *ptrToItem, void *ptrToItemToInsertAfter, CompareFunction compareFunction); /* no function panel */\r
+int ListInsertBeforeItem(list_t list, void *ptrToItem, void *ptrToItemToInsertBefore, CompareFunction compareFunction); /* no function panel */\r
+
+#endif
\ No newline at end of file
#define UPMA 0x00000000
#define UPMB 0x00800000
+#if !defined(__ASSEMBLY__) && defined(CONFIG_WATCHDOG)
+extern __inline__ void
+reset_8xx_watchdog(volatile immap_t *immr)
+{
+ immr->im_siu_conf.sc_swsr = 0x556c;
+ immr->im_siu_conf.sc_swsr = 0xaa39;
+}
+#endif /* !__ASSEMBLY && CONFIG_WATCHDOG */
+
#endif /* __MPCXX_H__ */
*
*
* History
- * 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added
+ * 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added
*/
#ifndef __NET_H__
/*
- * The current receive packet handler. Called with a pointer to the
- * application packet, and a protocol type (PORT_BOOTPC or PORT_TFTP).
- * All other packets are dealt with without calling the handler.
+ * The current receive packet handler. Called with a pointer to the
+ * application packet, and a protocol type (PORT_BOOTPC or PORT_TFTP).
+ * All other packets are dealt with without calling the handler.
*/
-typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);
+typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);
/*
* A timeout handler. Called after time interval has expired.
*/
-typedef void thand_f(void);
+typedef void thand_f(void);
-extern int eth_init(bd_t *bis); /* Initialize the device */
-extern int eth_send(volatile void *packet, int length); /* Send a packet */
-extern int eth_rx(void); /* Check for received packets */
-extern void eth_halt(void); /* stop SCC */
+extern int eth_init(bd_t *bis); /* Initialize the device */
+extern int eth_send(volatile void *packet, int length); /* Send a packet */
+extern int eth_rx(void); /* Check for received packets */
+extern void eth_halt(void); /* stop SCC */
/*
* Ethernet header
*/
-typedef struct
-{
- uchar et_dest[6]; /* Destination node */
- uchar et_src[6]; /* Source node */
- ushort et_protlen; /* Protocol or length */
- uchar et_dsap; /* 802 DSAP */
- uchar et_ssap; /* 802 SSAP */
- uchar et_ctl; /* 802 control */
- uchar et_snap1; /* SNAP */
+typedef struct {
+ uchar et_dest[6]; /* Destination node */
+ uchar et_src[6]; /* Source node */
+ ushort et_protlen; /* Protocol or length */
+ uchar et_dsap; /* 802 DSAP */
+ uchar et_ssap; /* 802 SSAP */
+ uchar et_ctl; /* 802 control */
+ uchar et_snap1; /* SNAP */
uchar et_snap2;
uchar et_snap3;
- ushort et_prot; /* 802 protocol */
-}
- Ethernet_t;
+ ushort et_prot; /* 802 protocol */
+} Ethernet_t;
-#define ETHER_HDR_SIZE 14 /* Ethernet header size */
-#define E802_HDR_SIZE 22 /* 802 ethernet header size */
-#define PROT_IP 0x0800 /* IP protocol */
-#define PROT_ARP 0x0806 /* IP ARP protocol */
-#define PROT_RARP 0x8035 /* IP ARP protocol */
+#define ETHER_HDR_SIZE 14 /* Ethernet header size */
+#define E802_HDR_SIZE 22 /* 802 ethernet header size */
+#define PROT_IP 0x0800 /* IP protocol */
+#define PROT_ARP 0x0806 /* IP ARP protocol */
+#define PROT_RARP 0x8035 /* IP ARP protocol */
/*
* Internet Protocol (IP) header.
*/
-typedef struct
-{
- uchar ip_hl_v; /* header length and version */
- uchar ip_tos; /* type of service */
- ushort ip_len; /* total length */
- ushort ip_id; /* identification */
- ushort ip_off; /* fragment offset field */
- uchar ip_ttl; /* time to live */
- uchar ip_p; /* protocol */
- ushort ip_sum; /* checksum */
- IPaddr_t ip_src; /* Source IP address */
- IPaddr_t ip_dst; /* Destination IP address */
- ushort udp_src; /* UDP source port */
- ushort udp_dst; /* UDP destination port */
- ushort udp_len; /* Length of UDP packet */
- ushort udp_xsum; /* Checksum */
-}
- IP_t;
+typedef struct {
+ uchar ip_hl_v; /* header length and version */
+ uchar ip_tos; /* type of service */
+ ushort ip_len; /* total length */
+ ushort ip_id; /* identification */
+ ushort ip_off; /* fragment offset field */
+ uchar ip_ttl; /* time to live */
+ uchar ip_p; /* protocol */
+ ushort ip_sum; /* checksum */
+ IPaddr_t ip_src; /* Source IP address */
+ IPaddr_t ip_dst; /* Destination IP address */
+ ushort udp_src; /* UDP source port */
+ ushort udp_dst; /* UDP destination port */
+ ushort udp_len; /* Length of UDP packet */
+ ushort udp_xsum; /* Checksum */
+} IP_t;
#define IP_HDR_SIZE_NO_UDP (sizeof (IP_t) - 8)
-#define IP_HDR_SIZE sizeof (IP_t)
+#define IP_HDR_SIZE (sizeof (IP_t))
/*
*/
typedef struct
{
- ushort ar_hrd; /* Format of hardware address */
-# define ARP_ETHER 1 /* Ethernet hardware address */
- ushort ar_pro; /* Format of protocol address */
- uchar ar_hln; /* Length of hardware address */
- uchar ar_pln; /* Length of protocol address */
- ushort ar_op; /* Operation */
-# define ARPOP_REQUEST 1 /* Request to resolve address */
-# define ARPOP_REPLY 2 /* Response to previous request */
-
-# define RARPOP_REQUEST 3 /* Request to resolve address */
-# define RARPOP_REPLY 4 /* Response to previous request */
+ ushort ar_hrd; /* Format of hardware address */
+# define ARP_ETHER 1 /* Ethernet hardware address */
+ ushort ar_pro; /* Format of protocol address */
+ uchar ar_hln; /* Length of hardware address */
+ uchar ar_pln; /* Length of protocol address */
+ ushort ar_op; /* Operation */
+# define ARPOP_REQUEST 1 /* Request to resolve address */
+# define ARPOP_REPLY 2 /* Response to previous request */
+
+# define RARPOP_REQUEST 3 /* Request to resolve address */
+# define RARPOP_REPLY 4 /* Response to previous request */
/*
- * The remaining fields are variable in size,
- * according to the sizes above, and are defined
- * as appropriate for specific hardware/protocol
- * combinations.
+ * The remaining fields are variable in size, according to
+ * the sizes above, and are defined as appropriate for
+ * specific hardware/protocol combinations.
*/
uchar ar_data[0];
#if 0
- uchar ar_sha[]; /* Sender hardware address */
- uchar ar_spa[]; /* Sender protocol address */
- uchar ar_tha[]; /* Target hardware address */
- uchar ar_tpa[]; /* Target protocol address */
-#endif // 0
-}
- ARP_t;
+ uchar ar_sha[]; /* Sender hardware address */
+ uchar ar_spa[]; /* Sender protocol address */
+ uchar ar_tha[]; /* Target hardware address */
+ uchar ar_tpa[]; /* Target protocol address */
+#endif /* 0 */
+} ARP_t;
-#define ARP_HDR_SIZE (8+20) /* Size assuming ethernet */
+#define ARP_HDR_SIZE (8+20) /* Size assuming ethernet */
/*
- * Maximum packet size; used to allocate packet storage.
- * TFTP packets can be 524 bytes + IP header + ethernet header.
- * Lets be conservative, and go for 38 * 16. (Must also be
- * a multiple of 32 bytes).
+ * Maximum packet size; used to allocate packet storage.
+ * TFTP packets can be 524 bytes + IP header + ethernet header.
+ * Lets be conservative, and go for 38 * 16. (Must also be
+ * a multiple of 32 bytes).
*/
-// #define PKTSIZE 1536
+/* #define PKTSIZE 1536 */
#define PKTSIZE 608
/*
- * Maximum receive ring size; that is, the number of packets
- * we can buffer before overflow happens. Basically, this just
- * needs to be enough to prevent a packet being discarded while
- * we are processing the previous one.
+ * Maximum receive ring size; that is, the number of packets
+ * we can buffer before overflow happens. Basically, this just
+ * needs to be enough to prevent a packet being discarded while
+ * we are processing the previous one.
*/
#define RINGSZ 4
#define RINGSZ_LOG2 2
*/
/* net.c */
-extern uchar NetOurEther[6]; /* Our ethernet address */
-extern uchar NetServerEther[6]; /* Boot server enet address */
-extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
-extern IPaddr_t NetServerIP; /* Server IP addr (0 = unkn) */
-extern volatile uchar * NetTxPacket; /* THE transmit packet */
-extern volatile uchar * NetRxPackets[PKTBUFSRX]; /* Receive packets */
-extern volatile uchar * NetRxPkt; /* Current receive packet */
-extern int NetRxPktLen; /* Current rx packet length */
-extern unsigned NetIPID; /* IP ID (counting) */
-extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */
-
-extern int NetState; /* Network loop state */
+/** BOOTP EXTENTIONS **/
+extern int NetOurGatewaysNum; /* Out gateways number */
+extern IPaddr_t NetOurGatewaysIP[4] ; /* Our gateways IP addresses */
+extern IPaddr_t NetOurSubnetMask ; /* Our subnet mask (0 = unknown)*/
+extern char NetOurNISDomain[32] ; /* Our NIS domain */
+extern char NetOurHostName[32] ; /* Our hostname */
+extern char NetOurRootPath[32] ; /* Our root path */
+extern int NetBootFileSize ; /* Our boot file size */
+/** END OF BOOTP EXTENTIONS **/
+extern uchar NetOurEther[6]; /* Our ethernet address */
+extern uchar NetServerEther[6]; /* Boot server enet address */
+extern IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
+extern IPaddr_t NetServerIP; /* Server IP addr (0 = unknown) */
+extern volatile uchar * NetTxPacket; /* THE transmit packet */
+extern volatile uchar * NetRxPackets[PKTBUFSRX];/* Receive packets */
+extern volatile uchar * NetRxPkt; /* Current receive packet */
+extern int NetRxPktLen; /* Current rx packet length */
+extern unsigned NetIPID; /* IP ID (counting) */
+extern uchar NetBcastAddr[6]; /* Ethernet boardcast address */
+
+extern int NetState; /* Network loop state */
#define NETLOOP_CONTINUE 1
#define NETLOOP_RESTART 2
#define NETLOOP_SUCCESS 3
/* Shutdown adapters and cleanup */
extern void NetStop(void);
-/* Load failed. Start again. */
+/* Load failed. Start again. */
extern void NetStartAgain(void);
/* Copy ethernet address */
extern void NetSetIP(volatile uchar *, IPaddr_t, int, int, int);
/* Checksum */
-extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */
-extern uint NetCksum(uchar *, int); /* Calculate the checksum */
+extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */
+extern uint NetCksum(uchar *, int); /* Calculate the checksum */
/* Set callbacks */
-extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
-extern void NetSetTimeout(int, thand_f *); /* Set timeout handler */
+extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
+extern void NetSetTimeout(int, thand_f *); /* Set timeout handler */
/* Transmit "NetTxPacket" */
extern void NetSendPacket(volatile uchar *, int);
/* Print an IP address on the console */
extern void NetPrintIPaddr(IPaddr_t);
+/* Convert a IP address to a string */
+extern void NetIPaddr (IPaddr_t x, char *s);
+
/**********************************************************************/
/*
#ifndef __VERSION_H__
#define __VERSION_H__
-#define PPCBOOT_VERSION "ppcboot 0.5.3"
+#define PPCBOOT_VERSION "ppcboot 0.6.0"
#endif /* __VERSION_H__ */
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
#ifndef _VIDEO_AD7176_H_
#define _VIDEO_AD7176_H_
+#define VIDEO_ENCODER_NAME "Analog Devices AD7176"
+
+#define VIDEO_ENCODER_I2C_RATE 100000 // Max rate is 100Khz
+
#define VIDEO_MODE_YUYV // The only mode supported by this encoder
#undef VIDEO_MODE_RGB
#define VIDEO_MODE_BPP 16
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _VIDEO_AD7177_H_
+#define _VIDEO_AD7177_H_
+
+#define VIDEO_ENCODER_NAME "Analog Devices AD7177"
+
+#define VIDEO_ENCODER_I2C_RATE 100000 // Max rate is 100Khz
+
+#define VIDEO_MODE_YUYV // The only mode supported by this encoder
+#undef VIDEO_MODE_RGB
+#define VIDEO_MODE_BPP 16
+
+#ifdef VIDEO_MODE_PAL
+#define VIDEO_ACTIVE_COLS 720
+#define VIDEO_ACTIVE_ROWS 576
+#define VIDEO_VISIBLE_COLS 640
+#define VIDEO_VISIBLE_ROWS 480
+#endif
+
+#ifdef VIDEO_MODE_NTSC
+#define VIDEO_ACTIVE_COLS 720
+#define VIDEO_ACTIVE_ROWS 525
+#define VIDEO_VISIBLE_COLS 640
+#define VIDEO_VISIBLE_ROWS 400
+#endif
+
+static unsigned char
+ video_encoder_data[] = {
+#ifdef VIDEO_MODE_NTSC
+ 0x04, // Mode Register 0
+#ifdef VIDEO_DEBUG_COLORBARS
+ 0xc2,
+#else
+ 0x42, // Mode Register 1
+#endif
+ 0x16, // Subcarrier Freq 0
+ 0x7c, // Subcarrier Freq 1
+ 0xf0, // Subcarrier Freq 2
+ 0x21, // Subcarrier Freq 3
+ 0x00, // Subcarrier phase
+ 0x02, // Timing Register 0
+ 0x00, // Extended Captioning 0
+ 0x00, // Extended Captioning 1
+ 0x00, // Closed Captioning 0
+ 0x00, // Closed Captioning 1
+ 0x00, // Timing Register 1
+ 0x08, // Mode Register 2
+ 0x00, // Pedestal Register 0
+ 0x00, // Pedestal Register 1
+ 0x00, // Pedestal Register 2
+ 0x00, // Pedestal Register 3
+ 0x00 // Mode Register 3
+
+#endif
+
+#ifdef VIDEO_MODE_PAL
+ 0x05, // Mode Register 0
+#ifdef VIDEO_DEBUG_COLORBARS
+ 0xc2,
+#else
+ 0x42, // Mode Register 1
+#endif
+ 0xcb, // Subcarrier Freq 0
+ 0x8a, // Subcarrier Freq 1
+ 0x09, // Subcarrier Freq 2
+ 0x2a, // Subcarrier Freq 3
+ 0x00, // Subcarrier phase
+ 0x0a, // Timing Register 0
+ 0x00, // Extended Captioning 0
+ 0x00, // Extended Captioning 1
+ 0x00, // Closed Captioning 0
+ 0x00, // Closed Captioning 1
+ 0x00, // Timing Register 1
+ 0x08, // Mode Register 2
+ 0x00, // Pedestal Register 0
+ 0x00, // Pedestal Register 1
+ 0x00, // Pedestal Register 2
+ 0x00, // Pedestal Register 3
+ 0x00 // Mode Register 3
+#endif
+ } ;
+
+#endif
typedef struct {
unsigned char *data;
int width,
- height,
+ height,
bpp,
pixel_size,
size;
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
#ifndef _VIDEO_FONT_
#define _VIDEO_FONT_
-/* $Id: zlib.h,v 1.1 2000/07/18 08:54:27 wd Exp $ */
+/* $Id: zlib.h,v 1.2 2000/10/25 10:46:51 wd Exp $ */
/*
* This file is derived from zlib.h and zconf.h from the zlib-0.95
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt nbytes));
+typedef void (*cb_func) OF((Bytef *buf, uInt len));
+
struct internal_state;
typedef struct z_stream_s {
Byte data_type; /* best guess about the data type: ascii or binary */
+ cb_func outcb; /* called regularly just before blocks of output */
+
} z_stream;
/*
--- /dev/null
+#
+# (C) Copyright 2000
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = lib$(BOARD).a
+
+OBJS = $(BOARD).o flash.o vpd.o
+
+$(LIB): .depend $(OBJS)
+ $(AR) crv $@ $^
+
+#########################################################################
+
+.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
+ $(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
+
+sinclude .depend
+
+#########################################################################
--- /dev/null
+#
+# (C) Copyright 2000
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+#
+# MBX8xx boards
+#
+
+TEXT_BASE = 0xfe000000
+//TEXT_BASE = 0x00200000
--- /dev/null
+#ifndef __csr_h
+#define __csr_h
+
+/*
+ * (C) Copyright 2000
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * Control and Status Register definitions for the MBX
+ *
+ *--------------------------------------------------------------------
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/* bits for CR1 and SR1 */
+#define CSR1_ETEN 0x80 /* Ethernet Transceiver Enabled */
+#define CSR1_ELEN 0x40 /* Ethernet XCVR in Internal Loopback */
+#define CSR1_EAEN 0x20 /* Auto selection TP/AUI Enabled */
+#define CSR1_TPEN 0x10 /* TP manually selected */
+#define CSR1_FDDIS 0x08 /* Full Duplex Mode disabled */
+#define CSR1_FCTEN 0x04 /* Collision Testing of XCVR disabled */
+#define CSR1_COM1EN 0x02 /* COM1 signals routed to RS232 Transceiver */
+#define CSR1_XCVRDIS 0x01 /* Onboard RS232 Transceiver Disabled */
+
+/* FIXME - CSR2 bits not yet defined */
+
+#define MBX_CSR1 (*((uchar *)CFG_CSR_BASE))
+#define MBX_CSR2 (*((uchar *)CFG_CSR_BASE + 1))
+
+#endif /* __csr_h */
--- /dev/null
+#ifndef __dimm_h
+#define __dimm_h
+
+/*
+ * Module name: %M%
+ * Description:
+ * Serial Presence Detect Definitions Module
+ * SCCS identification: %I%
+ * Branch: %B%
+ * Sequence: %S%
+ * Date newest applied delta was created (MM/DD/YY): %G%
+ * Time newest applied delta was created (HH:MM:SS): %U%
+ * SCCS file name %F%
+ * Fully qualified SCCS file name:
+ * %P%
+ * Copyright:
+ * (C) COPYRIGHT MOTOROLA, INC. 1996
+ * ALL RIGHTS RESERVED
+ * Notes:
+ * 1. All data was taken from an IBM application note titled
+ * "Serial Presence Detect Definitions".
+ * History:
+ * Date Who
+ *
+ * 10/24/96 Rob Baxter
+ * Initial release.
+ *
+ */
+
+/*
+ * serial PD byte assignment address map (256 byte EEPROM)
+ */
+typedef struct dimm
+{
+ uchar n_bytes; /* 00 number of bytes written/used */
+ uchar t_bytes; /* 01 total number of bytes in serial PD device */
+ uchar fmt; /* 02 fundamental memory type (FPM/EDO/SDRAM) */
+ uchar n_row; /* 03 number of rows */
+ uchar n_col; /* 04 number of columns */
+ uchar n_banks; /* 05 number of banks */
+ uchar data_w_lo; /* 06 data width */
+ uchar data_w_hi; /* 07 data width */
+ uchar ifl; /* 08 interface levels */
+ uchar a_ras; /* 09 RAS access */
+ uchar a_cas; /* 0A CAS access */
+ uchar ct; /* 0B configuration type (non-parity/parity/ECC) */
+ uchar refresh_rt; /* 0C refresh rate/type */
+ uchar p_dram_o; /* 0D primary DRAM organization */
+ uchar s_dram_o; /* 0E secondary DRAM organization (parity/ECC-checkbits) */
+ uchar reserved[17]; /* 0F reserved fields for future offerings */
+ uchar ss_info[32]; /* 20 superset information (may be used in the future) */
+ uchar m_info[64]; /* 40 manufacturer information (optional) */
+ uchar unused[128]; /* 80 unused storage locations */
+} dimm_t;
+
+/*
+ * memory type definitions
+ */
+#define DIMM_MT_FPM 1 /* standard FPM (fast page mode) DRAM */
+#define DIMM_MT_EDO 2 /* EDO (extended data out) */
+#define DIMM_MT_PN 3 /* pipelined nibble */
+#define DIMM_MT_SDRAM 4 /* SDRAM (synchronous DRAM) */
+
+/*
+ * row addresses definitions
+ */
+#define DIMM_RA_RDNDNT (1<<7) /* redundant addressing */
+#define DIMM_RA_MASK 0x7f /* number of row addresses mask */
+
+/*
+ * module interface levels definitions
+ */
+#define DIMM_IFL_TTL 0 /* TTL/5V tolerant */
+#define DIMM_IFL_LVTTL 1 /* LVTTL (not 5V tolerant) */
+#define DIMM_IFL_HSTL15 2 /* HSTL 1.5 */
+#define DIMM_IFL_SSTL33 3 /* SSTL 3.3 */
+#define DIMM_IFL_SSTL25 4 /* SSTL 2.5 */
+
+/*
+ * DIMM configuration type definitions
+ */
+#define DIMM_CT_NONE 0 /* none */
+#define DIMM_CT_PARITY 1 /* parity */
+#define DIMM_CT_ECC 2 /* ECC */
+
+/*
+ * row addresses definitions
+ */
+#define DIMM_RRT_SR (1<<7) /* self refresh flag */
+#define DIMM_RRT_MASK 0x7f /* refresh rate mask */
+#define DIMM_RRT_NRML 0x00 /* normal (15.625us) */
+#define DIMM_RRT_R_3_9 0x01 /* reduced .25x (3.9us) */
+#define DIMM_RRT_R_7_8 0x02 /* reduced .5x (7.8us) */
+#define DIMM_RRT_E_31_3 0x03 /* extended 2x (31.3us) */
+#define DIMM_RRT_E_62_5 0x04 /* extended 4x (62.5us) */
+#define DIMM_RRT_E_125 0x05 /* extended 8x (125us) */
+
+#endif /* __dimm_h */
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Marius Groeger <mgroeger@sysgo.de>
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * Flash Routines for AM290[48]0B devices
+ *
+ *--------------------------------------------------------------------
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <mpc8xx.h>
+#include "vpd.h"
+
+flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
+
+/*-----------------------------------------------------------------------
+ * Protection Flags:
+ */
+
+#define FLAG_PROTECT_SET 0x01
+#define FLAG_PROTECT_CLEAR 0x02
+
+/*-----------------------------------------------------------------------
+ * Functions
+ */
+
+ulong flash_get_size (vu_long *addr, flash_info_t *info);
+int flash_write (uchar *, ulong, ulong);
+flash_info_t *addr2info (ulong);
+
+static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
+static int write_word (flash_info_t *info, ulong dest, ulong data);
+static int flash_protect (int flag, ulong from, ulong to, flash_info_t *info);
+
+/*-----------------------------------------------------------------------
+ */
+
+unsigned long flash_init (void)
+{
+ unsigned long size, totsize;
+ int i;
+ ulong addr;
+
+ /* Init: no FLASHes known */
+ for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
+ flash_info[i].flash_id = FLASH_UNKNOWN;
+ }
+
+ /* Static FLASH Bank configuration here - FIXME XXX */
+
+ totsize = 0;
+ addr = 0xfc000000;
+ for(i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
+ size = flash_get_size((vu_long *)addr, &flash_info[i]);
+ if (flash_info[i].flash_id == FLASH_UNKNOWN)
+ break;
+ totsize += size;
+ addr += size;
+ }
+
+ addr = 0xfe000000;
+ for(i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
+
+ size = flash_get_size((vu_long *)addr, &flash_info[i]);
+ if (flash_info[i].flash_id == FLASH_UNKNOWN)
+ break;
+ totsize += size;
+ addr += size;
+ }
+
+ /* monitor protection ON by default */
+ (void)flash_protect(FLAG_PROTECT_SET,
+ CFG_FLASH_BASE,
+ CFG_FLASH_BASE+CFG_MONITOR_LEN-1,
+ &flash_info[0]);
+
+ return (totsize);
+}
+
+/*-----------------------------------------------------------------------
+ * Check or set protection status for monitor sectors
+ *
+ * The monitor always occupies the _first_ part of the _first_ Flash bank.
+ */
+static int flash_protect (int flag, ulong from, ulong to, flash_info_t *info)
+{
+ ulong b_end = info->start[0] + info->size - 1; /* bank end address */
+ int rc = 0;
+ int first = -1;
+ int last = -1;
+ int i;
+
+ if (to < info->start[0]) {
+ return (0);
+ }
+
+ for (i=0; i<info->sector_count; ++i) {
+ ulong end; /* last address in current sect */
+ short s_end;
+
+ s_end = info->sector_count - 1;
+
+ end = (i == s_end) ? b_end : info->start[i + 1] - 1;
+
+ if (from > end) {
+ continue;
+ }
+ if (to < info->start[i]) {
+ continue;
+ }
+
+ if (from == info->start[i]) {
+ first = i;
+ if (last < 0) {
+ last = s_end;
+ }
+ }
+ if (to == end) {
+ last = i;
+ if (first < 0) {
+ first = 0;
+ }
+ }
+ }
+
+ for (i=first; i<=last; ++i) {
+ if (flag & FLAG_PROTECT_CLEAR) {
+ info->protect[i] = 0;
+ } else if (flag & FLAG_PROTECT_SET) {
+ info->protect[i] = 1;
+ }
+ if (info->protect[i]) {
+ rc = 1;
+ }
+ }
+ return (rc);
+}
+
+
+/*-----------------------------------------------------------------------
+ */
+void flash_print_info (flash_info_t *info)
+{
+ int i;
+
+ if (info->flash_id == FLASH_UNKNOWN) {
+ printf ("missing or unknown FLASH type\n");
+ return;
+ }
+
+ switch (info->flash_id >> 8) {
+ case 0x1:
+ printf ("AMD ");
+ break;
+ default:
+ printf ("Unknown Vendor ");
+ break;
+ }
+
+ switch (info->flash_id & 0xff) {
+ case AMD_ID_F040B:
+ printf ("AM29F040B (4 Mbit)\n");
+ break;
+ case AMD_ID_F080B:
+ printf ("AM29F080B (8 Mbit)\n");
+ break;
+ default:
+ printf ("Unknown Chip Type\n");
+ break;
+ }
+
+ printf (" Size: %ld MB in %d Sectors\n",
+ info->size >> 20, info->sector_count);
+
+ printf (" Sector Start Addresses:");
+ for (i=0; i<info->sector_count; ++i) {
+ if ((i % 5) == 0)
+ printf ("\n ");
+ printf (" %08lX%s",
+ info->start[i],
+ info->protect[i] ? " (RO)" : " "
+ );
+ }
+ printf ("\n");
+}
+
+/*
+ * The following code cannot be run from FLASH!
+ */
+
+ulong flash_get_size (vu_long *addr, flash_info_t *info)
+{
+ short i;
+ ulong vendor, devid;
+ ulong base = (ulong)addr;
+
+ /* Write auto select command: read Manufacturer ID */
+ addr[0x0555] = 0xAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+ addr[0x0555] = 0x90909090;
+
+ vendor = addr[0];
+ devid = addr[1] & 0xff;
+
+ /* only support AMD */
+ if (vendor != 0x01010101) {
+ return 0;
+ }
+
+ vendor &= 0xf;
+ devid &= 0xff;
+
+ if (devid == AMD_ID_F040B) {
+ info->flash_id = vendor << 8 | devid;
+ info->sector_count = 8;
+ info->size = info->sector_count * 0x10000;
+ }
+ else if (devid == AMD_ID_F080B) {
+ info->flash_id = vendor << 8 | devid;
+ info->sector_count = 4;
+ info->size = 4 * info->sector_count * 0x10000;
+ }
+ else {
+ printf ("## Unknown Flash Type: %08lx\n", devid);
+ return 0;
+ }
+
+ /* check for protected sectors */
+ for (i = 0; i < info->sector_count; i++) {
+ /* sector base address */
+ info->start[i] = base + i * (info->size / info->sector_count);
+ /* read sector protection at sector address, (A7 .. A0) = 0x02 */
+ /* D0 = 1 if protected */
+ addr = (volatile unsigned long *)(info->start[i]);
+ info->protect[i] = addr[2] & 1;
+ }
+
+ /*
+ * Prevent writes to uninitialized FLASH.
+ */
+ if (info->flash_id != FLASH_UNKNOWN) {
+ addr = (vu_long *)info->start[0];
+ addr[0] = 0xF0; /* reset bank */
+ }
+
+ return (info->size);
+}
+
+
+/*-----------------------------------------------------------------------
+ */
+
+void flash_erase (flash_info_t *info, int s_first, int s_last)
+{
+ vu_long *addr = (vu_long*)(info->start[0]);
+ int flag, prot, sect, l_sect;
+ ulong start, now, last;
+
+ if ((s_first < 0) || (s_first > s_last)) {
+ if (info->flash_id == FLASH_UNKNOWN) {
+ printf ("- missing\n");
+ } else {
+ printf ("- no sectors to erase\n");
+ }
+ return;
+ }
+
+ prot = 0;
+ for (sect = s_first; sect <= s_last; sect++) {
+ if (info->protect[sect]) {
+ prot++;
+ }
+ }
+
+ if (prot) {
+ printf ("- Warning: %d protected sectors will not be erased!\n",
+ prot);
+ } else {
+ printf ("\n");
+ }
+
+ l_sect = -1;
+
+ /* Disable interrupts which might cause a timeout here */
+ flag = disable_interrupts();
+
+ addr[0x0555] = 0XAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+ addr[0x0555] = 0x80808080;
+ addr[0x0555] = 0XAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+
+ /* Start erase on unprotected sectors */
+ for (sect = s_first; sect<=s_last; sect++) {
+ if (info->protect[sect] == 0) { /* not protected */
+ addr = (vu_long*)(info->start[sect]);
+ addr[0] = 0x30303030;
+ l_sect = sect;
+ }
+ }
+
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ /* wait at least 80us - let's wait 1 ms */
+ udelay (1000);
+
+ /*
+ * We wait for the last triggered sector
+ */
+ if (l_sect < 0)
+ goto DONE;
+
+ start = get_timer (0);
+ last = start;
+ addr = (vu_long*)(info->start[l_sect]);
+ while ((addr[0] & 0x80808080) != 0x80808080) {
+ if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+ printf ("Timeout\n");
+ return;
+ }
+ /* show that we're waiting */
+ if ((now - last) > 1000) { /* every second */
+ serial_putc ('.');
+ last = now;
+ }
+ }
+
+ DONE:
+ /* reset to read mode */
+ addr = (volatile unsigned long *)info->start[0];
+ addr[0] = 0xF0F0F0F0; /* reset bank */
+
+ printf (" done\n");
+}
+
+/*-----------------------------------------------------------------------
+ */
+
+flash_info_t *addr2info (ulong addr)
+{
+ flash_info_t *info;
+ int i;
+
+ for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
+ if ((addr >= info->start[0]) &&
+ (addr < (info->start[0] + info->size)) ) {
+ return (info);
+ }
+ }
+
+ return (NULL);
+}
+
+/*-----------------------------------------------------------------------
+ * Copy memory to flash.
+ * Make sure all target addresses are within Flash bounds,
+ * and no protected sectors are hit.
+ * Returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ * 4 - target range includes protected sectors
+ * 8 - target address not in Flash memory
+ */
+int flash_write (uchar *src, ulong addr, ulong cnt)
+{
+ int i;
+ ulong end = addr + cnt - 1;
+ flash_info_t *info_first = addr2info (addr);
+ flash_info_t *info_last = addr2info (end );
+ flash_info_t *info;
+
+ if (cnt == 0) {
+ return (0);
+ }
+
+ if (!info_first || !info_last) {
+ return (8);
+ }
+
+ for (info = info_first; info <= info_last; ++info) {
+ ulong b_end = info->start[0] + info->size; /* bank end addr */
+ short s_end = info->sector_count - 1;
+ for (i=0; i<info->sector_count; ++i) {
+ ulong e_addr = (i == s_end) ? b_end : info->start[i + 1];
+
+ if ((end >= info->start[i]) && (addr < e_addr) &&
+ (info->protect[i] != 0) ) {
+ return (4);
+ }
+ }
+ }
+
+ /* finally write data to flash */
+ for (info = info_first; info <= info_last && cnt>0; ++info) {
+ ulong len;
+
+ len = info->start[0] + info->size - addr;
+ if (len > cnt)
+ len = cnt;
+ if ((i = write_buff(info, src, addr, len)) != 0) {
+ return (i);
+ }
+ cnt -= len;
+ addr += len;
+ src += len;
+ }
+ return (0);
+}
+
+/*-----------------------------------------------------------------------
+ * Copy memory to flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+
+static int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+{
+ ulong cp, wp, data;
+ int i, l, rc;
+
+ wp = (addr & ~3); /* get lower word aligned address */
+
+ /*
+ * handle unaligned start bytes
+ */
+ if ((l = addr - wp) != 0) {
+ data = 0;
+ for (i=0, cp=wp; i<l; ++i, ++cp) {
+ data = (data << 8) | (*(uchar *)cp);
+ }
+ for (; i<4 && cnt>0; ++i) {
+ data = (data << 8) | *src++;
+ --cnt;
+ ++cp;
+ }
+ for (; cnt==0 && i<4; ++i, ++cp) {
+ data = (data << 8) | (*(uchar *)cp);
+ }
+
+ if ((rc = write_word(info, wp, data)) != 0) {
+ return (rc);
+ }
+ wp += 4;
+ }
+
+ /*
+ * handle word aligned part
+ */
+ while (cnt >= 4) {
+ data = 0;
+ for (i=0; i<4; ++i) {
+ data = (data << 8) | *src++;
+ }
+ if ((rc = write_word(info, wp, data)) != 0) {
+ return (rc);
+ }
+ wp += 4;
+ cnt -= 4;
+ }
+
+ if (cnt == 0) {
+ return (0);
+ }
+
+ /*
+ * handle unaligned tail bytes
+ */
+ data = 0;
+ for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+ data = (data << 8) | *src++;
+ --cnt;
+ }
+ for (; i<4; ++i, ++cp) {
+ data = (data << 8) | (*(uchar *)cp);
+ }
+
+ return (write_word(info, wp, data));
+}
+
+/*-----------------------------------------------------------------------
+ * Write a word to Flash, returns:
+ * 0 - OK
+ * 1 - write timeout
+ * 2 - Flash not erased
+ */
+static int write_word (flash_info_t *info, ulong dest, ulong data)
+{
+ vu_long *addr = (vu_long*)(info->start[0]);
+ ulong start;
+ int flag;
+
+ /* Check if Flash is (sufficiently) erased */
+ if ((*((vu_long *)dest) & data) != data) {
+ return (2);
+ }
+ /* Disable interrupts which might cause a timeout here */
+ flag = disable_interrupts();
+
+ addr[0x0555] = 0xAAAAAAAA;
+ addr[0x02AA] = 0x55555555;
+ addr[0x0555] = 0xA0A0A0A0;
+
+ *((vu_long *)dest) = data;
+
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ /* data polling for D7 */
+ start = get_timer (0);
+ while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) {
+ if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+ return (1);
+ }
+ }
+ return (0);
+}
+
+/*-----------------------------------------------------------------------
+ */
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * Board specific routines for the MBX
+ *
+ * - initialisation
+ * - interface to VPD data (mac address, clock speeds)
+ * - memory controller
+ * - serial io initialisation
+ * - ethernet io initialisation
+ *
+ * -----------------------------------------------------------------
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <commproc.h>
+#include "mpc8xx.h"
+#include "dimm.h"
+#include "vpd.h"
+#include "csr.h"
+
+/* ------------------------------------------------------------------------- */
+
+const uint sdram_table_40[] =
+{
+ /* DRAM - single read. (offset 0 in upm RAM)
+ */
+ 0xCFAFC004, 0x0FAFC404, 0x0CAF0C04, 0x30AF0C00,
+ 0xF1BF4805, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* DRAM - burst read. (offset 8 in upm RAM)
+ */
+ 0xCFAFC004, 0x0FAFC404, 0x0CAF0C04, 0x03AF0C08,
+ 0x0CAF0C04, 0x03AF0C08, 0x0CAF0C04, 0x03AF0C08,
+ 0x0CAF0C04, 0x30AF0C00, 0xF3BF4805, 0xFFFFC005,
+ 0xFFFFC005, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* DRAM - single write. (offset 18 in upm RAM)
+ */
+ 0xCFFF0004, 0x0FFF0404, 0x0CFF0C00, 0x33FF4804,
+ 0xFFFFC005, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* DRAM - burst write. (offset 20 in upm RAM)
+ */
+ 0xCFFF0004, 0x0FFF0404, 0x0CFF0C00, 0x03FF0C0C,
+ 0x0CFF0C00, 0x03FF0C0C, 0x0CFF0C00, 0x03FF0C0C,
+ 0x0CFF0C00, 0x33FF4804, 0xFFFFC005, 0xFFFFC005,
+ 0xFFFFC005, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* refresh (offset 30 in upm RAM)
+ */
+ 0xFCFFC004, 0xC0FFC004, 0x01FFC004, 0x0FFFC004,
+ 0x3FFFC004, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+ 0xFFFFC005, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* exception. (offset 3c in upm RAM)
+ */
+ 0xFFFFC007, 0xFFFFC007, 0xFFFFC007, 0xFFFFC007,
+};
+
+const uint sdram_table_50[] =
+{
+ /* DRAM - single read. (offset 0 in upm RAM)
+ */
+ 0xCFAFC004, 0x0FAFC404, 0x0CAF8C04, 0x10AF0C04,
+ 0xF0AF0C00, 0xF3BF4805, 0xFFFFC005, 0xFFFFC005,
+
+ /* DRAM - burst read. (offset 8 in upm RAM)
+ */
+ 0xCFAFC004, 0x0FAFC404, 0x0CAF8C04, 0x00AF0C04,
+ 0x07AF0C08, 0x0CAF0C04, 0x01AF0C04, 0x0FAF0C04,
+ 0x0CAF0C04, 0x01AF0C04, 0x0FAF0C08, 0x0CAF0C04,
+ 0x10AF0C04, 0xF0AFC000, 0xF3FF4805, 0xFFFFC005,
+
+ /* DRAM - single write. (offset 18 in upm RAM)
+ */
+ 0xCFFF0004, 0x0FFF0404, 0x0CFF0C00, 0x13FF4804,
+ 0xFFFFC004, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* DRAM - burst write. (offset 20 in upm RAM)
+ */
+ 0xCFFF0004, 0x0FFF0404, 0x0CFF0C00, 0x03FF0C0C,
+ 0x0CFF0C00, 0x03FF0C0C, 0x0CFF0C00, 0x03FF0C0C,
+ 0x0CFF0C00, 0x13FF4804, 0xFFFFC004, 0xFFFFC005,
+ 0xFFFFC005, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* refresh (offset 30 in upm RAM)
+ */
+ 0xFCFFC004, 0xC0FFC004, 0x01FFC004, 0x0FFFC004,
+ 0x1FFFC004, 0xFFFFC004, 0xFFFFC005, 0xFFFFC005,
+ 0xFFFFC005, 0xFFFFC005, 0xFFFFC005, 0xFFFFC005,
+
+ /* exception. (offset 3c in upm RAM)
+ */
+ 0xFFFFC007, 0xFFFFC007, 0xFFFFC007, 0xFFFFC007,
+};
+
+/* ------------------------------------------------------------------------- */
+
+static unsigned int get_reffreq(void);
+
+void board_init(void)
+{
+ volatile immap_t *immr = (immap_t *)CFG_IMMR;
+ volatile memctl8xx_t *memctl = &immr->im_memctl;
+ unsigned int speed, refclock, plprcr;
+
+ /*
+ * Reset CPM
+ */
+ immr->im_cpm.cp_cpcr = CPM_CR_RST;
+ do {
+ __asm__ volatile ("eieio");
+ } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG);
+
+ /* SYPCR - contains watchdog control (11-9) */
+ immr->im_siu_conf.sc_sypcr = CFG_SYPCR;
+
+ /* SIUMCR - contains debug pin configuration (11-6) */
+ immr->im_siu_conf.sc_siumcr = CFG_SIUMCR;
+
+ /* timebase status and control register */
+ immr->im_sitk.sitk_tbscrk = KAPWR_KEY;
+ immr->im_sit.sit_tbscr = 0xc3;
+
+ /* pit status and control register */
+ immr->im_sitk.sitk_piscrk = KAPWR_KEY;
+ immr->im_sit.sit_piscr = CFG_PISCR;
+
+ /* pll, low power, and reset control register */
+ immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
+
+ /* system clock and reset control register */
+ immr->im_clkrstk.cark_sccrk = KAPWR_KEY;
+ immr->im_clkrst.car_sccr = CFG_SCCR;
+
+ /* real-time clock status and control register */
+ immr->im_sitk.sitk_rtcsck = KAPWR_KEY;
+ immr->im_sit.sit_rtcsc = 0x00C3;
+
+ /*
+ * Prepare access to i2c bus. The MBX offers 3 devices on the i2c
+ * bus:
+ * 1. Vital Product Data (contains clock speeds, mac-address etc,
+ * see vpd.h)
+ * 2. RAM Specs (see dimm.h)
+ * 2. DIMM Specs (see dimm.h)
+ */
+ vpd_init();
+
+ speed = board_get_cpufreq();
+ refclock = get_reffreq();
+
+ plprcr = CFG_PLPRCR;
+ plprcr |= ((speed + refclock / 2) / refclock - 1) << 20;
+ immr->im_clkrst.car_plprcr = plprcr;
+
+ /*
+ * preliminary setup of memory controller:
+ * - map pci registers
+ * - map configuation and status registers
+ * - DON'T map ram/flash/rom yet, this is done in initdram()
+ */
+ switch(speed / 1000000)
+ {
+ case 40:
+ memctl->memc_br4 = CFG_CSR_BASE | 0x401;
+ memctl->memc_or4 = CFG_CSR_OR | 0x920;
+ break;
+ case 50:
+ memctl->memc_br4 = CFG_CSR_BASE | 0x401;
+ memctl->memc_or4 = CFG_CSR_OR | 0x930;
+ break;
+ default:
+ hang();
+ break;
+ }
+ memctl->memc_br5 = CFG_PCIMEM_BASE | 0x001;
+ memctl->memc_or5 = CFG_PCIMEM_OR;
+ memctl->memc_br6 = CFG_PCIBRIDGE_BASE | 0x001;
+ memctl->memc_or6 = CFG_PCIBRIDGE_OR;
+
+ MBX_CSR1 = 0;
+}
+
+void board_serial_init(void)
+{
+ MBX_CSR1 &= ~(CSR1_COM1EN | CSR1_XCVRDIS);
+}
+
+void board_ether_init(void)
+{
+ MBX_CSR1 &= ~CSR1_EAEN | CSR1_ELEN;
+ MBX_CSR1 |= CSR1_ETEN | CSR1_TPEN | CSR1_FDDIS;
+}
+
+unsigned int board_get_cpufreq(void)
+{
+ vpd_packet_t *packet;
+
+ packet = vpd_find_packet(VPD_PID_ICS);
+ return *((ulong*)packet->data);
+}
+
+unsigned int board_get_busfreq(unsigned int cpufreq)
+{
+ vpd_packet_t *packet;
+
+ packet = vpd_find_packet(VPD_PID_ECS);
+ return *((ulong*)packet->data);
+}
+
+static unsigned int get_reffreq(void)
+{
+ vpd_packet_t *packet;
+
+ packet = vpd_find_packet(VPD_PID_RCS);
+ return *((ulong*)packet->data);
+}
+
+void board_get_enetaddr (uchar *addr)
+{
+ int i;
+ vpd_packet_t *packet;
+
+ packet = vpd_find_packet(VPD_PID_EA);
+ for (i=0; i<6; i++)
+ addr[i] = packet->data[i];
+}
+
+/*
+ * Check Board Identity:
+ */
+
+int checkboard (void)
+{
+ vpd_packet_t *packet;
+ int i;
+
+ packet = vpd_find_packet(VPD_PID_PID);
+ for (i=0; i<packet->size; i++) {
+ serial_putc (packet->data[i]);
+ }
+ packet = vpd_find_packet(VPD_PID_MT);
+ for (i=0; i<packet->size; i++) {
+ serial_putc (packet->data[i]);
+ }
+ serial_putc ('(');
+ packet = vpd_find_packet(VPD_PID_FAN);
+ for (i=0; i<packet->size; i++) {
+ serial_putc (packet->data[i]);
+ }
+ serial_putc (')');
+ serial_putc ('\n');
+
+ return (1);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static ulong get_ramsize(dimm_t *dimm)
+{
+ ulong size = 0;
+
+ if (dimm->fmt == 1 || dimm->fmt == 2 || dimm->fmt == 3 || dimm->fmt == 4 )
+ {
+ size = (1 << (dimm->n_row + dimm->n_col)) * dimm->n_banks *
+ ((dimm->data_w_hi << 8 | dimm->data_w_lo) / 8);
+ }
+
+ return size;
+}
+
+long int initdram (int board_type)
+{
+ volatile immap_t *immap = (immap_t *)CFG_IMMR;
+ volatile memctl8xx_t *memctl = &immap->im_memctl;
+ unsigned long ram_sz = 0;
+ unsigned long dimm_sz = 0;
+ dimm_t vpd_dimm, vpd_dram;
+ unsigned int speed = board_get_cpufreq() / 1000000;
+
+ if (vpd_read(0xa2, (uchar*)&vpd_dimm, sizeof(vpd_dimm), 0) > 0)
+ {
+ dimm_sz = get_ramsize(&vpd_dimm);
+ }
+ if (vpd_read(0xa6, (uchar*)&vpd_dram, sizeof(vpd_dram), 0) > 0)
+ {
+ ram_sz = get_ramsize(&vpd_dram);
+ }
+
+ /*
+ * Only initialize memory controller when running from FLASH.
+ * When running from RAM, don't touch it.
+ */
+ if ((ulong)initdram & 0xff000000)
+ {
+ ulong dimm_bank;
+ ulong br0_32 = memctl->memc_br0 & 0x400;
+
+ switch(speed)
+ {
+ case 40:
+ upmconfig(UPMA, (uint *)sdram_table_40,
+ sizeof(sdram_table_40) / sizeof(uint));
+ memctl->memc_mptpr = 0x0200;
+ memctl->memc_mamr = dimm_sz ? 0x0682100 : 0x13801000;
+ memctl->memc_br0 = 0xfe000000 | br0_32 | 1;
+ memctl->memc_or0 = 0xff800930;
+ memctl->memc_br7 = 0xfc000000 | (br0_32 ^ br0_32) | 1;
+ memctl->memc_or7 = 0xff800930;
+ break;
+ case 50:
+ upmconfig(UPMA, (uint *)sdram_table_50,
+ sizeof(sdram_table_50) / sizeof(uint));
+ memctl->memc_mptpr = 0x0200;
+ memctl->memc_mamr = dimm_sz ? 0x0882100 : 0x1882100;
+ memctl->memc_br0 = 0xfe000000 | br0_32 | 1;
+ memctl->memc_or0 = 0xff800940;
+ memctl->memc_br7 = 0xfc000000 | (br0_32 ^ br0_32) | 1;
+ memctl->memc_or7 = 0xff800940;
+ break;
+ default:
+ hang();
+ break;
+ }
+
+ /* now map ram and dimm, largest one first */
+ dimm_bank = dimm_sz / 2;
+ if (!dimm_sz)
+ {
+ memctl->memc_br1 = CFG_SDRAM_BASE | 0x81;
+ memctl->memc_or1 = ~(ram_sz - 1) | 0x400;
+ memctl->memc_br2 = 0;
+ memctl->memc_br3 = 0;
+ }
+ else if (ram_sz > dimm_bank)
+ {
+ memctl->memc_br1 = CFG_SDRAM_BASE | 0x81;
+ memctl->memc_or1 = ~(ram_sz - 1) | 0x400;
+ memctl->memc_br2 = (CFG_SDRAM_BASE + ram_sz) | 0x81;
+ memctl->memc_or2 = ~(dimm_bank - 1) | 0x400;
+ memctl->memc_br3 = (CFG_SDRAM_BASE + ram_sz + dimm_bank) | 0x81;
+ memctl->memc_or3 = ~(dimm_bank - 1) | 0x400;
+ }
+ else
+ {
+ memctl->memc_br2 = CFG_SDRAM_BASE | 0x81;
+ memctl->memc_or2 = ~(dimm_bank - 1) | 0x400;
+ memctl->memc_br3 = (CFG_SDRAM_BASE + dimm_bank) | 0x81;
+ memctl->memc_or3 = ~(dimm_bank - 1) | 0x400;
+ memctl->memc_br1 = (CFG_SDRAM_BASE + dimm_sz) | 0x81;
+ memctl->memc_or1 = ~(ram_sz - 1) | 0x400;
+ }
+ }
+
+ return ram_sz + dimm_sz;
+}
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = + SIZEOF_HEADERS;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .rel.text : { *(.rel.text) }
+ .rela.text : { *(.rela.text) }
+ .rel.data : { *(.rel.data) }
+ .rela.data : { *(.rela.data) }
+ .rel.rodata : { *(.rel.rodata) }
+ .rela.rodata : { *(.rela.rodata) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { *(.init) }
+ .plt : { *(.plt) }
+ .text :
+ {
+ /* WARNING - the following is hand-optimized to fit within */
+ /* the sector layout of our flash chips! XXX FIXME XXX */
+
+ mpc8xx/start.o (.text)
+
+ *(.text)
+
+ . = env_offset;
+ common/environment.o(.text)
+
+ *(.fixup)
+ *(.got1)
+ }
+ _etext = .;
+ PROVIDE (etext = .);
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata1)
+ }
+ .fini : { *(.fini) } =0
+ .ctors : { *(.ctors) }
+ .dtors : { *(.dtors) }
+
+ /* Read-write section, merged into data segment: */
+ . = (. + 0x00FF) & 0xFFFFFF00;
+ _erotext = .;
+ PROVIDE (erotext = .);
+ .reloc :
+ {
+ *(.got)
+ _GOT2_TABLE_ = .;
+ *(.got2)
+ _FIXUP_TABLE_ = .;
+ *(.fixup)
+ }
+ __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+ __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+ .data :
+ {
+ *(.data)
+ *(.data1)
+ *(.sdata)
+ *(.sdata2)
+ *(.dynamic)
+ CONSTRUCTORS
+ }
+ _edata = .;
+ PROVIDE (edata = .);
+
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ . = ALIGN(256);
+ __init_begin = .;
+ .text.init : { *(.text.init) }
+ .data.init : { *(.data.init) }
+ . = ALIGN(256);
+ __init_end = .;
+
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss) *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ _end = . ;
+ PROVIDE (end = .);
+}
+
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = + SIZEOF_HEADERS;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .rel.text : { *(.rel.text) }
+ .rela.text : { *(.rela.text) }
+ .rel.data : { *(.rel.data) }
+ .rela.data : { *(.rela.data) }
+ .rel.rodata : { *(.rel.rodata) }
+ .rela.rodata : { *(.rela.rodata) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { *(.init) }
+ .plt : { *(.plt) }
+ .text :
+ {
+ /* WARNING - the following is hand-optimized to fit within */
+ /* the sector layout of our flash chips! XXX FIXME XXX */
+
+ mpc8xx/start.o (.text)
+ common/dlmalloc.o (.text)
+ ppc/vsprintf.o (.text)
+ ppc/crc32.o (.text)
+ ppc/extable.o (.text)
+
+ . = env_offset;
+ common/environment.o(.text)
+
+ *(.text)
+ *(.fixup)
+ *(.got1)
+ }
+ _etext = .;
+ PROVIDE (etext = .);
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata1)
+ }
+ .fini : { *(.fini) } =0
+ .ctors : { *(.ctors) }
+ .dtors : { *(.dtors) }
+
+ /* Read-write section, merged into data segment: */
+ . = (. + 0x0FFF) & 0xFFFFF000;
+ _erotext = .;
+ PROVIDE (erotext = .);
+ .reloc :
+ {
+ *(.got)
+ _GOT2_TABLE_ = .;
+ *(.got2)
+ _FIXUP_TABLE_ = .;
+ *(.fixup)
+ }
+ __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+ __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+ .data :
+ {
+ *(.data)
+ *(.data1)
+ *(.sdata)
+ *(.sdata2)
+ *(.dynamic)
+ CONSTRUCTORS
+ }
+ _edata = .;
+ PROVIDE (edata = .);
+
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ . = ALIGN(4096);
+ __init_begin = .;
+ .text.init : { *(.text.init) }
+ .data.init : { *(.data.init) }
+ . = ALIGN(4096);
+ __init_end = .;
+
+ __bss_start = .;
+ .bss :
+ {
+ *(.sbss) *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ _end = . ;
+ PROVIDE (end = .);
+}
+
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * Code in faintly related to linux/arch/ppc/8xx_io:
+ * MPC8xx CPM I2C interface. Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
+ *
+ * This file implements functions to read the MBX's Vital Product Data
+ * (VPD). I can't use the more general i2c code in mpc8xx/... since I need
+ * the VPD at a time where there is no RAM available yet. Hence the VPD is
+ * read into a special area in the DPRAM (see config_MBX.h::CFG_DPRAMVPD).
+ *
+ * -----------------------------------------------------------------
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#ifdef CONFIG_8xx
+#include <commproc.h>
+#endif
+#include "vpd.h"
+
+/* Location of receive/transmit buffer descriptors
+ * Allocate one transmit bd and one receive bd.
+ * IIC_BD_FREE points to free bd space which we'll use as tx buffer.
+ */
+#define IIC_BD_TX1 (BD_IIC_START + 0*sizeof(cbd_t))
+#define IIC_BD_TX2 (BD_IIC_START + 1*sizeof(cbd_t))
+#define IIC_BD_RX (BD_IIC_START + 2*sizeof(cbd_t))
+#define IIC_BD_FREE (BD_IIC_START + 3*sizeof(cbd_t))
+
+/* FIXME -- replace 0x2000 with offsetof */
+#define VPD_P ((vpd_t *)(CFG_IMMR + 0x2000 + CFG_DPRAMVPD))
+
+/* transmit/receive buffers */
+#define IIC_RX_LENGTH 128
+
+#define WITH_MICROCODE_PATCH
+
+vpd_packet_t * vpd_find_packet(u_char ident)
+{
+ vpd_packet_t *packet;
+ vpd_t *vpd = VPD_P;
+
+ packet = (vpd_packet_t *)&vpd->packets;
+ while ((packet->identifier != ident) && packet->identifier != 0xFF)
+ {
+ packet = (vpd_packet_t *)((char *)packet + packet->size + 2);
+ }
+ return packet;
+}
+
+void vpd_init(void)
+{
+ volatile immap_t *im = (immap_t *)CFG_IMMR;
+ volatile cpm8xx_t *cp = &(im->im_cpm);
+ volatile i2c8xx_t *i2c = (i2c8xx_t *)&(im->im_i2c);
+ volatile iic_t *iip;
+#ifdef WITH_MICROCODE_PATCH
+ ulong reloc = 0;
+#endif
+
+ iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
+
+ /*
+ * kludge: when running from flash, no microcode patch can be
+ * installed. However, the DPMEM usually contains non-zero
+ * garbage at the relocatable patch base location, so lets clear
+ * it now. This way the rest of the code can support the microcode
+ * patch dynamically.
+ */
+ if ((ulong)vpd_init & 0xff000000)
+ iip->iic_rpbase = 0;
+
+#ifdef WITH_MICROCODE_PATCH
+ /* Check for and use a microcode relocation patch. */
+ if ((reloc = iip->iic_rpbase))
+ iip = (iic_t *)&cp->cp_dpmem[iip->iic_rpbase];
+#endif
+ /* Initialize Port B IIC pins */
+ cp->cp_pbodr |= 0x00000030;
+ cp->cp_pbdir |= 0x00000030;
+ cp->cp_pbpar |= 0x00000030;
+
+ i2c->i2c_i2mod = 0x04; /* filter clock */
+ i2c->i2c_i2add = 0x34; /* select an arbitrary (unique) address */
+ i2c->i2c_i2brg = 0x07; /* make clock run maximum slow */
+ i2c->i2c_i2cmr = 0x00; /* disable interrupts */
+ i2c->i2c_i2cer = 0x1f; /* clear events */
+ i2c->i2c_i2com = 0x01; /* configure i2c to work as master */
+
+ if (vpd_read(0xa4, (uchar*)VPD_P, VPD_EEPROM_SIZE, 0) != VPD_EEPROM_SIZE)
+ {
+ hang();
+ }
+}
+
+
+/* Read from I2C.
+ * This is a two step process. First, we send the "dummy" write
+ * to set the device offset for the read. Second, we perform
+ * the read operation.
+ */
+int vpd_read(uint iic_device, uchar *buf, int count, int offset)
+{
+ volatile immap_t *im = (immap_t *)CFG_IMMR;
+ volatile cpm8xx_t *cp = &(im->im_cpm);
+ volatile i2c8xx_t *i2c = (i2c8xx_t *)&(im->im_i2c);
+ volatile iic_t *iip;
+ volatile cbd_t *tbdf1, *tbdf2, *rbdf;
+ uchar *tb;
+ uchar event;
+#ifdef WITH_MICROCODE_PATCH
+ ulong reloc = 0;
+#endif
+
+ iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
+#ifdef WITH_MICROCODE_PATCH
+ /* Check for and use a microcode relocation patch. */
+ if ((reloc = iip->iic_rpbase))
+ iip = (iic_t *)&cp->cp_dpmem[iip->iic_rpbase];
+#endif
+ tbdf1 = (cbd_t *)&cp->cp_dpmem[IIC_BD_TX1];
+ tbdf2 = (cbd_t *)&cp->cp_dpmem[IIC_BD_TX2];
+ rbdf = (cbd_t *)&cp->cp_dpmem[IIC_BD_RX];
+
+ /* Send a "dummy write" operation. This is a write request with
+ * only the offset sent, followed by another start condition.
+ * This will ensure we start reading from the first location
+ * of the EEPROM.
+ */
+ tb = (uchar*)&cp->cp_dpmem[IIC_BD_FREE];
+ tb[0] = iic_device & 0xfe; /* device address */
+ tb[1] = offset; /* offset */
+ tbdf1->cbd_bufaddr = (uint)tb;
+ tbdf1->cbd_datlen = 2;
+ tbdf1->cbd_sc = 0x8400;
+
+ tb += 2;
+ tb[0] = iic_device | 1; /* device address */
+ tbdf2->cbd_bufaddr = (uint)tb;
+ tbdf2->cbd_datlen = count+1;
+ tbdf2->cbd_sc = 0xbc00;
+
+ rbdf->cbd_bufaddr = (uint)buf;
+ rbdf->cbd_datlen = 0;
+ rbdf->cbd_sc = 0xb000;
+
+ iip->iic_tbase = IIC_BD_TX1;
+ iip->iic_tbptr = IIC_BD_TX1;
+ iip->iic_rbase = IIC_BD_RX;
+ iip->iic_rbptr = IIC_BD_RX;
+ iip->iic_rfcr = 0x15;
+ iip->iic_tfcr = 0x15;
+ iip->iic_mrblr = count;
+ iip->iic_rstate = 0;
+ iip->iic_tstate = 0;
+
+ i2c->i2c_i2cer = 0x1f; /* clear event mask */
+ i2c->i2c_i2mod |= 1; /* enable iic operation */
+ i2c->i2c_i2com |= 0x80; /* start master */
+
+ /* wait for IIC transfer */
+ do {
+ __asm__ volatile ("eieio");
+ event = i2c->i2c_i2cer;
+ } while (event == 0);
+
+ if ((event & 0x10) || (event & 0x04)) {
+ count = -1;
+ goto bailout;
+ }
+
+bailout:
+ i2c->i2c_i2mod &= ~1; /* turn off iic operation */
+ i2c->i2c_i2cer = 0x1f; /* clear event mask */
+
+ return count;
+}
--- /dev/null
+#ifndef __vpd_h
+#define __vpd_h
+
+/*
+ * Module name: %M%
+ * Description:
+ * Vital Product Data (VPD) Header Module
+ * SCCS identification: %I%
+ * Branch: %B%
+ * Sequence: %S%
+ * Date newest applied delta was created (MM/DD/YY): %G%
+ * Time newest applied delta was created (HH:MM:SS): %U%
+ * SCCS file name %F%
+ * Fully qualified SCCS file name:
+ * %P%
+ * Copyright:
+ * (C) COPYRIGHT MOTOROLA, INC. 1996
+ * ALL RIGHTS RESERVED
+ * Notes:
+ * History:
+ * Date Who
+ *
+ * 10/24/96 Rob Baxter
+ * Initial release.
+ *
+ */
+
+#define VPD_EEPROM_SIZE 256 /* EEPROM size in bytes */
+
+/*
+ * packet tuple identifiers
+ *
+ * 0x0D - 0xBF reserved
+ * 0xC0 - 0xFE user defined
+ */
+#define VPD_PID_GI 0x00 /* guaranteed illegal */
+#define VPD_PID_PID 0x01 /* product identifier (ASCII) */
+#define VPD_PID_FAN 0x02 /* factory assembly-number (ASCII) */
+#define VPD_PID_SN 0x03 /* serial-number (ASCII) */
+#define VPD_PID_PCO 0x04 /* product configuration options(binary) */
+#define VPD_PID_ICS 0x05 /* internal clock speed in HZ (integer) */
+#define VPD_PID_ECS 0x06 /* external clock speed in HZ (integer) */
+#define VPD_PID_RCS 0x07 /* reference clock speed in HZ(integer) */
+#define VPD_PID_EA 0x08 /* ethernet address (binary) */
+#define VPD_PID_MT 0x09 /* microprocessor type (ASCII) */
+#define VPD_PID_CRC 0x0A /* EEPROM CRC (integer) */
+#define VPD_PID_FMC 0x0B /* FLASH memory configuration (binary) */
+#define VPD_PID_VLSI 0x0C /* VLSI revisions/versions (binary) */
+#define VPD_PID_TERM 0xFF /* termination */
+
+/*
+ * VPD structure (format)
+ */
+#define VPD_EYE_SIZE 8 /* eyecatcher size */
+typedef struct vpd_header
+{
+ uchar eyecatcher[VPD_EYE_SIZE]; /* eyecatcher - "MOTOROLA" */
+ ushort size; /* size of EEPROM */
+} vpd_header_t;
+
+#define VPD_DATA_SIZE (VPD_EEPROM_SIZE-sizeof(vpd_header_t))
+typedef struct vpd
+{
+ vpd_header_t header; /* header */
+ uchar packets[VPD_DATA_SIZE]; /* data */
+} vpd_t;
+
+/*
+ * packet tuple structure (format)
+ */
+typedef struct vpd_packet
+{
+ uchar identifier; /* identifier (PIDs above) */
+ uchar size; /* size of the following data area */
+ uchar data[1]; /* data (size is dependent upon PID) */
+} vpd_packet_t;
+
+/*
+ * MBX product configuration options bit definitions
+ *
+ * Notes:
+ * 1. The bit numbering is reversed in perspective with the C compiler.
+ */
+#define PCO_BBRAM (1<<0) /* battery-backed RAM (BBRAM) and socket */
+#define PCO_BOOTROM (1<<1) /* boot ROM and socket (i.e., socketed FLASH) */
+#define PCO_KAPWR (1<<2) /* keep alive power source (lithium battey) and control circuit */
+#define PCO_ENET_TP (1<<3) /* ethernet twisted pair (TP) connector (RJ45) */
+#define PCO_ENET_AUI (1<<4) /* ethernet attachment unit interface (AUI) header */
+#define PCO_PCMCIA (1<<5) /* PCMCIA socket */
+#define PCO_DIMM (1<<6) /* DIMM module socket */
+#define PCO_DTT (1<<7) /* digital thermometer and thermostat (DTT) device */
+#define PCO_LCD (1<<8) /* liquid crystal display (LCD) device */
+#define PCO_PCI (1<<9) /* PCI-Bus bridge device (QSpan) and ISA-Bus bridge device (Winbond) */
+#define PCO_PCIO (1<<10) /* PC I/O (COM1, COM2, FDC, LPT, Keyboard/Mouse) */
+#define PCO_EIDE (1<<11) /* enhanced IDE (EIDE) header */
+#define PCO_FDC (1<<12) /* floppy disk controller (FDC) header */
+#define PCO_LPT_8XX (1<<13) /* parallel port header via MPC8xx */
+#define PCO_LPT_PCIO (1<<14) /* parallel port header via PC I/O */
+
+/*
+ * FLASH memory configuration packet data
+ */
+typedef struct vpd_fmc
+{
+ ushort mid; /* manufacturer's idenitfier */
+ ushort did; /* manufacturer's device idenitfier */
+ uchar ddw; /* device data width (e.g., 8-bits, 16-bits) */
+ uchar nod; /* number of devices present */
+ uchar noc; /* number of columns */
+ uchar cw; /* column width in bits */
+ uchar wedw; /* write/erase data width */
+} vpd_fmc_t;
+
+/* function prototypes */
+extern void vpd_init(void);
+extern int vpd_read(uint iic_device, uchar *buf, int count, int offset);
+extern vpd_packet_t *vpd_find_packet(u_char ident);
+
+#endif /* __vpd_h */
START = start.o kgdb.o
OBJS = traps.o serial.o cpu.o cpu_init.o speed.o \
- interrupts.o scc.o i2c.o video.o \
- wl_4ppm_keyboard.o
+ interrupts.o scc.o i2c.o video.o wlkbd.o
all: .depend $(START) $(LIB)
# MA 02111-1307 USA
#
+PLATFORM_RELFLAGS += -mrelocatable -ffixed-r14
+
+PLATFORM_CPPFLAGS += -DCONFIG_8xx -ffixed-r2 -mstring -mcpu=860 -msoft-float
}
/* ------------------------------------------------------------------------- */
+
+#if defined(CONFIG_WATCHDOG)
+void
+watchdog_reset(void)
+{
+ int re_enable = disable_interrupts();
+ reset_8xx_watchdog((immap_t *)CFG_IMMR);
+ if (re_enable) enable_interrupts();
+}
+#endif /* CONFIG_WATCHDOG */
+
+/* ------------------------------------------------------------------------- */
immr->im_siu_conf.sc_sypcr = CFG_SYPCR;
+#if defined(CONFIG_WATCHDOG)
+ reset_8xx_watchdog(immr);
+#endif /* CONFIG_WATCHDOG */
/* SIUMCR - contains debug pin configuration (11-6) */
memctl->memc_br0 = CFG_BR0_PRELIM; /* XXX ??? XXX ??? XXX */
#endif
+#if defined(CFG_OR0_REMAP)
memctl->memc_or0 = CFG_OR0_REMAP;
+#endif
+#if !defined(CONFIG_GENIETV) && defined(CFG_OR1_REMAP)
memctl->memc_or1 = CFG_OR1_REMAP;
+#endif
/* now restrict to preliminary range */
memctl->memc_br0 = CFG_BR0_PRELIM;
-
memctl->memc_or0 = CFG_OR0_PRELIM;
- memctl->memc_or1 = CFG_OR1_PRELIM;
+#ifndef CONFIG_GENIETV
+ memctl->memc_or1 = CFG_OR1_PRELIM;
memctl->memc_br1 = CFG_BR1_PRELIM;
+#endif
+
+#if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM)
+ memctl->memc_or2 = CFG_OR2_PRELIM;
+ memctl->memc_br2 = CFG_BR2_PRELIM;
+#endif
+
+#if defined(CFG_OR3_PRELIM) && defined(CFG_BR3_PRELIM)
+ memctl->memc_or3 = CFG_OR3_PRELIM;
+ memctl->memc_br3 = CFG_BR3_PRELIM;
+#endif
/*
* Reset CPM
/*
-** I2C interface
-** =============
-** (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
-** AIRVENT SAM s.p.a - RIMINI(ITALY)
-**
-*/
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
#include <ppcboot.h>
#include <commproc.h>
#include <i2c.h>
-#ifdef CONFIG_I2C
-
#define DEBUG_STEP 0
-#define PRINTD(x) if (DEBUG_STEP) printf(x);
+#define PRINTD(x) if (DEBUG_STEP) printf(x);
#define DELAY_US 100000 // us to wait before checking the I2c
#define I2C_PRAM 0
// input parameters (clock speed, filter, and predivider value).
// It returns computer speed value and the difference between it and desired
// speed.
-static inline int i2c_roundrate (int hz, int speed, int filter, int modval,
+static inline int i2c_roundrate (int hz, int speed, int filter, int modval,
int *brgval, int *totspeed)
{
int moddiv = 1 << (3-(modval & 3)),
div;
*brgval = hz / (2 * moddiv * speed) - 3 + 2*filter ;
-
+
if ((*brgval < 0) || (*brgval > 255))
return -1 ;
-
+
brgdiv = 2 * (*brgval + 3 + 2 * filter) ;
div = moddiv * brgdiv ;
*totspeed = hz / div ;
-
+
return 0;
}
bestspeed_filter=0,
totspeed,
filter;
-
+
for (filter = 0; filter < 2; filter++)
for (modval = 0; modval < 4; modval++)
- if (i2c_roundrate ( hz, speed,
- filter, modval,
+ if (i2c_roundrate ( hz, speed,
+ filter, modval,
&brgval, &totspeed) == 0)
{
int diff = speed - totspeed ;
-
+
if ((diff >= 0) && (diff < bestspeed_diff))
{
bestspeed_diff = diff ;
}
/* printf("Best is:\n");
- printf("\nCPU=%dhz RATE=%d F=%d I2MOD=%08x I2BRG=%08x DIFF=%dhz",
- hz, speed,
- bestspeed_filter, bestspeed_modval, bestspeed_brgval,
- bestspeed_diff);
-*/
- i2c->i2c_i2mod = ((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3);
+ printf("\nCPU=%dhz RATE=%d F=%d I2MOD=%08x I2BRG=%08x DIFF=%dhz",
+ hz, speed,
+ bestspeed_filter, bestspeed_modval, bestspeed_brgval,
+ bestspeed_diff);
+*/
+ i2c->i2c_i2mod = ((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3);
i2c->i2c_i2brg = bestspeed_brgval & 0xff;
return 1 ;
void i2c_init(int speed)
{
+ init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
immap_t *immap = (immap_t *)CFG_IMMR ;
volatile cpm8xx_t *cp;
char *dest;
#ifdef CONFIG_UCODE_PATCH
/* Check for and use a microcode relocation patch
- */
+ */
if (reloc = iip->iic_rpbase)
iip = (iic_t *)&cp->cp_dpmem[iip->iic_rpbase] ;
cp->cp_pbdir |= 0x00000030;
cp->cp_pbodr |= 0x00000030;
#endif
-
+
/* Disable interrupts.
*/
i2c->i2c_i2cmr = 0;
*/
iip->iic_rbase = (unsigned short) 0x2018;
iip->iic_tbase = (unsigned short) 0x2020;
-
+
cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_I2C, CPM_CR_INIT_TRX) | CPM_CR_FLG;
while (cp->cp_cpcr & CPM_CR_FLG);
- // Setup Buffer Descriptor and buffer memory. Skips space used by
+ // Setup Buffer Descriptor and buffer memory. Skips space used by
// uart.s buffer descriptors and buffers. (0x2000 to 0x2017)
- // Each buffer descriptor takes up 8 bytes
+ // Each buffer descriptor takes up 8 bytes
rxbd = ( I2C_BD *) ((unsigned char *)immap + 0x2018);
txbd = ( I2C_BD *) ((unsigned char *)immap + 0x2020);
PRINTD("\n[I2C ] Clearing the buffer memory...");
- // Clear the buffer memory
+ // Clear the buffer memory
dest = rxbuf;
for( count = 0; count < I2C_RX_LEN; count++ )
*dest++ = 0;
-
+
dest = txbuf;
for( count = 0; count < I2C_TX_LEN; count++ )
*dest++ = 0;
-
+
dest = txbuf2;
for( count = 0; count < I2C_TX_LEN; count++ )
*dest++ = 0;
-
+
PRINTD("\n[I2C ] Initializing BD's...");
- // Initialize the BD's
-
- // Rx: Wrap, no interrupt, empty
+ // Initialize the BD's
+
+ // Rx: Wrap, no interrupt, empty
rxbd->length = 0;
rxbd->addr = rxbuf;
rxbd->status = 0xa000;
- // Tx: Wrap, no interrupt, not ready to send, last
+ // Tx: Wrap, no interrupt, not ready to send, last
txbd->length = 0;
txbd->addr = txbuf;
txbd->status = 0x2800;
-
+
txbd2->length = 0;
txbd2->addr = txbuf2;
txbd2->status = 0x2c00;
// Set the I2C BRG Clock division factor from desired i2c rate
- // and current CPU rate (we assume sccr dfbgr field is 0;
+ // and current CPU rate (we assume sccr dfbgr field is 0;
// divide BRGCLK by 1)
PRINTD("\n[I2C ] Setting rate...");
- i2c_setrate (MPC8XX_HZ, speed) ;
-
+ i2c_setrate (idata->cpu_speed, speed) ;
+
}
void i2c_send( unsigned char address,
int i,j;
if( size > I2C_TX_LEN ) /* Trying to send message larger than BD */
- return;
+ return;
/* Enable I2C */
PRINTD("\n[I2C ] Enabling I2C...");
- i2c->i2c_i2mod |= 1;
+ i2c->i2c_i2mod |= 1;
/* WE ONLY HAVE TO SEND ONCE
-
+
PRINTD("\n[I2C ] Waiting for transmit buffer empty...");
while( txbd->status & TXBD_R )
{
- }; // Loop until previous data sent
+ }; // Loop until previous data sent
*/
- PRINTD("\n[I2C ] Formatting addresses...");
+ PRINTD("\n[I2C ] Formatting addresses...");
if( enable_secondary ) /* Device has an internal address */
{
txbd->length = size + 2; /* Length of message plus dest addresses */
}
/* Copy data to send into buffer */
- PRINTD("\n[I2C ] Copying data into buffer...");
+ PRINTD("\n[I2C ] Copying data into buffer...");
for( j = 0; j < size; i++, j++ )
txbd->addr[ i ] = dataout[j];
-
- /* Ready to Transmit, wrap, last */
-
- PRINTD("\n[I2C ] Waiting to transmit...");
-
+
+ /* Ready to Transmit, wrap, last */
+
+ PRINTD("\n[I2C ] Waiting to transmit...");
+
txbd->status = txbd->status | TXBD_R | TXBD_W | TXBD_L;
-
+
/* Transmit */
- PRINTD("\n[I2C ] Transmitting...");
+ PRINTD("\n[I2C ] Transmitting...");
i2c->i2c_i2com |= 0x80;
PRINTD("\n[I2C ] Waiting for transmit buffer empty...");
udelay (DELAY_US) ;
-
+
while( txbd->status & TXBD_R );
-
+
/* Turn off I2C */
PRINTD("\n[I2C ] Turning off I2C...");
i2c->i2c_i2mod &= (~1);
void i2c_receive(unsigned char address,
unsigned char secondary_address,
- int enable_secondary,
+ int enable_secondary,
unsigned short size_to_expect, unsigned char datain[] )
{
int i, j;
-
+
// if( size_to_expect > I2C_RX_LEN )
// abort(); /* Expected to receive too much */
-
+
/* Turn on I2C */
i2c->i2c_i2mod |= 0x01;
-
- /* Setup TXBD for destination address */
+
+ /* Setup TXBD for destination address */
if( enable_secondary )
{
- txbd->length = 2;
+ txbd->length = 2;
txbd->addr[0] = address | 0x00; /* Write data */
txbd->addr[1] = secondary_address; /* Internal address */
txbd->status = TXBD_R;
-
+
/* Buffer ready to transmit, */
txbd2->status = TXBD_R | TXBD_W | TXBD_L | TXBD_S;
txbd2->length = size_to_expect + 1;
/* Reset the rxbd */
rxbd->status = RXBD_E | RXBD_W;
-
+
/* Begin transmission */
i2c->i2c_i2com |= 0x80;
-
- }
+
+ }
else
{
txbd->length = 1 + size_to_expect;
txbd->addr[0] = address | 0x01;
-
-
+
+
/* Buffer ready to transmit, wrap, loop */
txbd->status |= TXBD_R | TXBD_W | TXBD_L;
/* Reset the rxbd */
rxbd->status = RXBD_E | RXBD_W;
-
+
/* Begin transmission */
i2c->i2c_i2com |= 0x80;
-
+
while( txbd->status & TXBD_R); /* Loop until transmit completed */
}
-
+
while( rxbd->status & RXBD_E); /* Wait until receive is finished */
-
+
for( i= 0, j = 0; j < size_to_expect; j++, i++ ) /* Copy data to datain[] */
datain[j] = rxbd->addr[i];
-
+
/* Turn off I2C */
i2c->i2c_i2mod &= (~1);
}
-
-#endif /* CONFIG_I2C */
set_dec (decrementer_count);
timestamp++;
+
+#if defined(CONFIG_WATCHDOG)
+ if ((timestamp % 1000) == 0)
+ reset_8xx_watchdog(immr);
+#endif /* CONFIG_WATCHDOG */
}
/****************************************************************************/
SYNC
blr
- CACHE_LINE_SIZE = 16
- LG_CACHE_LINE_SIZE = 4
-
.globl kgdb_flush_cache_range
kgdb_flush_cache_range:
- li r5,CACHE_LINE_SIZE-1
+ li r5,CFG_CACHELINE_SIZE-1
andc r3,r3,r5
subf r4,r3,r4
add r4,r4,r5
- srwi. r4,r4,LG_CACHE_LINE_SIZE
+ srwi. r4,r4,CFG_CACHELINE_SHIFT
beqlr
mtctr r4
mr r6,r3
1: dcbst 0,r3
- addi r3,r3,CACHE_LINE_SIZE
+ addi r3,r3,CFG_CACHELINE_SIZE
bdnz 1b
sync /* wait for dcbst's to get to ram */
mtctr r4
2: icbi 0,r6
- addi r6,r6,CACHE_LINE_SIZE
+ addi r6,r6,CFG_CACHELINE_SIZE
bdnz 2b
SYNC
blr
cp->cp_pbpar |= 0x00000c00;
cp->cp_pbdir &= ~0x00000c00;
cp->cp_pbodr &= ~0x00000c00;
-# endif
+# endif
#endif
#if defined(CONFIG_FADS)
}
void
-serial_putstr (const char *s)
+serial_puts (const char *s)
{
while (*s) {
serial_putc (*s++);
kgdb_serial_init(void)
{
#ifdef CONFIG_8xx_CONS_SMC1
- printf("[on SMC1] ");
+ serial_printf("[on SMC1] ");
#endif
#ifdef CONFIG_8xx_CONS_SMC2
- printf("[on SMC2] ");
+ serial_printf("[on SMC2] ");
#endif
}
void
putDebugStr (const char *str)
{
- serial_putstr (str);
+ serial_puts (str);
}
int
* Calculate absolute address in FLASH and jump there
*----------------------------------------------------------------------*/
- lis r3, CFG_FLASH_BASE@h
- ori r3, r3, CFG_FLASH_BASE@l
+ lis r3, CFG_MONITOR_BASE@h
+ ori r3, r3, CFG_MONITOR_BASE@l
addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
mtlr r3
blr
mr r10, r5 /* Save copy of Destination Address */
mr r3, r5 /* Destination Address */
- lis r4, CFG_FLASH_BASE@h /* Source Address */
- ori r4, r4, CFG_FLASH_BASE@l
+ lis r4, CFG_MONITOR_BASE@h /* Source Address */
+ ori r4, r4, CFG_MONITOR_BASE@l
lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
ori r5, r5, CFG_MONITOR_LEN@l
li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
/*
* Fix GOT pointer:
*
- * New GOT-PTR = (old GOT-PTR - CFG_FLASH_BASE) + Destination Address
+ * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
*
* Offset:
*/
/*
-** MPC823 Video Controller
-** =======================
-** (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
-** AIRVENT SAM s.p.a - RIMINI(ITALY)
-**
-*/
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
// ***********************************************************************
// ** HEADER FILES
#include <config.h>
#include <version.h>
#include <i2c.h>
-#include <video.h>
#include <linux/types.h>
+#include <devices.h>
-#ifdef CONFIG_VIDEO
+#ifdef CONFIG_VIDEO
// ***********************************************************************
// ** DEBUG SETTINGS
//#define VIDEO_BLINK // This enables cursor blinking (under construction)
#define VIDEO_INFO // Show PPCBOOT informations
#define VIDEO_INFO_X VIDEO_LOGO_WIDTH+8
-#define VIDEO_INFO_Y 8
+#define VIDEO_INFO_Y 16
// ***********************************************************************
// ** VIDEO ENCODER CONSTANTS
#include <video_ad7176.h> // Sets encoder data, mode, and visible and active area
#define VIDEO_I2C 1
-#define VIDEO_I2C_RATE 75000 // Max I2C rate is 100Khz - Too high!
+#define VIDEO_I2C_RATE (VIDEO_ENCODER_I2C_RATE >> 1)
#define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7176_ADDR
#define VIDEO_I2C_DATA_ADDR video_encoder_data
#define VIDEO_I2C_DATA_SIZE sizeof(video_encoder_data)
#endif
+#ifdef CONFIG_VIDEO_ENCODER_AD7177
+
+#include <video_ad7177.h> // Sets encoder data, mode, and visible and active area
+
+#define VIDEO_I2C 1
+#define VIDEO_I2C_RATE (VIDEO_ENCODER_I2C_RATE >> 1)
+#define VIDEO_I2C_ADDR CONFIG_VIDEO_ENCODER_AD7177_ADDR
+#define VIDEO_I2C_DATA_ADDR video_encoder_data
+#define VIDEO_I2C_DATA_SIZE sizeof(video_encoder_data)
+#endif
+
+// ***********************************************************************
+// ** VIDEO MODE CONSTANTS
+// ***********************************************************************
+
#ifdef VIDEO_MODE_EXTENDED
#define VIDEO_COLS VIDEO_ACTIVE_COLS
#define VIDEO_ROWS VIDEO_ACTIVE_ROWS
#define VIDEO_ROWS VIDEO_VISIBLE_ROWS
#endif
-// ***********************************************************************
-// ** VIDEO MODE CONSTANTS
-// ***********************************************************************
-
-#define VIDEO_PIXEL_SIZE (VIDEO_MODE_BPP/8)
-#define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)// Total size of buffer
+#define VIDEO_PIXEL_SIZE (VIDEO_MODE_BPP/8)
+#define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)// Total size of buffer
#define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) // Number of ints
#define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) // Number of bytes per line
#define VIDEO_BURST_LEN (VIDEO_COLS/8)
Y1,
U,
Y2;
-} tYUYV ;
+} tYUYV ;
/* This structure is based on the Video Ram in the MPC823. */
typedef struct VRAM
// ** VARIABLES
// ***********************************************************************
-static int
+static int
video_panning_range_x = 0, // Video mode invisible pixels x range
video_panning_range_y = 0, // Video mode invisible pixels y range
video_panning_value_x = 0, // Video mode x panning value (absolute)
video_panning_value_y = 0, // Video mode y panning value (absolute)
video_panning_factor_x = 0, // Video mode x panning value (-127 +127)
video_panning_factor_y = 0, // Video mode y panning value (-127 +127)
-
+
console_col = 0, // Cursor col
console_row = 0, // Cursor row
-
+
video_palette[16]; // Our palette
-
+
static const int
video_font_draw_table[] = {0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff} ;
-static char
+static char
video_color_fg = 0, // Current fg color index (0-15)
video_color_bg = 0, // Current bg color index (0-15)
-
+
video_enable = 0 ; // Video has been initialized?
-static void
+static void
*video_fb_address, // Frame buffer address
*video_console_address ; // Console frame buffer start address
}
// ***********************************************************************
-// ** VIDEO DRAWING AND COLOR FUNCTIONS
+// ** VIDEO DRAWING AND COLOR FUNCTIONS
// ***********************************************************************
static int video_maprgb (int r, int g, int b)
{
+#ifdef VIDEO_MODE_YUYV
unsigned int pR, pG, pB ;
tYUYV YUYV ;
unsigned int *ret = (unsigned int*) &YUYV ;
-
+
// Transform (0-255) components to (0-100)
pR = r * 100 / 255 ;
pG = g * 100 / 255 ;
pB = b * 100 / 255 ;
-
+
// Calculate YUV values (0-255) from RGB beetween 0-100
- YUYV.Y1 = YUYV.Y2 = 209 * (pR + pG + pB) / 300 + 16 ;
- YUYV.U = pR - (pG*3/4) - (pB/4) + 128 ;
- YUYV.V = pB - (pR/4) - (pG*3/4) + 128 ;
-
+ YUYV.Y1 = YUYV.Y2 = 209 * (pR + pG + pB) / 300 + 16 ;
+ YUYV.U = pR - (pG*3/4) - (pB/4) + 128 ;
+ YUYV.V = pB - (pR/4) - (pG*3/4) + 128 ;
return *ret ;
-}
+#endif
+#ifdef VIDEO_MODE_RGB
+ return ((r >> 3) << 11) | ((g > 2) << 6) | (b >> 3) ;
+#endif
+}
static void video_setpalette (int color, int r, int g, int b)
{
color &= 0xf ;
-
+
video_palette[color] = video_maprgb(r,g,b);
-
+
// Swap values if our panning offset is odd
if (video_panning_value_x & 1)
video_palette[color] = SWAPINT (video_palette[color]);
int rows;
u8 *dest ;
dest = video_fb_address + yy * VIDEO_LINE_LEN + xx * 2;
-
+
for (rows = VIDEO_FONT_HEIGHT; rows--; dest += VIDEO_LINE_LEN) {
switch (VIDEO_FONT_WIDTH) {
case 16:
fgx = video_pickcolor (video_color_fg) ;
bgx = video_pickcolor (video_color_bg) ;
-
- if (xx & 1)
+
+ if (xx & 1)
{
fgx = SWAPINT(fgx);
bgx = SWAPINT(bgx);
}
-
+
eorx = fgx ^ bgx;
switch (VIDEO_FONT_WIDTH) {
static void video_mode_dupefield(VRAM *source, VRAM *dest, int entries)
{
int i ;
-
+
for(i=0; i<entries; i++)
{
dest[i] = source[i] ; // Copy the entire record
dest[i].fx = (!dest[i].fx)*3 ; // Negate field bit
}
-
+
dest[0].lcyc++ ; // Add a cycle to the first entry
dest[entries-1].lst = 1 ; // Set end of ram entries
}
-static void video_mode_addentry(VRAM *vr,
+static void inline video_mode_addentry(VRAM *vr,
int Hx,
int Vx,
int Fx,
video_panning_value_x = (video_panning_factor_x + 128) * DX / 256;
video_panning_value_y = (video_panning_factor_y + 128) * DY / 256;
-
+
// We assume these are burst units (multiplied by 2, we need it pari)
X1 = video_panning_value_x & 0xfffe;
X2 = DX - X1;
Y2 = DY - Y1;
#ifdef VIDEO_MODE_NTSC
-#error "Not yet supported!"
+// Hx Vx Fx Bx VDS INT LCYC LP LST
+//
+// Retrace blanking
+//
+ ADDENTRY( 0, 0, 3, 0, 1, 0, 3, 1, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 243, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0,1440, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
+//
+// Vertical blanking
+//
+ ADDENTRY( 0, 0, 0, 0, 1, 0, 18, 1, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 243, 0, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
+//
+// Odd field active area (TOP)
+//
+ if (Y1 > 0)
+ {
+ ADDENTRY( 0, 0, 0, 0, 1, 0, Y1, 1, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 235, 0, 0 );
+ ADDENTRY( 3, 0, 0, 3, 1, 0,1448, 0, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
+ }
+//
+// Odd field active area
+//
+ ADDENTRY( 0, 0, 0, 0, 1, 0, 240 - DY, 1, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 235, 0, 0 );
+ ADDENTRY( 3, 0, 0, 3, 1, 0, 8+X1, 0, 0 );
+ ADDENTRY( 3, 0, 0, 3, 0, 0,VIDEO_COLS * 2, 0, 0 );
+
+ if (X2 > 0)
+ ADDENTRY( 3, 0, 0, 3, 1, 0, X2, 0, 0 );
+
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
+
+//
+// Odd field active area (BOTTOM)
+//
+ if (Y1 > 0)
+ {
+ ADDENTRY( 0, 0, 0, 0, 1, 0, Y2, 1, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 235, 0, 0 );
+ ADDENTRY( 3, 0, 0, 3, 1, 0,1448, 0, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
+ }
+//
+// Vertical blanking
+//
+ ADDENTRY( 0, 0, 0, 0, 1, 0, 4, 1, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 243, 0, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
+ ADDENTRY( 3, 0, 0, 0, 1, 0, 32, 1, 0 );
+//
+// Vertical blanking
+//
+ ADDENTRY( 0, 0, 3, 0, 1, 0, 19, 1, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 243, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0,1440, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
+//
+// Even field active area (TOP)
+//
+ if (Y1 > 0)
+ {
+ ADDENTRY( 0, 0, 3, 0, 1, 0, Y1, 1, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 235, 0, 0 );
+ ADDENTRY( 3, 0, 3, 3, 1, 0,1448, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
+ }
+//
+// Even field active area (CENTER)
+//
+ ADDENTRY( 0, 0, 3, 0, 1, 0, 240 - DY, 1, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 235, 0, 0 );
+ ADDENTRY( 3, 0, 3, 3, 1, 0, 8+X1, 0, 0 );
+ ADDENTRY( 3, 0, 3, 3, 0, 0,VIDEO_COLS * 2, 0, 0 );
+
+ if (X2 > 0)
+ ADDENTRY( 3, 0, 3, 3, 1, 0, X2, 0, 0 );
+
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
+//
+// Even field active area (BOTTOM)
+//
+ if (Y1 > 0)
+ {
+ ADDENTRY( 0, 0, 3, 0, 1, 0, Y2, 1, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 235, 0, 0 );
+ ADDENTRY( 3, 0, 3, 3, 1, 0,1448, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 32, 1, 0 );
+ }
+//
+// Vertical blanking
+//
+ ADDENTRY( 0, 0, 3, 0, 1, 0, 1, 1, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0, 243, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 0,1440, 0, 0 );
+ ADDENTRY( 3, 0, 3, 0, 1, 1, 32, 1, 1 );
#endif
#ifdef VIDEO_MODE_PAL
-// Hx Vx Fx Bx VDS INT LCYC LP LST
+// Hx Vx Fx Bx VDS INT LCYC LP LST
//
// vertical; blanking
//
- ADDENTRY( 0, 0, 0, 0, 1, 0, 22, 1, 0 );
+ ADDENTRY( 0, 0, 0, 0, 1, 0, 22, 1, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 263, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0,1440, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
//
ADDENTRY( 0, 0, 0, 0, 1, 0, 288-DY, 1, 0 ); // 265?
ADDENTRY( 3, 0, 0, 0, 1, 0, 255, 0, 0 );
- ADDENTRY( 3, 0, 0, 3, 1, 0, 8 + X1, 0, 0 );
- ADDENTRY( 3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0 );
+ ADDENTRY( 3, 0, 0, 3, 1, 0, 8 + X1, 0, 0 );
+ ADDENTRY( 3, 0, 0, 3, 0, 0, VIDEO_COLS * 2, 0, 0 );
if (X2 > 0)
ADDENTRY( 3, 0, 0, 1, 1, 0, X2, 0, 0 );
ADDENTRY( 3, 0, 0, 0, 1, 0, 24, 1, 0 );
//
// Create the other field (like this, but whit other field selected,
-// one more cycle loop and a last identifier)
+// one more cycle loop and a last identifier)
//
video_mode_dupefield (vr, &vr[entry], entry);
#endif
// See what FIFO are we using
- fifo = GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS);
-
+ fifo = GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS);
+
// Set number of lines and burst (only one frame for now)
if (fifo)
- immap->im_vid.vid_vfcr0 = VIDEO_BURST_LEN |
- (VIDEO_BURST_LEN << 8) |
+ immap->im_vid.vid_vfcr0 = VIDEO_BURST_LEN |
+ (VIDEO_BURST_LEN << 8) |
((VIDEO_ROWS / 2) << 19) ;
else
- immap->im_vid.vid_vfcr1 = VIDEO_BURST_LEN |
- (VIDEO_BURST_LEN << 8) |
+ immap->im_vid.vid_vfcr1 = VIDEO_BURST_LEN |
+ (VIDEO_BURST_LEN << 8) |
((VIDEO_ROWS / 2) << 19) ;
-
- SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_ASEL, !fifo);
+
+ SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_ASEL, !fifo);
// Wait until changes are applied (not done)
// while (GETBIT(immap->im_vid.vid_vsr, VIDEO_VSR_CAS) == fifo) ;
i2c_init (VIDEO_I2C_RATE);
#ifdef CONFIG_FADS
- // Reset ADV7176 chip
+ // Reset ADV7176 chip
PRINTD("\n[VIDEO ENCODER] Resetting encoder...");
(*(int *)BCSR4) &= ~(1 << 21);
-
+
// Wait for 5 ms inside the reset
PRINTD("\n[VIDEO ENCODER] Waiting for encoder reset...");
udelay(5000);
- // Take ADV7176 out of reset
- (*(int *)BCSR4) |= 1 << 21;
+ // Take ADV7176 out of reset
+ (*(int *)BCSR4) |= 1 << 21;
// Wait for 5 ms after the reset
udelay(5000);
// Send configuration
PRINTD("\n[VIDEO ENCODER] Configuring the encoder...");
#if (VIDEO_DEBUG_STEP == 1)
- printf("Sending %d bytes (%08x) to I2C 0x%x\n",
+ printf("Sending %d bytes (%08x) to I2C 0x%x\n",
VIDEO_I2C_DATA_SIZE, VIDEO_I2C_DATA_ADDR, VIDEO_I2C_ADDR);
#endif
- i2c_send(VIDEO_I2C_ADDR, 0, 1, \rVIDEO_I2C_DATA_SIZE, VIDEO_I2C_DATA_ADDR);\r
+ i2c_send(VIDEO_I2C_ADDR, 0, 1, VIDEO_I2C_DATA_SIZE, VIDEO_I2C_DATA_ADDR);
#endif
return ;
}
// Set black background
PRINTD("\n[VIDEO CTRL] Setting background color...");
- immap->im_vid.vid_vbcb = VIDEO_BG_COL;
+ immap->im_vid.vid_vbcb = VIDEO_BG_COL;
// Show the background
PRINTD("\n[VIDEO CTRL] Forcing background...");
- SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 1);
+ SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 1);
// Turn off video controller
PRINTD("\n[VIDEO CTRL] Turning off video controller...");
SETBIT(immap->im_vid.vid_vccr, VIDEO_VCCR_VON, 0) ;
#ifdef CONFIG_FADS
- // Turn on Video Port LED
+ // Turn on Video Port LED
PRINTD("\n[VIDEO CTRL] Turning off video port led...");
SETBIT(*(int *)BCSR4, VIDEO_BCSR4_VIDLED_BIT, 1);
// Generate and make active a new video mode
PRINTD("\n[VIDEO CTRL] Generating video mode...");
video_mode_generate ();
-
+
// Start of frame buffer (even and odd frame, to make it working with
// any selected active set)
PRINTD("\n[VIDEO CTRL] Setting frame address...");
- immap->im_vid.vid_vfaa1 =
+ immap->im_vid.vid_vfaa1 =
immap->im_vid.vid_vfaa0 = (u32) video_fb_address ;
- immap->im_vid.vid_vfba1 =
+ immap->im_vid.vid_vfba1 =
immap->im_vid.vid_vfba0 = (u32) video_fb_address + VIDEO_LINE_LEN ;
- // YUV, Big endian, SHIFT/CLK/CLK input (BEFORE ENABLING 27MHZ EXT CLOCK)
+ // YUV, Big endian, SHIFT/CLK/CLK input (BEFORE ENABLING 27MHZ EXT CLOCK)
PRINTD("\n[VIDEO CTRL] Setting pixel mode and clocks...");
- immap->im_vid.vid_vccr = 0x2042;
-
+ immap->im_vid.vid_vccr = 0x2042;
+
// Configure port pins
PRINTD("\n[VIDEO CTRL] Configuring input/ouput pins...");
immap->im_ioport.iop_pdpar = 0x1fff;
immap->im_ioport.iop_pddir = 0x0000;
-
+
#ifdef CONFIG_FADS
// Turn on Video Port Clock - ONLY AFTER SET VCCR TO ENABLE EXTERNAL CLOCK
PRINTD("\n[VIDEO CTRL] Turning on video clock...");
SETBIT(*(int *)BCSR4, VIDEO_BCSR4_EXTCLK_BIT, 1);
- // Turn on Video Port LED
+ // Turn on Video Port LED
PRINTD("\n[VIDEO CTRL] Turning on video port led...");
SETBIT(*(int *)BCSR4, VIDEO_BCSR4_VIDLED_BIT, 0);
#endif
- // Blanking the screen.
+ // Blanking the screen.
PRINTD("\n[VIDEO CTRL] Blanking the screen...");
video_fill(VIDEO_BG_COL);
// the screen to flicker when the caches try to fill. This gives the
// FIFO's for the Video Controller higher priority and prevents flickering
// because of underrun. This may still be an issue when using FLASH, since
- // accessing data from Flash is so slow.
+ // accessing data from Flash is so slow.
PRINTD("\n[VIDEO CTRL] Turning on aggressive mode...");
immap->im_siu_conf.sc_sdcr = 0x40;
// Show the display
PRINTD("\n[VIDEO CTRL] Enabling the video...");
- SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 0);
+ SETBIT(immap->im_vid.vid_vcmr, VIDEO_VCMR_BD, 0);
}
// ***********************************************************************
-// ** CONSOLE FUNCTIONS
+// ** CONSOLE FUNCTIONS
// ***********************************************************************
static void console_scrollup(void)
static inline void console_back (void)
{
console_col -- ;
-
+
if (console_col < 0)
{
console_col = CONSOLE_COLS-1 ;
if (console_row < 0)
console_row = 0;
}
-
+
video_putchar (console_col * VIDEO_FONT_WIDTH, console_row * VIDEO_FONT_HEIGHT, ' ');
}
{
// Scroll everything up
console_scrollup () ;
-
+
// Decrement row number
console_row -- ;
}
serial_putc(c);
return ;
}
-
+
switch (c){
case 13: // Simply ignore this
break;
-
+
case '\n': // Next line, please
console_newline();
break;
+
+ case 9: // Tab (8 chars alignment)
+ console_col |= 0x0008 ; // Next 8 chars boundary
+ console_col &= ~0x0007 ; // Set this bit to zero
+
+ if (console_col >= CONSOLE_COLS)
+ console_newline();
+ break;
case 8: // Eat last character
console_back();
break;
-
+
default: // Add to the console
- video_putchar (console_col * VIDEO_FONT_WIDTH,
+ video_putchar (console_col * VIDEO_FONT_WIDTH,
console_row * VIDEO_FONT_HEIGHT, c);
- console_col++ ;
+ console_col++ ;
// Check if we need to go to next row
- if (console_col >= CONSOLE_COLS)
+ if (console_col >= CONSOLE_COLS)
console_newline();
}
}
-void video_putstr (const char *s)
+void video_puts (const char *s)
{
int count = strlen(s);
video_putc(*s++);
}
-void video_printf(const char *fmt, ...)
-{
- extern int vsprintf(char *buf, const char *fmt, va_list args);
- va_list args;
- uint i;
- char printbuffer[CFG_PBSIZE]; // damm, wd
-
- va_start(args, fmt);
-
- /* For this to work, printbuffer must be larger than
- * anything we ever want to print.
- */
- i = vsprintf(printbuffer, fmt, args);
- va_end(args);
-
- if (!video_enable)
- serial_putstr(printbuffer);
- else
- video_putstr(printbuffer);
-}
-
// ***********************************************************************
// ** CURSOR BLINKING FUNCTIONS
// ***********************************************************************
{
// Check if we need to reverse last character
if (blink_old)
- video_revchar (blink_col * VIDEO_FONT_WIDTH,
- (blink_row
+ video_revchar (blink_col * VIDEO_FONT_WIDTH,
+ (blink_row
#ifdef CONFIG_VIDEO_LOGO
- + VIDEO_LOGO_HEIGHT
+ + VIDEO_LOGO_HEIGHT
#endif
)* VIDEO_FONT_HEIGHT);
/*
* Handler for blinking cursor
*/
-static void blink_handler (void *arg)\r
+static void blink_handler (void *arg)
{
// Blink
blink_update();
timer_enable (&blink_timer);
else
timer_disable (&blink_timer);
-
+
blink_enabled = blink ;
-
+
return ret ;
}
// ***********************************************************************
#ifdef CONFIG_VIDEO_LOGO
-
-#ifdef VIDEO_MODE_YUYV
void easylogo_plot (fastimage_t *image, void *screen, int width, int x, int y)
{
- int skip = width - image->width,
+ int skip = width - image->width,
xcount,
ycount = image->height;
-
- unsigned short
- val,
+
+#ifdef VIDEO_MODE_YUYV
+ unsigned short
*source = (unsigned short *) image->data,
*dest = (unsigned short *) screen + y * width + x;
-#ifdef ENABLE_ASCII_BANNERS
- printf("Image size is W=%d H=%d - ",image->width, image->height);
- printf("Dest is X=%d Y=%d at 0x%08x\n",
- x,
- y,
- screen);
-#endif
while (ycount--)
{
xcount = image->width ;
while (xcount--)
- {
-#if defined(powerpc)
- val = *source;
-#else
- val = SWAPSHORT(*source); // Because of i386 inverts data!
-#ifdef ENABLE_ASCII_BANNERS
- if (val != 0x8010)
- printf("X");
- else
- printf(" ");
-#endif
+ *dest++ = *source++;
+ dest += skip ;
+ }
#endif
+#ifdef VIDEO_MODE_RGB
+ unsigned char
+ *source = (unsigned short *) image->data,
+ *dest = (unsigned short *) screen + ((y * width) + x)*3;
- *dest = val ;
-
- source++ ;
- dest++ ;
- }
-#ifdef ENABLE_ASCII_BANNERS
- printf("\n");
-#endif
- dest += skip ;
+ while (ycount--)
+ {
+ xcount = image->width * 3 ;
+ memcpy(dest, source, xcount);
+ source += xcount ;
+ dest += ycount ;
}
-}
#endif
+}
static void *video_logo (void)
{
easylogo_plot (VIDEO_LOGO_ADDR, screen, width, 0, 0);
#ifdef VIDEO_INFO
- video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, PPCBOOT_VERSION);
-#ifdef CONFIG_FADS
+ sprintf(info, "%s (%s - %s) ",PPCBOOT_VERSION,__DATE__,__TIME__);
+ video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, info);
+#ifdef CONFIG_FADS
sprintf(info, "MPC823 CPU at 50 Mhz on FADS823 board");
video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y + VIDEO_FONT_HEIGHT, info);
return video_fb_address + VIDEO_LOGO_HEIGHT * VIDEO_LINE_LEN ;
}
#endif
-
+
// ***********************************************************************
// ** VIDEO HIGH-LEVEL FUNCTIONS
// ***********************************************************************
-int video_init(void *videobase)
+static int video_init(void *videobase)
{
// Initialize the encoder
PRINTD("\n[VIDEO] Initializing video encoder...");
video_encoder_init();
-
+
// Initialize the video controller
#if VIDEO_DEBUG_STEP == 1
printf("\n[VIDEO] Initializing video controller at %08x...", (int)videobase);
console_row = 0;
video_enable = 1 ;
+/*
// Showing some information
- printf("%s %dx%dx%d (%s) at %08x (%d bytes) - console %dx%d\n",
+ printf("%s %dx%dx%d (%s) on %s - console %dx%d\n",
#ifdef VIDEO_MODE_PAL
"PAL",
#endif
#ifdef VIDEO_MODE_NTSC
"NTSC",
#endif
- VIDEO_COLS, VIDEO_ROWS, VIDEO_MODE_BPP,
+ VIDEO_COLS, VIDEO_ROWS, VIDEO_MODE_BPP,
#ifdef VIDEO_MODE_YUYV
"YCbYCr",
#endif
#ifdef VIDEO_MODE_RGB
"RGB",
#endif
- video_fb_address,
- VIDEO_SIZE,
+ VIDEO_ENCODER_NAME,
CONSOLE_COLS,
CONSOLE_ROWS
);
+*/
return 0 ;
}
-#endif /* CONFIG_VIDEO */
+int drv_video_init (void)
+{
+ int error, devices = 1 ;
+
+ device_t videodev ;
+
+ video_init((void *)CONFIG_VIDEO_ADDR); // Video initialization
+
+// Device initialization
+
+ memset (&videodev, 0, sizeof(videodev));
+
+ strcpy(videodev.name, "video");
+ videodev.ext = DEV_EXT_VIDEO ; // Video extensions
+ videodev.flags = DEV_FLAGS_OUTPUT; // Output only
+ videodev.putc = video_putc ; // 'putc' function
+ videodev.puts = video_puts ; // 'puts' function
+
+ error = device_register (&videodev);
+
+ return (error == 0) ? devices : error ;
+}
+
+#endif
--- /dev/null
+/*
+ * (C) Copyright 2000
+ * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <ppcboot.h>
+#include <config.h>
+
+int drv_wlkbd_init(void)
+{
+ return 0 ;
+}
#CFLAGS += -DET_DEBUG -DDEBUG
-DIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
-NAME = $(shell basename $(DIR))
-LIB = lib$(NAME).a
+LIB = libnet.a
OBJS = net.o tftp.o bootp.o rarp.o
all: $(LIB)
/*
- * LiMon - BOOTP.
+ * Based on LiMon - BOOTP.
*
* Copyright 1994, 1995, 2000 Neil Russell.
* (See License)
+ * Copyright 2000 Roland Borde
+ * Copyright 2000 Paolo Scaffardi
*/
+/* #define DEBUG_BOOTP_EXT 1 / * Debug received vendor fields */
+
#include <ppcboot.h>
#include <command.h>
#include "net.h"
#include "bootp.h"
#include "tftp.h"
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
+#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
-#define TIMEOUT 5 /* Seconds before trying BOOTP again */
+#if (CONFIG_COMMANDS & CFG_CMD_NET)
-#define PORT_BOOTPS 67 /* BOOTP server UDP port */
-#define PORT_BOOTPC 68 /* BOOTP client UDP port */
+#define TIMEOUT 5 /* Seconds before trying BOOTP again */
+#define PORT_BOOTPS 67 /* BOOTP server UDP port */
+#define PORT_BOOTPC 68 /* BOOTP client UDP port */
ulong BootpID;
char BootFile[128];
int BootpTry;
static ulong lAddr;
+void BootpVendorFieldProcess(u8 *ext)
+{
+ int size = *(ext+1) ;
+
+#ifdef DEBUG_BOOTP_EXT
+ printf("[BOOTP] Processing extension %d... (%d bytes)\n", *ext, *(ext+1));
+#endif
+
+ switch (*ext) {
+ /* Fixed length fields */
+ case 1: /* Subnet mask */
+ if (NetOurSubnetMask == 0)
+ memcpy(&NetOurSubnetMask, ext+2, 4);
+ break;
+ case 2: /* Time offset - Not yet supported */
+ break;
+ /* Variable length fields */
+ case 3: /* Gateways list */
+ if (NetOurGatewaysNum == 0) {
+ memcpy(&NetOurGatewaysIP, ext+2, size);
+ NetOurGatewaysNum = size >> 2 ;
+ }
+ break;
+ case 4: /* Time server - Not yet supported */
+ break;
+ case 5: /* IEN-116 name server - Not yet supported */
+ break;
+ case 6: /* Domain name server - Not yet supported */
+ break;
+ case 7: /* Log server - Not yet supported */
+ break;
+ case 8: /* Cookie/Quote server - Not yet supported */
+ break;
+ case 9: /* LPR server - Not yet supported */
+ break;
+ case 10: /* Impress server - Not yet supported */
+ break;
+ case 11: /* RPL server - Not yet supported */
+ break;
+ case 12: /* Host name */
+ if (NetOurHostName[0] == 0) {
+ memcpy(&NetOurHostName, ext+2, size);
+ NetOurHostName[size] = 0 ;
+ }
+ break;
+ case 13: /* Boot file size */
+ if (NetBootFileSize == 0)
+ memcpy(&NetBootFileSize, ext+2, size);
+ break;
+ case 14: /* Merit dump file - Not yet supported */
+ break;
+ case 15: /* Domain name - Not yet supported */
+ break;
+ case 16: /* Swap server - Not yet supported */
+ break;
+ case 17: /* Root path */
+ if (NetOurRootPath[0] == 0) {
+ memcpy(&NetOurRootPath, ext+2, size);
+ NetOurRootPath[size] = 0 ;
+ }
+ break;
+ case 18: /* Extension path - Not yet supported */
+ /*
+ * This can be used to send the informations of the
+ * vendor area in another file that the client can
+ * access via TFTP.
+ */
+ break;
+ /* IP host layer fields */
+ case 40: /* NIS Domain name */
+ if (NetOurNISDomain[0] == 0) {
+ memcpy(&NetOurNISDomain, ext+2, size);
+ NetOurNISDomain[size] = 0 ;
+ }
+ break;
+ /* Application layer fields */
+ case 43: /* Vendor specific info - Not yet supported */
+ /*
+ * Binary informations to exchange specific
+ * product information.
+ */
+ break;
+ /* Reserved (custom) fields (128..254) */
+ }
+}
+
+void BootpVendorProcess(u8 *ext, int size)
+{
+ u8 *end = ext + size ;
+#ifdef DEBUG_BOOTP_EXT
+ printf("[BOOTP] Checking extension (%d bytes)...\n", size);
+#endif
+ while ((ext < end) && (*ext != 0xff)) {
+ if (*ext == 0) {
+ ext ++ ;
+ } else {
+ u8 *opt = ext ;
+ ext += ext[1] + 2 ;
+ if (ext <= end)
+ BootpVendorFieldProcess (opt) ;
+ }
+ }
+
+#ifdef DEBUG_BOOTP_EXT
+ printf("[BOOTP] Received fields: \n");
+ if (NetOurSubnetMask)
+ printf(" NetOurSubnetMask : "); NetPrintIPaddr (NetOurSubnetMask); putc("\n");
+
+ if (NetOurGatewayIP)
+ printf("\n NetOurGatewayIP : "); NetPrintIPaddr (NetOurGatewayIP); putc("\n");
+
+ if (NetBootFileSize)
+ printf(" NetBootFileSize : %d\n", NetBootFileSize);
+
+ if (NetOurHostName[0])
+ printf(" NetOurHostName : %s\n", NetOurHostName);
+
+ if (NetOurRootPath[0])
+ printf(" NetOurRootPath : %s\n", NetOurRootPath);
+
+ if (NetOurNISDomain[0])
+ printf(" NetOurNISDomain : %s\n", NetOurNISDomain);
+#endif
+}
+
/*
* Handle a BOOTP received packet.
*/
{
Bootp_t * bp;
-
#if 0
printf("got BOOTP packet (src=%d, dst=%d, len=%d)\n", src, dest, len);
#endif /* DEBUG */
NetCopyEther(NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src);
memcpy(BootFile, bp->bp_file, sizeof bp->bp_file);
+ /* Retrieve extended informations (we must parse the vendor area) */
+ if ((*(uint *)bp->bp_vend) == BOOTP_VENDOR_MAGIC)
+ BootpVendorProcess(&bp->bp_vend[4], len);
+
NetSetTimeout(0, (thand_f *)0);
#ifdef DEBUG
BootpRequest(BootFile, lAddr);
}
+/* Initialize BOOTP extension fields in the request. */
+int BootpExtended (u8 *e)
+{
+ u8 *start = e ;
+
+ *e++ = 99; /* RFC1048 Magic Cookie */
+ *e++ = 130;
+ *e++ = 83;
+ *e++ = 99;
+
+ *e++ = 1; /* Subnet mask request */
+ *e++ = 4;
+ e += 4;
+
+ *e++ = 3; /* Default gateway request */
+ *e++ = 4;
+ e += 4;
+
+ *e++ = 12; /* Host name request */
+ *e++ = 32;
+ e += 32;
+
+ *e++ = 40; /* NIS Domain name request */
+ *e++ = 32;
+ e += 32;
+
+ *e++ = 17; /* Boot path */
+ *e++ = 32;
+ e += 32;
+
+ *e++ = 13; /* Boot file size */
+ *e++ = 4;
+ e += 4;
+
+ *e = 255; /* End of the list */
+
+ return e - start ;
+}
void
BootpRequest(char *fileName, ulong loadAdr)
NetCopyEther(bp->bp_chaddr, NetOurEther);
strcpy(bp->bp_file, fileName);
+ /* Request additional information from the BOOTP server */
+ BootpExtended (bp->bp_vend) ;
+
/* store boot file name for repetitions in case of bootp timeout */
strcpy(BootFile, fileName);
/*
- * LiMon - BOOTP.
+ * Copied from LiMon - BOOTP.
*
* Copyright 1994, 1995, 2000 Neil Russell.
* (See License)
+ * Copyright 2000 Paolo Scaffardi
*/
#ifndef __BOOTP_H__
*/
typedef struct
{
- uchar bp_op; /* Operation */
-# define OP_BOOTREQUEST 1
-# define OP_BOOTREPLY 2
- uchar bp_htype; /* Hardware type */
-# define HWT_ETHER 1
- uchar bp_hlen; /* Hardware address length */
-# define HWL_ETHER 6
- uchar bp_hops; /* Hop count (gateway thing) */
- ulong bp_id; /* Transaction ID */
- ushort bp_secs; /* Seconds since boot */
- ushort bp_spare1; /* Alignment */
- IPaddr_t bp_ciaddr; /* Client IP address */
- IPaddr_t bp_yiaddr; /* Your (client) IP address */
- IPaddr_t bp_siaddr; /* Server IP address */
- IPaddr_t bp_giaddr; /* Gateway IP address */
- uchar bp_chaddr[16]; /* Client hardware address */
- char bp_sname[64]; /* Server host name */
- char bp_file[128]; /* Boot file name */
- char bp_vend[64]; /* Vendor information */
-}
- Bootp_t;
+ uchar bp_op; /* Operation */
+# define OP_BOOTREQUEST 1
+# define OP_BOOTREPLY 2
+ uchar bp_htype; /* Hardware type */
+# define HWT_ETHER 1
+ uchar bp_hlen; /* Hardware address length */
+# define HWL_ETHER 6
+ uchar bp_hops; /* Hop count (gateway thing) */
+ ulong bp_id; /* Transaction ID */
+ ushort bp_secs; /* Seconds since boot */
+ ushort bp_spare1; /* Alignment */
+ IPaddr_t bp_ciaddr; /* Client IP address */
+ IPaddr_t bp_yiaddr; /* Your (client) IP address */
+ IPaddr_t bp_siaddr; /* Server IP address */
+ IPaddr_t bp_giaddr; /* Gateway IP address */
+ uchar bp_chaddr[16]; /* Client hardware address */
+ char bp_sname[64]; /* Server host name */
+ char bp_file[128]; /* Boot file name */
+ char bp_vend[128]; /* Vendor information */
+} Bootp_t;
#define BOOTP_HDR_SIZE sizeof (Bootp_t)
#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE)
*/
/* bootp.c */
-extern ulong BootpID; /* ID of cur BOOTP request */
-extern char BootFile[128]; /* Boot file name */
+extern ulong BootpID; /* ID of cur BOOTP request */
+extern char BootFile[128]; /* Boot file name */
extern int BootpTry;
-extern void BootpRequest(char *fileName, ulong loadAdr); /* Send a BOOTP request */
+/* Send a BOOTP request */
+extern void BootpRequest(char *fileName, ulong loadAdr);
/**********************************************************************/
/*
- * Linux Monitor (LiMon) - Networking.
+ * Copied from Linux Monitor (LiMon) - Networking.
*
* Copyright 1994 - 2000 Neil Russell.
* (See License)
+ * Copyright 2000 Roland Borde
+ * Copyright 2000 Paolo Scaffardi
*
* History
- * 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added
+ * 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added
*/
#include <ppcboot.h>
#if (CONFIG_COMMANDS & CFG_CMD_NET)
-uchar NetOurEther[6]; /* Our ethernet address */
-uchar NetServerEther[6]; /* Boot server enet address */
-IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
-IPaddr_t NetServerIP; /* Our IP addr (0 = unknown) */
-volatile uchar * NetRxPkt; /* Current receive packet */
-int NetRxPktLen; /* Current rx packet length */
-unsigned NetIPID; /* IP packet ID */
-uchar NetBcastAddr[6] = /* Ethernet bcast address */
- { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-int NetState; /* Network loop state */
+/** BOOTP EXTENTIONS **/
-volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE + PKTALIGN];
+IPaddr_t NetOurSubnetMask=0; /* Our subnet mask (0=unknown) */
+int NetOurGatewaysNum=0; /* Out gateways number */
+IPaddr_t NetOurGatewaysIP[4]={0,}; /* Our gateways IP addresses */
+char NetOurNISDomain[32]={0,}; /* Our NIS domain */
+char NetOurHostName[32]={0,}; /* Our hostname */
+char NetOurRootPath[32]={0,}; /* Our bootpath */
+int NetBootFileSize=0; /* Out bootfile size */
-volatile uchar * NetRxPackets[PKTBUFSRX]; /* Receive packets */
+/** END OF BOOTP EXTENTIONS **/
-static rxhand_f * packetHandler; /* Current RX packet handler */
-static thand_f * timeHandler; /* Current timeout handler */
-static ulong timeValue; /* Current timeout value */
-volatile uchar * NetTxPacket = 0; /* THE transmit packet */
+uchar NetOurEther[6]; /* Our ethernet address */
+uchar NetServerEther[6]; /* Boot server enet address */
+IPaddr_t NetOurIP; /* Our IP addr (0 = unknown) */
+IPaddr_t NetServerIP; /* Our IP addr (0 = unknown) */
+volatile uchar *NetRxPkt; /* Current receive packet */
+int NetRxPktLen; /* Current rx packet length */
+unsigned NetIPID; /* IP packet ID */
+uchar NetBcastAddr[6] = /* Ethernet bcast address */
+ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+int NetState; /* Network loop state */
-static ulong tb_factor;
+volatile uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE + PKTALIGN];
+
+volatile uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
+
+static rxhand_f *packetHandler; /* Current RX packet handler */
+static thand_f *timeHandler; /* Current timeout handler */
+static ulong timeValue; /* Current timeout value */
+volatile uchar *NetTxPacket = 0; /* THE transmit packet */
+
+static ulong tb_factor;
/**********************************************************************/
char *s, *e;
ulong reg;
-
- if (!NetTxPacket)
- {
- int i;
+ if (!NetTxPacket) {
+ int i;
ulong DecrementerSpeed;
/*
DecrementerSpeed = bis->bi_busfreq * 1000000 / 4;
tb_factor = 0xffffffff / (DecrementerSpeed / HZ);
- }
+ }
- eth_halt();
+ eth_halt();
eth_init(bis);
NetCopyEther(NetOurEther, bis->bi_enetaddr);
NetOurIP = 0;
BootpTry = 0;
- RarpTry = 0;
+ RarpTry = 0;
- restart:
+restart:
NetState = NETLOOP_CONTINUE;
/*
* here on, this code is a state machine driven by received
* packets and timer events.
*/
- switch (protocol) {
+ switch (protocol) {
- case TFTP:
+ case TFTP:
NetCopyEther(NetServerEther, NetBcastAddr);
strcpy(BootFile, fileName);
NetOurIP = bis->bi_ip_addr;
if (NetOurIP & NetServerIP) {
TftpStart(loadAdr);
} else {
- printf("\nThis command requires valid IP addresses for Server (serverip)\nand client (ipaddr) in the environment!\n");
+ printf ("\n"
+ "Environment variables `ipaddr' and `serverip'"
+ " needed for this command\n"
+ );
return 0;
}
break;
- case RARP:
- RarpRequest(fileName, loadAdr);
+ case RARP:
+ RarpRequest(fileName, loadAdr);
break;
- default:
+ default:
BootpRequest(fileName, loadAdr);
break;
}
* Main packet reception loop. Loop receiving packets until
* someone sets `NetQuit'.
*/
- for (;;)
- {
+ for (;;) {
/*
* Check the ethernet for a new packet. The ethernet
* receive routine will process it.
/*
* Check the keyboard for a Key. Quit if we get one.
- */
- if (serial_tstc())
- {
+ */
+ if (tstc()) {
printf("\nAbort\n");
return 0;
}
* Check for a timeout, and run the timeout handler
* if we have one.
*/
- if (timeHandler && GetTicksSinceBoot() > timeValue)
- {
- thand_f * x;
+ if (timeHandler && GetTicksSinceBoot() > timeValue) {
+ thand_f *x;
x = timeHandler;
timeHandler = (thand_f *)0;
}
- switch (NetState)
- {
+ switch (NetState) {
+
case NETLOOP_RESTART:
goto restart;
void
NetSetTimeout(int iv, thand_f * f)
{
- if (iv == 0)
+ if (iv == 0) {
timeHandler = (thand_f *)0;
- else
- {
+ } else {
timeHandler = f;
- timeValue = GetTicksSinceBoot() + iv;
+ timeValue = GetTicksSinceBoot() + iv;
}
}
void
NetReceive(volatile uchar * pkt, int len)
{
- Ethernet_t * et;
- IP_t * ip;
- ARP_t * arp;
- int x;
+ Ethernet_t *et;
+ IP_t *ip;
+ ARP_t *arp;
+ int x;
NetRxPkt = pkt;
et = (Ethernet_t *)pkt;
x = SWAP16(et->et_protlen);
- if (x < 1514)
- {
+
+ if (x < 1514) {
/*
* Got a 802 packet. Check the other protocol field.
*/
x = SWAP16(et->et_prot);
ip = (IP_t *)(pkt + E802_HDR_SIZE);
len -= E802_HDR_SIZE;
- }
- else
- {
+ } else {
ip = (IP_t *)(pkt + ETHER_HDR_SIZE);
len -= ETHER_HDR_SIZE;
}
printf("Receive from protocol 0x%x\n", x);
#endif
- switch (x)
- {
+ switch (x) {
+
case PROT_ARP:
/*
* The only type of ARP packet we deal with is a request
printf("Got ARP\n");
#endif
arp = (ARP_t *)ip;
- if (len < ARP_HDR_SIZE)
- {
+ if (len < ARP_HDR_SIZE) {
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
return;
}
return;
if (NetOurIP == 0 ||
- *((IPaddr_t *)&arp->ar_data[16]) != NetOurIP)
+ *((IPaddr_t *)&arp->ar_data[16]) != NetOurIP) {
return;
+ }
NetSetEther((uchar *)et, et->et_src, PROT_ARP);
arp->ar_op = SWAP16(ARPOP_REPLY);
printf("Got RARP\n");
#endif
arp = (ARP_t *)ip;
- if (len < ARP_HDR_SIZE)
- {
+ if (len < ARP_HDR_SIZE) {
printf("bad length %d < %d\n", len, ARP_HDR_SIZE);
return;
}
if ((SWAP16(arp->ar_op) != RARPOP_REPLY) ||
(SWAP16(arp->ar_hrd) != ARP_ETHER) ||
(SWAP16(arp->ar_pro) != PROT_IP) ||
- (arp->ar_hln != 6) || (arp->ar_pln != 4))
+ (arp->ar_hln != 6) || (arp->ar_pln != 4)) {
printf("invalid RARP header\n");
- else
- {
+ } else {
NetOurIP = *((IPaddr_t *)&arp->ar_data[16]);
NetServerIP = *((IPaddr_t *)&arp->ar_data[6]);
NetCopyEther(NetServerEther, &arp->ar_data[0]);
#endif
if (len < IP_HDR_SIZE)
return;
- if (len < SWAP16(ip->ip_len))
- {
+ if (len < SWAP16(ip->ip_len)) {
printf("len bad %d < %d\n", len, SWAP16(ip->ip_len));
return;
}
return;
if (ip->ip_off & SWAP16c(0x1fff)) /* Can't deal w/ fragments */
return;
- if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2))
- {
+ if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
printf("checksum bad\n");
return;
}
return;
- /* if at this point we still use the ET broadcast address
- * copy the server ET adress to the req. location;
- * this happens when issuing a TFTP request with the
- * known server IP address and the ET broadcast address as destin.
+ /*
+ * At this point we still use the ET broadcast
+ * address; copy the server ET adress to the req.
+ * location. This happens when issuing a TFTP request
+ * with the known server IP address and the ET
+ * broadcast address as destination.
*/
- if (memcmp(NetServerEther, NetBcastAddr, 6) == 0)
+ if (memcmp(NetServerEther, NetBcastAddr, 6) == 0)
NetCopyEther(NetServerEther, et->et_src);
/*
unsigned
NetCksum(uchar * ptr, int len)
{
- ulong xsum;
+ ulong xsum;
xsum = 0;
while (len-- > 0)
xsum += *((ushort *)ptr)++;
xsum = (xsum & 0xffff) + (xsum >> 16);
xsum = (xsum & 0xffff) + (xsum >> 16);
- return xsum & 0xffff;
+ return (xsum & 0xffff);
}
void
NetCopyEther(volatile uchar * to, uchar * from)
{
- int i;
+ int i;
for (i = 0; i < 6; i++)
*to++ = *from++;
void
NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
{
- volatile Ethernet_t * et = (Ethernet_t *)xet;
+ volatile Ethernet_t *et = (Ethernet_t *)xet;
NetCopyEther(et->et_dest, addr);
NetCopyEther(et->et_src, NetOurEther);
void
NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
{
- volatile IP_t * ip = (IP_t *)xip;
+ volatile IP_t *ip = (IP_t *)xip;
/*
* If the data is an odd number of bytes, zero the
* Construct an IP and UDP header.
(need to set no fragment bit - XXX)
*/
- ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
- ip->ip_tos = 0;
- ip->ip_len = SWAP16(IP_HDR_SIZE + len);
- ip->ip_id = SWAP16(NetIPID++);
- ip->ip_off = SWAP16c(0x4000); /* No fragmentation */
- ip->ip_ttl = 255;
- ip->ip_p = 17; /* UDP */
- ip->ip_sum = 0;
- ip->ip_src = NetOurIP;
- ip->ip_dst = dest;
- ip->udp_src = SWAP16(sport);
- ip->udp_dst = SWAP16(dport);
- ip->udp_len = SWAP16(8 + len);
+ ip->ip_hl_v = 0x45; /* IP_HDR_SIZE / 4 (not including UDP) */
+ ip->ip_tos = 0;
+ ip->ip_len = SWAP16(IP_HDR_SIZE + len);
+ ip->ip_id = SWAP16(NetIPID++);
+ ip->ip_off = SWAP16c(0x4000); /* No fragmentation */
+ ip->ip_ttl = 255;
+ ip->ip_p = 17; /* UDP */
+ ip->ip_sum = 0;
+ ip->ip_src = NetOurIP;
+ ip->ip_dst = dest;
+ ip->udp_src = SWAP16(sport);
+ ip->udp_dst = SWAP16(dport);
+ ip->udp_len = SWAP16(8 + len);
ip->udp_xsum = 0;
- ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
+ ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
}
-void
-NetPrintIPaddr(IPaddr_t x)
+void NetIPaddr (IPaddr_t x, char *s)
{
- x = SWAP32(x);
- printf("%d.%d.%d.%d", (int)((x >> 24) & 0xff),
- (int)((x >> 16) & 0xff),
- (int)((x >> 8) & 0xff),
- (int)((x >> 0) & 0xff));
+ x = SWAP32(x);
+ sprintf (s,"%d.%d.%d.%d",
+ (int)((x >> 24) & 0xff),
+ (int)((x >> 16) & 0xff),
+ (int)((x >> 8) & 0xff),
+ (int)((x >> 0) & 0xff)
+ );
+}
+
+void NetPrintIPaddr(IPaddr_t x)
+{
+ char tmp[12];
+
+ NetIPaddr(x, tmp);
+
+ puts(tmp);
}
ulong
GetTicksSinceBoot(void)
{
- ulong l;
- ulong h;
- ulong tmp;
- unsigned long long tb;
+ ulong l;
+ ulong h;
+ ulong tmp;
+ unsigned long long tb;
- asm volatile (" 1: mftbu %0;
+ asm volatile (" 1: mftbu %0;
mftb %1;
mftbu %2;
cmpw %0, %2;
static void
RarpHandler(uchar * dummi0, unsigned dummi1, unsigned dummi2, unsigned dummi3)
{
-/* Bootp_t * bp; */
-
printf("Got good RARP\n");
TftpStart(lAddr);
RarpRequest(char *fileName, ulong loadAdr)
{
int i;
- volatile uchar * pkt;
+ volatile uchar *pkt;
ARP_t * rarp;
lAddr = loadAdr;
*(IPaddr_t *)(&rarp->ar_data[6]) = NetOurIP; /* source IP addr */
NetCopyEther(&rarp->ar_data[10], NetOurEther); /* dest ET addr = source ET addr ??*/
/* dest. IP addr set to broadcast */
- for (i = 0; i <= 3; i++) rarp->ar_data[16 + i] = 0xff;
+ for (i = 0; i <= 3; i++) rarp->ar_data[16 + i] = 0xff;
#if (CONFIG_COMMANDS & CFG_CMD_NET)
-#define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
-#define TIMEOUT 2 /* Seconds to timeout for a lost pkt */
-#define TIMEOUT_COUNT 10 /* # of timeouts before giving up */
- /* (for checking the image size) */
-#define NDOTS 65 /* Number of "loading" dots */
+#define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
+#define TIMEOUT 2 /* Seconds to timeout for a lost pkt */
+#define TIMEOUT_COUNT 10 /* # of timeouts before giving up */
+ /* (for checking the image size) */
+#define NDOTS 65 /* Number of "loading" dots */
/*
* TFTP operations.
-static int TftpServerPort; /* The UDP port at their end */
-static int TftpOurPort; /* The UDP port at our end */
+static int TftpServerPort; /* The UDP port at their end */
+static int TftpOurPort; /* The UDP port at our end */
static int TftpTimeoutCount;
static unsigned TftpBlock;
static unsigned TftpLastBlock;
#define STATE_BAD_MAGIC 4
ulong TftpLoadAddress; /* Place to load the image into */
-static void
-store_block(unsigned block, uchar * src, unsigned len)
+static __inline__ void
+store_block (unsigned block, uchar * src, unsigned len)
{
(void)memcpy((void *)(TftpLoadAddress + block * 512), src, len);
}
/**********************************************************************/
static void
-TftpSend(void)
+TftpSend (void)
{
volatile uchar * pkt;
volatile uchar * xp;
int len;
-
/*
* We will always be sending some sort of packet, so
* cobble together the packet headers now.
*/
pkt = NetTxPacket + ETHER_HDR_SIZE + IP_HDR_SIZE;
- switch (TftpState)
- {
+ switch (TftpState) {
+
case STATE_RRQ:
xp = pkt;
*((ushort *)pkt)++ = SWAP16c(TFTP_RRQ);
- strcpy((char *)pkt, &BootFile[0]);
+ strcpy ((char *)pkt, &BootFile[0]);
pkt += strlen(BootFile) + 1;
- strcpy((char *)pkt, "octet");
+ strcpy ((char *)pkt, "octet");
pkt += 5 /*strlen("octet")*/ + 1;
len = pkt - xp;
break;
xp = pkt;
*((ushort *)pkt)++ = SWAP16c(TFTP_ERROR);
*((ushort *)pkt)++ = SWAP16(3);
- strcpy((char *)pkt, "File too large");
+ strcpy ((char *)pkt, "File too large");
pkt += 14 /*strlen("File too large")*/ + 1;
len = pkt - xp;
break;
xp = pkt;
*((ushort *)pkt)++ = SWAP16c(TFTP_ERROR);
*((ushort *)pkt)++ = SWAP16(2);
- strcpy((char *)pkt, "File has bad magic");
+ strcpy ((char *)pkt, "File has bad magic");
pkt += 18 /*strlen("File has bad magic")*/ + 1;
len = pkt - xp;
break;
}
- NetSetEther(NetTxPacket, NetServerEther, PROT_IP);
- NetSetIP(NetTxPacket + ETHER_HDR_SIZE, NetServerIP,
+ NetSetEther (NetTxPacket, NetServerEther, PROT_IP);
+ NetSetIP (NetTxPacket + ETHER_HDR_SIZE, NetServerIP,
TftpServerPort, TftpOurPort, len);
- NetSendPacket(NetTxPacket, ETHER_HDR_SIZE + IP_HDR_SIZE + len);
+ NetSendPacket (NetTxPacket, ETHER_HDR_SIZE + IP_HDR_SIZE + len);
}
static void
-TftpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
{
if (dest != TftpOurPort)
return;
if (len < 2)
return;
len -= 2;
- switch (SWAP16(*((ushort *)pkt)++))
- {
+ switch (SWAP16(*((ushort *)pkt)++)) {
+
case TFTP_RRQ:
case TFTP_WRQ:
case TFTP_ACK:
return;
len -= 2;
TftpBlock = SWAP16(*(ushort *)pkt);
- if (((TftpBlock - 1) % 10) == 0) printf("#");
+ if (((TftpBlock - 1) % 10) == 0) printf ("#");
- if (TftpState == STATE_RRQ)
- {
+ if (TftpState == STATE_RRQ) {
TftpState = STATE_DATA;
TftpServerPort = src;
TftpLastBlock = 0;
- if (TftpBlock != 1) /* Assertion */
- {
- printf("\nTFTP error: First block is not "
- "block 1 (%d).\n", TftpBlock);
- printf("Starting again.\n\n");
- NetStartAgain();
+ if (TftpBlock != 1) { /* Assertion */
+ printf ("\nTFTP error: First block is not "
+ "block 1 (%d)\n", TftpBlock);
+ printf ("Starting again\n\n");
+ NetStartAgain ();
break;
}
}
- if (TftpBlock == TftpLastBlock)
- {
+ if (TftpBlock == TftpLastBlock) {
/*
* Same block again; ignore it.
*/
TftpTimeoutCount = 0;
/* ImageSize += len; */
- store_block(TftpBlock - 1, pkt + 2, len);
+ store_block (TftpBlock - 1, pkt + 2, len);
/*
* Acknoledge the block just received, which will prompt
* the server for the next one.
*/
- TftpSend();
+ TftpSend ();
- if (len < 512)
- {
+ if (len < 512) {
/*
* We received the whole thing. Try to
* run it.
*/
- printf("\ndone.\n");
+ printf ("\ndone\n");
NetState = NETLOOP_SUCCESS;
}
break;
case TFTP_ERROR:
- printf("\nTFTP error: '%s' (%d)\n",
+ printf ("\nTFTP error: '%s' (%d)\n",
pkt + 2, SWAP16(*(ushort *)pkt));
- printf("Starting again.\n\n");
- NetStartAgain();
+ printf ("Starting again\n\n");
+ NetStartAgain ();
break;
}
}
static void
-TftpTimeout(void)
+TftpTimeout (void)
{
- if (++TftpTimeoutCount >= TIMEOUT_COUNT)
- {
- printf("\nRetry count exceeded; starting again\n");
- NetStartAgain();
- }
- else
- {
- printf("T ");
- NetSetTimeout(TIMEOUT * HZ, TftpTimeout);
- TftpSend();
+ if (++TftpTimeoutCount >= TIMEOUT_COUNT) {
+ printf ("\nRetry count exceeded; starting again\n");
+ NetStartAgain ();
+ } else {
+ printf ("T ");
+ NetSetTimeout (TIMEOUT * HZ, TftpTimeout);
+ TftpSend ();
}
}
void
-TftpStart(ulong loadAdr)
+TftpStart (ulong loadAdr)
{
#ifdef ET_DEBUG
- printf(".\nServer ethernet address %02x:%02x:%02x:%02x:%02x:%02x\n",
- NetServerEther[0],
- NetServerEther[1],
- NetServerEther[2],
- NetServerEther[3],
- NetServerEther[4],
- NetServerEther[5]);
+ printf ("\nServer ethernet address %02x:%02x:%02x:%02x:%02x:%02x\n",
+ NetServerEther[0],
+ NetServerEther[1],
+ NetServerEther[2],
+ NetServerEther[3],
+ NetServerEther[4],
+ NetServerEther[5]
+ );
#endif /* DEBUG */
- printf("TFTP from server ");
- NetPrintIPaddr(NetServerIP);
- printf("; our IP address is ");
- NetPrintIPaddr(NetOurIP);
- printf(".\n");
+ printf ("TFTP from server "); NetPrintIPaddr (NetServerIP);
+ printf ("; our IP address is "); NetPrintIPaddr (NetOurIP);
+
+ // Check if we need to send across this subnet
+ if ((NetOurGatewaysNum > 0) && (NetOurSubnetMask != 0)) {
+ IPaddr_t OurNet = NetOurIP & NetOurSubnetMask;
+ IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask;
- if (BootFile[0] == '\0')
- {
- int i;
+ if (OurNet != ServerNet) {
+ printf ("; sending throught gateway ");
+ NetPrintIPaddr (NetOurGatewaysIP[0]) ;
+ }
+ }
+ printf ("\n");
+
+ if (BootFile[0] == '\0') {
+ int i;
- for (i = 0; i < 4; i++)
- {
- static char hex[] = "0123456789ABCDEF";
- int x;
+ for (i = 0; i < 4; i++) {
+ static char hex[] = "0123456789ABCDEF";
+ int x;
x = (NetOurIP >> (i * 8)) & 0xff;
- BootFile[i*2+0] = hex[x >> 4];
+ BootFile[i*2+0] = hex[x >> 4];
BootFile[i*2+1] = hex[x & 0xf];
}
- strcpy(&BootFile[8], ".img");
+ strcpy (&BootFile[8], ".img");
- printf("No file name; using '%s'.\n", BootFile);
- }
- else
- {
- printf("Filename '%s'.\n", BootFile);
+ printf ("No file name; using '%s'.", BootFile);
+ } else {
+ printf ("Filename '%s'.", BootFile);
}
- if (loadAdr == -1) {
+ if (NetBootFileSize)
+ printf (" Size is %d%s kB",
+ NetBootFileSize,
+ (NetBootFileSize%2) ? ".5" : "");
+
+ printf ("\n");
+
+ if (loadAdr == ~0) {
TftpLoadAddress = CFG_TFTP_LOADADDR;
- printf("No load address; using 0x%lx\n", TftpLoadAddress);
- }
- else
- {
+ printf ("No load address; using 0x%lx\n", TftpLoadAddress);
+ } else {
TftpLoadAddress = loadAdr;
- printf("Load address: 0x%lx\n", TftpLoadAddress);
+ printf ("Load address: 0x%lx\n", TftpLoadAddress);
}
- printf("Loading: *\b");
+ printf ("Loading: *\b");
- NetSetTimeout(TIMEOUT * HZ, TftpTimeout);
- NetSetHandler(TftpHandler);
+ NetSetTimeout (TIMEOUT * HZ, TftpTimeout);
+ NetSetHandler (TftpHandler);
TftpServerPort = WELL_KNOWN_PORT;
TftpTimeoutCount = 0;
TftpState = STATE_RRQ;
TftpOurPort = 1024 + (GetTicksSinceBoot() % 3072);
- TftpSend();
+ TftpSend ();
}
#endif /* CFG_CMD_NET */
# MA 02111-1307 USA
#
-
+PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
return i;
}
-// static char printbuffer[256];
-
-/* damm:
- * i've put the printbuffer on the stack - good for printouts without dram */
-
-void printf(const char *fmt, ...)
-{
- va_list args;
- uint i;
- char printbuffer[CFG_PBSIZE]; // damm, wd
- char *cp;
- extern void serial_putc (const char);
-
- va_start(args, fmt);
-
- /* For this to work, printbuffer must be larger than
- * anything we ever want to print.
- */
- i = vsprintf(printbuffer, fmt, args);
- va_end(args);
-
- cp = printbuffer;
- while (i-- > 0) {
- serial_putc(*cp);
- cp++;
- }
-}
-
void panic(const char *fmt, ...)
{
va_list args;
* - added Z_PACKET_FLUSH (see zlib.h for details)
* - added inflateIncomp
*
- * $Id: zlib.c,v 1.1 2000/07/18 08:54:27 wd Exp $
+ * $Id: zlib.c,v 1.2 2000/10/25 10:46:51 wd Exp $
*/
/*+++++*/
s->read = s->write = s->window;
if (s->checkfn != Z_NULL)
s->check = (*s->checkfn)(0L, Z_NULL, 0);
+ if (z->outcb != Z_NULL)
+ (*z->outcb)(Z_NULL, 0);
Trace((stderr, "inflate: blocks reset\n"));
}
/* update check information */
if (s->checkfn != Z_NULL)
s->check = (*s->checkfn)(s->check, q, t);
+ /* output callback */
+ if (z->outcb != Z_NULL)
+ (*z->outcb)(q, t);
zmemcpy(q, p, t);
q += t;
p += t;
if (s->checkfn != Z_NULL)
s->check = (*s->checkfn)(s->check, q, n);
+ /* output callback */
+ if (z->outcb != Z_NULL)
+ (*z->outcb)(q, n);
+
/* copy as far as end of window */
zmemcpy(p, q, n);
p += n;
if (s->checkfn != Z_NULL)
s->check = (*s->checkfn)(s->check, q, n);
+ /* output callback */
+ if (z->outcb != Z_NULL)
+ (*z->outcb)(q, n);
+
/* copy */
zmemcpy(p, q, n);
p += n;
# MA 02111-1307 USA
#
+PLATFORM_RELFLAGS += -mrelocatable -ffixed-r14
+
+PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -mstring -mcpu=403 -msoft-float
void
-serial_putstr (const char *s)
+serial_puts (const char *s)
{
while (*s)
{
void
-serial_putstr (const char *s)
+serial_puts (const char *s)
{
while (*s)
{
int checkboard (void)
{
- printf ("MPC823TS\n");
+ printf ("SPD823TS\n");
return (1);
}
unsigned short ImageHeight;
unsigned char ImagePixelSize;
unsigned char ImageDescriptorByte;
-} tga_header_t;
+} tga_header_t;
typedef struct {
unsigned char r,g,b ;
{
int count = strlen(str);
char c ;
-
+
while(count--)
{
c=*str;
{
int count = strlen(str);
char c ;
-
+
while(count--)
{
c=*str;
}
void pixel_rgb_to_yuyv (rgb_t *rgb_pixel, yuyv_t *yuyv_pixel)
{
- float R = rgb_pixel->r,
- G = rgb_pixel->g,
- B = rgb_pixel->b;
-
- yuyv_pixel->y1 = yuyv_pixel->y2 = 16 + ( 65.738 * R + 129.057 * G + 25.064 * B) / 256.0 ;
- yuyv_pixel->u = 128 + ( -37.945 * R - 74.494 * G + 112.439 * B) / 256.0 ;
- yuyv_pixel->v = 128 + ( 112.439 * R - 94.154 * G - 18.285 * B) / 256.0 ;
+ unsigned int pR, pG, pB ;
+
+ // Transform (0-255) components to (0-100)
+ pR = rgb_pixel->r * 100 / 255 ;
+ pG = rgb_pixel->g * 100 / 255 ;
+ pB = rgb_pixel->b * 100 / 255 ;
+
+ // Calculate YUV values (0-255) from RGB beetween 0-100
+ yuyv_pixel->y1 = yuyv_pixel->y2 = 209 * (pR + pG + pB) / 300 + 16 ;
+ yuyv_pixel->u = pR - (pG*3/4) - (pB/4) + 128 ;
+ yuyv_pixel->v = pB - (pR/4) - (pG*3/4) + 128 ;
return ;
-}
+}
void printlogo_rgb (rgb_t *data, int w, int h)
{
for (y=0; y<h; y++)
{
for (x=0; x<w; x++, data++)
- if ((data->r == 0)&&(data->g == 0)&&(data->b == 0))
+ if ((data->r < 30)/*&&(data->g == 0)&&(data->b == 0)*/)
printf(" ");
else
printf("X");
printf("\n");
- }
+ }
}
void printlogo_yuyv (unsigned short *data, int w, int h)
else
printf("X");
printf("\n");
- }
+ }
}
int image_load_tga (image_t *image, char *filename)
int i;
unsigned char app ;
rgb_t *p ;
-
+
if( ( file = fopen( filename, "rb" ) ) == NULL )
return -1;
image->width = header.ImageWidth ;
image->height = header.ImageHeight ;
-
+
switch (header.ImageTypeCode){
case 2: // Uncompressed RGB
image->yuyv = 0 ;
image->palette_size = 0 ;
image->palette = NULL ;
break;
-
+
default:
printf("Format not supported!\n");
return -1 ;
printf("Bpp not supported: %d!\n", image->bpp);
return -1 ;
}
-
- fread(image->data, image->size, 1, file);
+
+ fread(image->data, image->size, 1, file);
// Swapping R and B values
{
unsigned char *temp = malloc(image->size);
int linesize = image->pixel_size * image->width ;
- void *dest = image->data,
+ void *dest = image->data,
*source = temp + image->size - linesize ;
printf("S");
printf("Cannot alloc temp buffer!\n");
return -1;
}
-
+
memcpy(temp, image->data, image->size);
for(i = 0; i<image->height; i++, dest+=linesize, source-=linesize)
memcpy(dest, source, linesize);
-
+
free( temp );
}
-
+
#ifdef ENABLE_ASCII_BANNERS
printlogo_rgb (image->data,image->width, image->height);
#endif
fclose (file);
- return 0;
+ return 0;
}
int image_free (image_t *image)
rgb_t *rgb_ptr = (rgb_t *) rgb_image->data ;
yuyv_t yuyv ;
unsigned short *dest ;
- int count = rgb_image->pixels;
+ int count = 0 ;
yuyv_image->pixel_size = 2 ;
yuyv_image->bpp = 16 ;
dest = (unsigned short *) (yuyv_image->data = malloc(yuyv_image->size)) ;
yuyv_image->palette = 0 ;
yuyv_image->palette_size= 0 ;
-
- while(count--)
+
+ while((count++) < rgb_image->pixels)
{
pixel_rgb_to_yuyv (rgb_ptr++, &yuyv);
-
- // Use first pixel only (V and Y1)
- memcpy (dest, (void *)&yuyv + 2, sizeof(short));
-
+
+ if ((count & 1) == 0)
+ memcpy (dest, ((void *)&yuyv) + 2, sizeof(short));
+ else
+ memcpy (dest, (void *)&yuyv, sizeof(short));
+
dest ++ ;
}
#ifdef ENABLE_ASCII_BANNERS
printlogo_yuyv (yuyv_image->data, yuyv_image->width, yuyv_image->height);
-#endif
+#endif
return 0 ;
}
unsigned char *dataptr = image->data ;
if (file==NULL)
return -1 ;
-
+
// Author informations
fprintf(file, "//\n// Generated by EasyLogo, (C) 2000 by Paolo Scaffardi\n//\n");
fprintf(file, "// To use this, include it and call: easylogo_plot(screen,&%s, width,x,y)\n//\n", varname);
fprintf(file, "// \t\t'width'\tis the screen width\n");
fprintf(file, "// \t\t'x'\t\tis the horizontal position\n");
fprintf(file, "// \t\t'y'\t\tis the vertical position\n//\n\n");
-
+
// Headers
fprintf(file, "#include <video_easylogo.h>\n\n");
// Macros
strcpy(def_name, varname);
StringUpperCase (def_name);
- fprintf(file, "#define DEF_%s_WIDTH\t\t%d\n", def_name, image->width);
- fprintf(file, "#define DEF_%s_HEIGHT\t\t%d\n", def_name, image->height);
- fprintf(file, "#define DEF_%s_PIXELS\t\t%d\n", def_name, image->pixels);
- fprintf(file, "#define DEF_%s_BPP\t\t%d\n", def_name, image->bpp);
- fprintf(file, "#define DEF_%s_PIXEL_SIZE\t%d\n", def_name, image->pixel_size);
- fprintf(file, "#define DEF_%s_SIZE\t\t%d\n\n", def_name, image->size);
+ fprintf(file, "#define DEF_%s_WIDTH\t\t%d\n", def_name, image->width);
+ fprintf(file, "#define DEF_%s_HEIGHT\t\t%d\n", def_name, image->height);
+ fprintf(file, "#define DEF_%s_PIXELS\t\t%d\n", def_name, image->pixels);
+ fprintf(file, "#define DEF_%s_BPP\t\t%d\n", def_name, image->bpp);
+ fprintf(file, "#define DEF_%s_PIXEL_SIZE\t%d\n", def_name, image->pixel_size);
+ fprintf(file, "#define DEF_%s_SIZE\t\t%d\n\n", def_name, image->size);
// Declaration
fprintf(file, "unsigned char DEF_%s_DATA[DEF_%s_SIZE] = {\n", def_name, def_name);
col++;
count-- ;
break;
-
+
case 16:
fprintf(file, "%s", str);
if (count > 0)
fprintf(file,",");
fprintf(file, "\n");
-
+
col = 0 ;
break;
-
+
default:
strcpy(app, str);
sprintf(str, "%s, 0x%02x", app, *dataptr++);
count-- ;
break;
}
-
+
if (col)
fprintf(file, "%s\n", str);
-
+
// End of declaration
- fprintf(file, "};\n\n");
+ fprintf(file, "};\n\n");
// Variable
fprintf(file, "fastimage_t %s = {\n", varname);
fprintf(file, " DEF_%s_DATA,\n", def_name);
fprintf(file, " DEF_%s_BPP,\n", def_name);
fprintf(file, " DEF_%s_PIXEL_SIZE,\n", def_name);
fprintf(file, " DEF_%s_SIZE\n};\n", def_name);
-
+
fclose (file);
return 0 ;
int main (int argc, char *argv[])
{
char
- inputfile[DEF_FILELEN],
+ inputfile[DEF_FILELEN],
outputfile[DEF_FILELEN],
varname[DEF_FILELEN];
-
+
image_t rgb_logo, yuyv_logo ;
switch (argc){
- case 2:
+ case 2:
case 3:
case 4:
strcpy (inputfile, argv[1]);
int pos = strchr(inputfile, '.');
if (pos >= 0)
- {
+ {
strncpy (varname, inputfile, pos);
varname[pos] = 0 ;
}
}
-
+
if (argc > 3)
strcpy (outputfile, argv[3]);
else
{
int pos = strchr (varname, '.');
-
+
if (pos > 0)
{
char app[DEF_FILELEN] ;
-
+
strncpy(app, varname, pos);
sprintf(outputfile, "%s.h", app);
}
}
break;
-
+
default:
printf("EasyLogo 1.0 (C) 2000 by Paolo Scaffardi\n\n");
printf("Where: 'inputfile' is the TGA image to load\n");
printf(" 'outputvar' is the variable name to create\n");
printf(" 'outputfile' is the output header file (default is 'inputfile.h')\n");
-
+
return -1 ;
}
printf("Doing '%s' (%s) from '%s'...",
outputfile, varname, inputfile);
-
+
// Import TGA logo
-
+
printf("L");
if (image_load_tga (&rgb_logo, inputfile)<0)
{
printf("input file not found!\n");
exit(1);
}
-
+
// Convert it to YUYV format
printf("C");
image_rgb_to_yuyv (&rgb_logo, &yuyv_logo) ;
-
+
// Save it into a header format
-
+
printf("S");
image_save_header (&yuyv_logo, outputfile, varname) ;
-
+
// Free original image and copy
-
+
image_free (&rgb_logo);
image_free (&yuyv_logo);
printf("\n");
-
+
return 0 ;
}
#!/bin/sh
+make
./easylogo linux_logo.tga ppcboot_logo video_logo.h
mv video_logo.h ../../include
#include <sys/time.h>
#include "serial.h"
-static struct termios tios = { BRKINT, 0, B115200|CS8|CREAD, 0, 0 };
+#ifdef __sun__
+static struct termios tios = { BRKINT, 0, B115200|CS8|CREAD, 0, { 0 } };
+#else
+static struct termios tios = { BRKINT, 0, B115200|CS8|CREAD, 0, 0 };
+#endif
static struct speedmap {
char *str;
* Wolfgang Denk, wd@denx.de
* All rights reserved.
*
- * $Date: 2000/10/21 21:38:50 $
- * $Revision: 1.8 $
+ * $Date: 2000/10/25 10:46:51 $
+ * $Revision: 1.9 $
*/
#include <errno.h>
copy_file (ifd, datafile, 0);
}
-#ifdef _POSIX_SYNCHRONIZED_IO /* We're a bit of paranoid */
+ /* We're a bit of paranoid */
+#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__)
(void) fdatasync (ifd);
#else
(void) fsync (ifd);
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- serial_putc ('.');
+ putc ('.');
last = now;
}
}
}
for ( ; s<e; ++s) {
- serial_putc (*s);
+ putc (*s);
}
- serial_putc ('\n');
+ putc ('\n');
return (l_type);
}