Skip to content

Commit

Permalink
API for external applications.
Browse files Browse the repository at this point in the history
This is an API for external (standalone) applications running on top of
U-Boot, and is meant to be more extensible and robust than the existing
jumptable mechanism. It is similar to UNIX syscall approach. See api/README
for more details.

Included is the demo application using this new framework (api_examples).

Please note this is still an experimental feature, and is turned off by
default.

Signed-off-by: Rafal Jaworowski <[email protected]>
  • Loading branch information
semihalf-jaworowski-rafal committed Jan 9, 2008
1 parent 26a4179 commit 500856e
Show file tree
Hide file tree
Showing 18 changed files with 2,537 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ LIBS += $(shell if [ -d post/board/$(BOARDDIR) ]; then echo \
"post/board/$(BOARDDIR)/libpost$(BOARD).a"; fi)
LIBS += common/libcommon.a
LIBS += libfdt/libfdt.a
ifeq ($(CONFIG_API),y)
LIBS += api/libapi.a
endif

LIBS := $(addprefix $(obj),$(LIBS))
.PHONY : $(LIBS)
Expand All @@ -255,6 +258,10 @@ PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -
SUBDIRS = tools \
examples

ifeq ($(CONFIG_API),y)
SUBDIRS += api_examples
endif

.PHONY : $(SUBDIRS)

ifeq ($(CONFIG_NAND_U_BOOT),y)
Expand Down Expand Up @@ -2749,6 +2756,7 @@ clean:
rm -f $(obj)board/bf537-stamp/u-boot.lds $(obj)board/bf561-ezkit/u-boot.lds
rm -f $(obj)include/bmp_logo.h
rm -f $(obj)nand_spl/u-boot-spl $(obj)nand_spl/u-boot-spl.map
rm -f $(obj)api_examples/demo

clobber: clean
find $(OBJTREE) -type f \( -name .depend \
Expand All @@ -2762,6 +2770,8 @@ clobber: clean
rm -f $(obj)tools/inca-swap-bytes $(obj)cpu/mpc824x/bedbug_603e.c
rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
[ ! -d $(OBJTREE)/nand_spl ] || find $(obj)nand_spl -lname "*" -print | xargs rm -f
find $(obj)api_examples -lname "*" -print | xargs rm -f
rm -f $(obj)api_examples/demo

ifeq ($(OBJTREE),$(SRCTREE))
mrproper \
Expand Down
40 changes: 40 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# (C) Copyright 2007 Semihalf
#
# 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 Foundatio; 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 = $(obj)libapi.a

COBJS = api.o api_net.o api_storage.o api_platform-$(ARCH).o

SRCS := $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))

all: $(LIB)

$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)

# defines $(obj).depend target
include $(SRCTREE)/rules.mk

sinclude $(obj).depend
55 changes: 55 additions & 0 deletions api/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
U-Boot machine/arch independent API for external apps
=====================================================

1. Main assumptions

- there is a single entry point (syscall) to the API

- per current design the syscall is a C-callable function in the U-Boot
text, which might evolve into a real syscall using machine exception trap
once this initial version proves functional

- the consumer app is responsible for producing appropriate context (call
number and arguments)

- upon entry, the syscall dispatches the call to other (existing) U-Boot
functional areas like networking or storage operations

- consumer application will recognize the API is available by searching
a specified (assumed by convention) range of address space for the
signature

- the U-Boot integral part of the API is meant to be thin and non-intrusive,
leaving as much processing as possible on the consumer application side,
for example it doesn't keep states, but relies on hints from the app and
so on

- optional (CONFIG_API)


2. Calls

- console related (getc, putc, tstc etc.)
- system (reset, platform info)
- time (delay, current)
- env vars (enumerate all, get, set)
- devices (enumerate all, open, close, read, write); currently two classes
of devices are recognized and supported: network and storage (ide, scsi,
usb etc.)


3. Structure overview

- core API, integral part of U-Boot, mandatory
- implements the single entry point (mimics UNIX syscall)

- glue
- entry point at the consumer side, allows to make syscall, mandatory
part

- helper conveniency wrappers so that consumer app does not have to use
the syscall directly, but in a more friendly manner (a la libc calls),
optional part

- consumer application
- calls directly, or leverages the provided glue mid-layer
Loading

0 comments on commit 500856e

Please sign in to comment.