/*-
* Copyright (c) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
#include <crc32.h>
#include <stand.h>
#include "api_public.h"
#include "glue.h"
#ifdef DEBUG
#else
#endif
/* Some random address used by U-Boot. */
extern long uboot_address;
static int
{
struct api_signature s;
return (0);
/*
* Clear the checksum field (in the local copy) so as to calculate the
* CRC with the same initial contents as at the time when the sig was
* produced
*/
s = *sig;
s.checksum = 0;
return (0);
return (1);
}
/*
* Searches for the U-Boot API signature
*
*/
int
{
return (0);
if (uboot_address == 0)
return (1);
}
sp += API_SIG_MAGLEN;
}
return (0);
}
/****************************************
*
* console
*
****************************************/
int
ub_getc(void)
{
int c;
return (-1);
return (c);
}
int
ub_tstc(void)
{
int t;
return (-1);
return (t);
}
void
ub_putc(const char c)
{
}
void
ub_puts(const char *s)
{
}
/****************************************
*
* system
*
****************************************/
void
ub_reset(void)
{
}
struct sys_info *
ub_get_sys_info(void)
{
int err = 0;
return (NULL);
}
/****************************************
*
* timing
*
****************************************/
void
{
}
unsigned long
{
unsigned long cur;
return (0);
return (cur);
}
/****************************************************************************
*
* devices
*
* Devices are identified by handles: numbers 0, 1, 2, ..., UB_MAX_DEV-1
*
***************************************************************************/
struct device_info *
ub_dev_get(int i)
{
}
/*
* Enumerates the devices: fills out device_info elements in the devices[]
* array.
*
* returns: number of devices found
*/
int
ub_dev_enum(void)
{
int n = 0;
return (0);
if (++n >= UB_MAX_DEV)
break;
/* take another device_info */
di++;
/* pass on the previous cookie */
return (0);
}
return (n);
}
/*
* handle: 0-based id of the device
*
* returns: 0 when OK, err otherwise
*/
int
{
int err = 0;
return (API_EINVAL);
return (-1);
return (err);
}
int
{
return (API_EINVAL);
return (-1);
return (0);
}
/*
*
* - have sane handle
* - be opened
*
* returns: 0/1 accordingly
*/
static int
{
return (0);
return (0);
return (1);
}
static int
{
return (0);
return (0);
return (1);
}
int
{
int err = 0;
if (!dev_stor_valid(handle))
return (API_ENODEV);
return (API_ESYSC);
return (err);
}
static int
{
return (0);
return (0);
return (1);
}
int
{
if (!dev_net_valid(handle))
return (API_ENODEV);
return (API_ESYSC);
if (!err)
return (err);
}
int
{
int err = 0;
if (!dev_net_valid(handle))
return (API_ENODEV);
return (API_ESYSC);
return (err);
}
char *
{
if (type & DT_STOR_IDE)
return ("IDE");
if (type & DT_STOR_SCSI)
return ("SCSI");
if (type & DT_STOR_USB)
return ("USB");
if (type & DT_STOR_MMC)
return ("MMC");
if (type & DT_STOR_SATA)
return ("SATA");
return ("Unknown");
}
char *
{
switch (flags & 0x000F) {
case MR_ATTR_FLASH:
return ("FLASH");
case MR_ATTR_DRAM:
return ("DRAM");
case MR_ATTR_SRAM:
return ("SRAM");
default:
return ("Unknown");
}
}
void
{
int i;
printf(" hwaddr\t= ");
for (i = 0; i < 6; i++)
printf("\n");
}
}
void
{
int i;
printf("sys info:\n");
printf("---\n");
break;
printf("---\n");
}
}
/****************************************
*
* env vars
*
****************************************/
char *
{
char *value;
return (NULL);
return (value);
}
void
{
}
const char *
{
int i;
/*
* It's OK to pass only the name piece as last (and not the whole
* 'name=val' string), since the API_ENUM_ENV call uses envmatch()
* internally, which handles such case
*/
return (NULL);
/* no more env. variables to enumerate */
return (NULL);
/* next enumerated env var */
env_name[i] = '\0';
return (env_name);
}