1176481Smarcel/*-
2176481Smarcel * Copyright (c) 2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
3176481Smarcel * All rights reserved.
4176481Smarcel *
5176481Smarcel * Redistribution and use in source and binary forms, with or without
6176481Smarcel * modification, are permitted provided that the following conditions
7176481Smarcel * are met:
8176481Smarcel * 1. Redistributions of source code must retain the above copyright
9176481Smarcel *    notice, this list of conditions and the following disclaimer.
10176481Smarcel * 2. Redistributions in binary form must reproduce the above copyright
11176481Smarcel *    notice, this list of conditions and the following disclaimer in the
12176481Smarcel *    documentation and/or other materials provided with the distribution.
13176481Smarcel *
14176481Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15176481Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16176481Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17176481Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18176481Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19176481Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20176481Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21176481Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22176481Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23176481Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24176481Smarcel * SUCH DAMAGE.
25176481Smarcel *
26176481Smarcel * $FreeBSD: releng/11.0/sys/boot/uboot/lib/glue.h 296564 2016-03-09 11:45:48Z sgalabov $
27176481Smarcel */
28176481Smarcel
29176481Smarcel/*
30176481Smarcel * This is the header file for conveniency wrapper routines (API glue)
31176481Smarcel */
32176481Smarcel
33176481Smarcel#ifndef _API_GLUE_H_
34176481Smarcel#define _API_GLUE_H_
35176481Smarcel
36182723Sraj#include "api_public.h"
37182723Sraj
38296182Ssgalabov/*
39296182Ssgalabov * Mask used to align the start address for API signature search to 1MiB
40296182Ssgalabov */
41296182Ssgalabov#define	API_SIG_SEARCH_MASK	~0x000fffff
42296182Ssgalabov
43296182Ssgalabov#ifdef __mips__
44296182Ssgalabov/*
45296182Ssgalabov * On MIPS, U-Boot passes us a hint address, which is very close to the end of
46296182Ssgalabov * RAM (less than 1MiB), so searching for the API signature within more than
47296182Ssgalabov * that leads to exception.
48296182Ssgalabov */
49296182Ssgalabov#define	API_SIG_SEARCH_LEN	0x00100000
50296182Ssgalabov#else
51296182Ssgalabov/*
52296182Ssgalabov * Search for the API signature within 3MiB of the 1MiB-aligned address that
53296182Ssgalabov * U-Boot has hinted us.
54296182Ssgalabov */
55296182Ssgalabov#define	API_SIG_SEARCH_LEN	0x00300000
56296182Ssgalabov#endif
57296182Ssgalabov
58182732Srajint syscall(int, int *, ...);
59182732Srajvoid *syscall_ptr;
60176481Smarcel
61296564Ssgalabovint api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig);
62182732Srajint api_search_sig(struct api_signature **sig);
63176481Smarcel
64280194Sian#define	UB_MAX_MR	16		/* max mem regions number */
65183598Sraj#define	UB_MAX_DEV	6		/* max devices number */
66183598Sraj
67176481Smarcel/*
68176481Smarcel * The ub_ library calls are part of the application, not U-Boot code!  They
69176481Smarcel * are front-end wrappers that are used by the consumer application: they
70176481Smarcel * prepare arguments for particular syscall and jump to the low level
71176481Smarcel * syscall()
72176481Smarcel */
73176481Smarcel
74176481Smarcel/* console */
75182732Srajint ub_getc(void);
76182732Srajint ub_tstc(void);
77183599Srajvoid ub_putc(char);
78183599Srajvoid ub_puts(const char *);
79176481Smarcel
80176481Smarcel/* system */
81182732Srajvoid ub_reset(void);
82182723Srajstruct sys_info *ub_get_sys_info(void);
83176481Smarcel
84176481Smarcel/* time */
85182732Srajvoid ub_udelay(unsigned long);
86182732Srajunsigned long ub_get_timer(unsigned long);
87176481Smarcel
88176481Smarcel/* env vars */
89183599Srajchar *ub_env_get(const char *);
90183599Srajvoid ub_env_set(const char *, char *);
91183599Srajconst char *ub_env_enum(const char *);
92176481Smarcel
93176481Smarcel/* devices */
94182732Srajint ub_dev_enum(void);
95183599Srajint ub_dev_open(int);
96183599Srajint ub_dev_close(int);
97183599Srajint ub_dev_read(int, void *, lbasize_t, lbastart_t, lbasize_t *);
98183599Srajint ub_dev_send(int, void *, int);
99183599Srajint ub_dev_recv(int, void *, int, int *);
100183599Srajstruct device_info *ub_dev_get(int);
101176481Smarcel
102182732Srajvoid ub_dump_di(int);
103182732Srajvoid ub_dump_si(struct sys_info *);
104182732Srajchar *ub_mem_type(int);
105185099Srajchar *ub_stor_type(int);
106182732Sraj
107176481Smarcel#endif /* _API_GLUE_H_ */
108