diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-12-01 09:51:44 +1100 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-12-01 09:51:44 +1100 |
commit | aaad509cdca2ed5f2c92a26f5279ec0e89c4fd5f (patch) | |
tree | dfffc0d8f3d21f6736b7f09219c95e2370052d8a /llfw/io_generic | |
download | SLOF-aaad509cdca2ed5f2c92a26f5279ec0e89c4fd5f.zip SLOF-aaad509cdca2ed5f2c92a26f5279ec0e89c4fd5f.tar.gz SLOF-aaad509cdca2ed5f2c92a26f5279ec0e89c4fd5f.tar.bz2 |
Initial import of slof-JX-1.7.0-4
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'llfw/io_generic')
-rw-r--r-- | llfw/io_generic/Makefile.inc | 38 | ||||
-rw-r--r-- | llfw/io_generic/io_generic.S | 129 |
2 files changed, 167 insertions, 0 deletions
diff --git a/llfw/io_generic/Makefile.inc b/llfw/io_generic/Makefile.inc new file mode 100644 index 0000000..b660725 --- /dev/null +++ b/llfw/io_generic/Makefile.inc @@ -0,0 +1,38 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + +IOGENERICDIR = $(LLFWCMNDIR)/io_generic + +IO_GENERIC_SRC_ASM = io_generic.S +IO_GENERIC_SRC_C = + +IO_GENERIC_SRCS = $(IO_GENERIC_SRC_ASM:%=$(IOGENERICDIR)/%) \ + $(IO_GENERIC_SRC_C:%=$(IOGENERICDIR)/%) +IO_GENERIC_OBJ_ASM = $(IO_GENERIC_SRC_ASM:%.S=%.o) +IO_GENERIC_OBJ_C = $(IO_GENERIC_SRC_C:%.c=%.o) + + +io_generic_lib.o: $(IO_GENERIC_OBJ_ASM) $(IO_GENERIC_OBJ_C) + $(LD) $(LDFLAGS) $^ -o $@ -r + + +%.o: $(IOGENERICDIR)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + +%.o: $(IOGENERICDIR)/%.S + $(CC) $(CPPFLAGS) $(ASFLAGS) -c $< -o $@ + + +LLFW_CLEAN_TARGETS += clean_io_generic +.PHONY : clean_io_generic +clean_io_generic: + rm -f $(IO_GENERIC_OBJ_C) $(IO_GENERIC_OBJ_ASM) io_generic_lib.o diff --git a/llfw/io_generic/io_generic.S b/llfw/io_generic/io_generic.S new file mode 100644 index 0000000..9c1db41 --- /dev/null +++ b/llfw/io_generic/io_generic.S @@ -0,0 +1,129 @@ +/****************************************************************************** + * Copyright (c) 2004, 2008 IBM Corporation + * All rights reserved. + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * IBM Corporation - initial implementation + *****************************************************************************/ +#include "macros.h" +#include "calculatecrc.h" +#include "calculatecrc.h" + + .text + +/**************************************************************************** + * prints a 0-terminated string to serial console + * + * Input: + * R3 - pointer to string in memory + * + * Returns: - + * + * Modifies Registers: + * R3, R4, R5, R6, R7, R8, R9 + ****************************************************************************/ +ASM_ENTRY(io_print) + mflr r8 + mr r9, r3 + +0: + lbz r3, 0(r9) + cmpwi r3, 0 + beq 1f + bl io_putchar + addi r9, r9, 1 + b 0b +1: + mtlr r8 + blr + +/**************************************************************************** + * prints Hex integer to the UART and the NVRAM (using board io_putchar) + * + * Input: + * R3 - integer to print + * + * Returns: - + * + * Modifies Registers: + * R3, R4, R5, R6, R7, R8, R9 + ****************************************************************************/ +#define _io_gen_print_nib(reg, src, shift) \ + srdi reg, src, shift; \ + andi. reg, reg, 0x0F; \ + cmpwi reg, 0x0A; \ + blt 0f; \ + addi reg, reg, ('A'-'0'-10); \ +0:; \ + addi reg, reg, '0'; \ + bl io_putchar + +ASM_ENTRY(io_printhex64) + mflr r8 + mr r9, r3 + +_io_printhex64: + _io_gen_print_nib(r3, r9, 60) + _io_gen_print_nib(r3, r9, 56) + _io_gen_print_nib(r3, r9, 52) + _io_gen_print_nib(r3, r9, 48) + _io_gen_print_nib(r3, r9, 44) + _io_gen_print_nib(r3, r9, 40) + _io_gen_print_nib(r3, r9, 36) + _io_gen_print_nib(r3, r9, 32) +_io_printhex32: + _io_gen_print_nib(r3, r9, 28) + _io_gen_print_nib(r3, r9, 24) + _io_gen_print_nib(r3, r9, 20) + _io_gen_print_nib(r3, r9, 16) +_io_printhex16: + _io_gen_print_nib(r3, r9, 12) + _io_gen_print_nib(r3, r9, 8) +_io_printhex8: + _io_gen_print_nib(r3, r9, 4) + _io_gen_print_nib(r3, r9, 0) + + mtlr r8 + blr + +ASM_ENTRY(io_printhex32) + mflr r8 + mr r9, r3 + b _io_printhex32 + +ASM_ENTRY(io_printhex16) + mflr r8 + mr r9, r3 + b _io_printhex16 + +ASM_ENTRY(io_printhex8) + mflr r8 + mr r9, r3 + b _io_printhex8 + + +/**************************************************************************** + * print the address and its contents as 64-bit hex values + * + * Input: + * R3 - Address to read from + * + * Returns: - + * + * Modifies Registers: + * R3, R4, R5, R6, R7, R8, R9, R10 + ****************************************************************************/ +#if 0 /* currently unused */ +ASM_ENTRY(io_dump) + mflr r10 + bl io_printhex64 + li r3,':' + bl io_putchar + ld r9,0(r9) + mr r8,r10 + b _io_printhex64 +#endif |