Commit e99e9575 authored by Wolfgang Denk's avatar Wolfgang Denk
Browse files

Merge branch 'Makefile' of git://git.denx.de/u-boot-arm

parents a13b2d93 08ab4e17
......@@ -227,6 +227,7 @@ LIBS += drivers/mtd/nand_legacy/libnand_legacy.a
LIBS += drivers/mtd/onenand/libonenand.a
LIBS += drivers/mtd/spi/libspi_flash.a
LIBS += drivers/net/libnet.a
LIBS += drivers/net/phy/libphy.a
LIBS += drivers/net/sk98lin/libsk98lin.a
LIBS += drivers/pci/libpci.a
LIBS += drivers/pcmcia/libpcmcia.a
......
......@@ -27,16 +27,39 @@ LIB = $(obj)libcommon.a
AOBJS =
# core
COBJS-y += main.o
COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o
COBJS-y += circbuf.o
COBJS-y += console.o
COBJS-y += command.o
COBJS-y += devices.o
COBJS-y += dlmalloc.o
COBJS-y += exports.o
COBJS-y += hush.o
COBJS-y += image.o
COBJS-y += memsize.o
COBJS-y += s_record.o
COBJS-y += serial.o
COBJS-y += xyzModem.o
# environment
COBJS-y += environment.o
COBJS-y += env_common.o
COBJS-y += env_dataflash.o
COBJS-y += env_eeprom.o
COBJS-y += env_flash.o
COBJS-y += env_nand.o
COBJS-y += env_nvram.o
COBJS-y += env_onenand.o
COBJS-y += env_sf.o
COBJS-y += env_nowhere.o
# command
COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
COBJS-y += cmd_autoscript.o
COBJS-$(CONFIG_AUTOSCRIPT)$(CONFIG_CMD_AUTOSCRIPT) += cmd_autoscript.o
COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o
COBJS-$(CONFIG_CMD_BEDBUG) += cmd_bedbug.o
COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
COBJS-y += image.o
COBJS-y += gunzip.o
COBJS-y += cmd_boot.o
COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
COBJS-y += cmd_bootm.o
......@@ -84,10 +107,14 @@ COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o
COBJS-y += cmd_load.o
COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o
COBJS-y += cmd_mac.o
COBJS-y += cmd_mem.o
COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
COBJS-$(CONFIG_MII)$(CONFIG_CMD_MII) += miiphyutil.o
COBJS-$(CONFIG_CMD_MII) += cmd_mii.o
COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
COBJS-$(CONFIG_MP) += cmd_mp.o
COBJS-y += cmd_nand.o
COBJS-$(CONFIG_CMD_NET) += cmd_net.o
COBJS-y += cmd_nvedit.o
......@@ -101,58 +128,30 @@ COBJS-$(CONFIG_CMD_PORTIO) += cmd_portio.o
COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o
COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o
COBJS-$(CONFIG_CMD_SATA) += cmd_sata.o
COBJS-$(CONFIG_CMD_SF) += cmd_sf.o
COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o
COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o
COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o
COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o
COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
COBJS-$(CONFIG_CMD_USB) += cmd_usb.o
ifdef CONFIG_CMD_USB
COBJS-y += cmd_usb.o
COBJS-y += usb.o
COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o
endif
COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o
COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o
COBJS-y += cmd_vfd.o
COBJS-y += command.o
COBJS-y += console.o
COBJS-y += devices.o
COBJS-y += dlmalloc.o
COBJS-$(CONFIG_CMD_DOC) += docecc.o
COBJS-y += environment.o
COBJS-y += env_common.o
COBJS-y += env_nand.o
COBJS-y += env_dataflash.o
COBJS-y += env_flash.o
COBJS-y += env_eeprom.o
COBJS-y += env_onenand.o
COBJS-y += env_sf.o
COBJS-y += env_nvram.o
COBJS-y += env_nowhere.o
COBJS-y += exports.o
COBJS-y += flash.o
COBJS-y += hush.o
COBJS-y += kgdb.o
COBJS-$(CONFIG_LCD) += lcd.o
COBJS-y += lists.o
COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o
COBJS-y += memsize.o
COBJS-$(CONFIG_BITBANGMII) += miiphybb.o
COBJS-y += miiphyutil.o
COBJS-y += s_record.o
COBJS-y += serial.o
COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
ifdef CONFIG_CMD_USB
COBJS-y += usb.o
COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o
endif
COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
COBJS-y += crc16.o
COBJS-y += xyzModem.o
COBJS-y += cmd_mac.o
COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
COBJS-$(CONFIG_MP) += cmd_mp.o
COBJS-$(CONFIG_CMD_SF) += cmd_sf.o
COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o
COBJS-y += $(COBJS-yy)
COBJS := $(COBJS-y)
SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
......
......@@ -47,8 +47,6 @@
#include <hush.h>
#endif
#if defined(CONFIG_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT)
int
autoscript (ulong addr, const char *fit_uname)
{
......@@ -200,8 +198,6 @@ autoscript (ulong addr, const char *fit_uname)
return rcode;
}
#endif
/**************************************************/
#if defined(CONFIG_CMD_AUTOSCRIPT)
int
......
......@@ -31,14 +31,17 @@
extern void _do_coninfo (void);
int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
int i, l;
int l;
struct list_head *list = device_get_list();
struct list_head *pos;
device_t *dev;
/* Scan for valid output and input devices */
puts ("List of available devices:\n");
for (i = 1; i <= ListNumItems (devlist); i++) {
device_t *dev = ListGetPtrToItem (devlist, i);
list_for_each(pos, list) {
dev = list_entry(pos, device_t, list);
printf ("%-8s %08x %c%c%c ",
dev->name,
......
......@@ -27,12 +27,10 @@
#include <common.h>
#include <command.h>
#include <devices.h>
#if defined(CONFIG_CMD_TERMINAL)
#include <serial.h>
int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
int i, l;
int last_tilde = 0;
device_t *dev = NULL;
......@@ -40,13 +38,7 @@ int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
return -1;
/* Scan for selected output/input device */
for (i = 1; i <= ListNumItems (devlist); i++) {
device_t *tmp = ListGetPtrToItem (devlist, i);
if (!strcmp(tmp->name, argv[1])) {
dev = tmp;
break;
}
}
dev = device_get_by_name(argv[1]);
if (!dev)
return -1;
......@@ -98,5 +90,3 @@ U_BOOT_CMD(
"terminal - start terminal emulator\n",
""
);
#endif /* CONFIG_CMD_TERMINAL */
......@@ -325,9 +325,22 @@ inline void dbg(const char *fmt, ...)
/** U-Boot INIT FUNCTIONS *************************************************/
device_t *search_device (int flags, char *name)
{
device_t *dev;
dev = device_get_by_name(name);
if(dev && (dev->flags & flags))
return dev;
return NULL;
}
int console_assign (int file, char *devname)
{
int flag, i;
int flag;
device_t *dev;
/* Check for valid file */
switch (file) {
......@@ -344,16 +357,10 @@ int console_assign (int file, char *devname)
/* 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);
dev = search_device(flag, devname);
return -1;
}
}
if(dev)
return console_setfile (file, dev);
return -1;
}
......@@ -371,27 +378,6 @@ int console_init_f (void)
return (0);
}
#if defined(CFG_CONSOLE_IS_IN_ENV) || defined(CONFIG_SPLASH_SCREEN) || defined(CONFIG_SILENT_CONSOLE)
/* search a device */
device_t *search_device (int flags, char *name)
{
int i, items;
device_t *dev = NULL;
items = ListNumItems (devlist);
if (name == NULL)
return dev;
for (i = 1; i <= items; i++) {
dev = ListGetPtrToItem (devlist, i);
if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) {
break;
}
}
return dev;
}
#endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
#ifdef CFG_CONSOLE_IS_IN_ENV
/* Called after the relocation - use desired console functions */
int console_init_r (void)
......@@ -488,7 +474,10 @@ int console_init_r (void)
int console_init_r (void)
{
device_t *inputdev = NULL, *outputdev = NULL;
int i, items = ListNumItems (devlist);
int i;
struct list_head *list = device_get_list();
struct list_head *pos;
device_t *dev;
#ifdef CONFIG_SPLASH_SCREEN
/* suppress all output if splash screen is enabled and we have
......@@ -498,11 +487,8 @@ int console_init_r (void)
#endif
/* Scan devices looking for input and output devices */
for (i = 1;
(i <= items) && ((inputdev == NULL) || (outputdev == NULL));
i++
) {
device_t *dev = ListGetPtrToItem (devlist, i);
list_for_each(pos, list) {
dev = list_entry(pos, device_t, list);
if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) {
inputdev = dev;
......@@ -510,6 +496,8 @@ int console_init_r (void)
if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev == NULL)) {
outputdev = dev;
}
if(inputdev && outputdev)
break;
}
/* Initializes output console first */
......
......@@ -36,7 +36,7 @@
DECLARE_GLOBAL_DATA_PTR;
list_t devlist = 0;
static device_t devs;
device_t *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
......@@ -48,18 +48,18 @@ char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
#ifdef CFG_DEVICE_NULLDEV
void nulldev_putc(const char c)
{
/* nulldev is empty! */
/* nulldev is empty! */
}
void nulldev_puts(const char *s)
{
/* nulldev is empty! */
/* nulldev is empty! */
}
int nulldev_input(void)
{
/* nulldev is empty! */
return 0;
/* nulldev is empty! */
return 0;
}
#endif
......@@ -108,10 +108,32 @@ static void drv_system_init (void)
* DEVICES
**************************************************************************
*/
struct list_head* device_get_list(void)
{
return &(devs.list);
}
device_t* device_get_by_name(char* name)
{
struct list_head *pos;
device_t *dev;
if(!name)
return NULL;
list_for_each(pos, &(devs.list)) {
dev = list_entry(pos, device_t, list);
if(strcmp(dev->name, name) == 0)
return dev;
}
return NULL;
}
int device_register (device_t * dev)
{
ListInsertItem (devlist, dev, LIST_END);
list_add(&(dev->list), &(devs.list));
return 0;
}
......@@ -121,20 +143,15 @@ int device_register (device_t * dev)
#ifdef CFG_DEVICE_DEREGISTER
int device_deregister(char *devname)
{
int i,l,dev_index;
device_t *dev = NULL;
int l;
struct list_head *pos;
device_t *dev;
char temp_names[3][8];
dev_index = -1;
for (i=1; i<=ListNumItems(devlist); i++) {
dev = ListGetPtrToItem (devlist, i);
if(strcmp(dev->name,devname)==0) {
dev_index=i;
break;
}
}
if(dev_index<0) /* device not found */
return 0;
dev = device_get_by_name(devname);
if(!dev) /* device not found */
return -1;
/* get stdio devices (ListRemoveItem changes the dev list) */
for (l=0 ; l< MAX_FILES; l++) {
if (stdio_devices[l] == dev) {
......@@ -145,14 +162,15 @@ int device_deregister(char *devname)
stdio_devices[l]->name,
sizeof(stdio_devices[l]->name));
}
ListRemoveItem(devlist,NULL,dev_index);
list_del(&(dev->list));
/* reassign Device list */
for (i=1; i<=ListNumItems(devlist); i++) {
dev = ListGetPtrToItem (devlist, i);
list_for_each(pos, &(devs.list)) {
dev = list_entry(pos, device_t, list);
for (l=0 ; l< MAX_FILES; l++) {
if(strcmp(dev->name,temp_names[l])==0) {
if(strcmp(dev->name, temp_names[l]) == 0)
stdio_devices[l] = dev;
}
}
}
return 0;
......@@ -161,7 +179,7 @@ int device_deregister(char *devname)
int devices_init (void)
{
#ifndef CONFIG_ARM /* already relocated for current ARM implementation */
#ifndef CONFIG_ARM /* already relocated for current ARM implementation */
ulong relocation_offset = gd->reloc_off;
int i;
......@@ -173,12 +191,8 @@ int devices_init (void)
#endif
/* Initialize the list */
devlist = ListCreate (sizeof (device_t));
INIT_LIST_HEAD(&(devs.list));
if (devlist == NULL) {
eputs ("Cannot initialize the list of devices!\n");
return -1;
}
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
#endif
......@@ -207,10 +221,3 @@ int devices_init (void)
return (0);
}
int devices_done (void)
{
ListDispose (devlist);
return 0;
}
#include <common.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)
/* increase list size by 10% every time it is full */
#define kDefaultAllocationPercentIncrease 10
/* always increase list size by 4 items when it is full */
#define kDefaultAllocationminNumItemsIncrease 4
/*
* how many items to expand the list by when it becomes full
* = current listSize (in items) + (hiword percent of list size) + loword
*/
#define NUMITEMSPERALLOC(list) MAX(((*list)->listSize * \
((*list)->percentIncrease + 100)) / 100, \
(*list)->minNumItemsIncrease )
#define ITEMPTR(list,item) &(((char *)&(*list)->itemList)[(*(list))->itemSize * (item)])
#define LIST_SIGNATURE CAT4CHARS('L', 'I', 'S', 'T');
#define calloc(size,num) malloc(size*num)
/********************************************************************/
Handle NewHandle (unsigned int numBytes)
{
void *memPtr;
HandleRecord *hanPtr;
memPtr = calloc (numBytes, 1);
hanPtr = (HandleRecord *) calloc (sizeof (HandleRecord), 1);
if (hanPtr && (memPtr || numBytes == 0)) {
hanPtr->ptr = memPtr;
hanPtr->size = numBytes;
return (Handle) hanPtr;
} else {
free (memPtr);
free (hanPtr);
return NULL;
}
}
/********************************************************************/
void DisposeHandle (Handle handle)
{
if (handle) {
free (*handle);
free ((void *) handle);
}
}
/********************************************************************/
unsigned int GetHandleSize (Handle handle)
{
return ((HandleRecord *) handle)->size;
}
/********************************************************************/
int SetHandleSize (Handle handle, unsigned int newSize)
{
HandleRecord *hanRecPtr = (HandleRecord *) handle;
void *newPtr, *oldPtr;
unsigned int oldSize;
oldPtr = hanRecPtr->ptr;
oldSize = hanRecPtr->size;
if (oldSize == newSize)
return 1;
if (oldPtr == NULL) {
newPtr = malloc (newSize);
} else {
newPtr = realloc (oldPtr, newSize);
}
if (newPtr || (newSize == 0)) {
hanRecPtr->ptr = newPtr;
hanRecPtr->size = newSize;
if (newSize > oldSize)
memset ((char *) newPtr + oldSize, 0, newSize - oldSize);
return 1;
} else
return 0;
}
#ifdef CFG_ALL_LIST_FUNCTIONS
/* Used to compare list elements by their raw data contents */
static int ListMemBlockCmp (void *a, void *b, int size)
{
return memcmp (a, b, size);
}
/***************************************************************************/
/*
* Binary search numElements of size elementSize in array for a match
* to the. item. Return the index of the element that matches
* (0 - numElements - 1). If no match is found return the -i-1 where
* i is the index (0 - numElements) where the item should be placed.
* (*theCmp)(a,b) should return <0 if a<b, 0 if a==b, >0 if a>b.
*
* This function is like the C-Library function bsearch() except that
* this function returns the index where the item should be placed if
* it is not found.
*/
int BinSearch ( void *array, int numElements, int elementSize,
void *itemPtr, CompareFunction compareFunction)
{
int low, high, mid, cmp;
void *arrayItemPtr;
for (low = 0, high = numElements - 1, mid = 0, cmp = -1; low <= high;) {
mid = (low + high) >> 1;
arrayItemPtr = (void *) (((char *) array) + (mid * elementSize));
cmp = compareFunction
? compareFunction (itemPtr, arrayItemPtr)
: ListMemBlockCmp (itemPtr, arrayItemPtr, elementSize);
if (cmp == 0) {
return mid;
} else if (cmp < 0) {
high = mid - 1;
} else {
low = mid + 1;
}
}
if (cmp > 0)
mid++;
return -mid - 1;
}
#endif /* CFG_ALL_LIST_FUNCTIONS */
/*******************************************************************************/
/*
* If numNewItems == 0 then expand the list by the number of items
* indicated by its allocation policy.
* If numNewItems > 0 then expand the list by exactly the number of
* items indicated.
* If numNewItems < 0 then expand the list by the absolute value of
* numNewItems plus the number of items indicated by its allocation
* policy.
* Returns 1 for success, 0 if out of memory
*/
static int ExpandListSpace (list_t list, int numNewItems)
{
if (numNewItems == 0) {
numNewItems = NUMITEMSPERALLOC (list);
} else if (numNewItems < 0) {
numNewItems = (-numNewItems) + NUMITEMSPERALLOC (list);