From 9e80202352dd49bdd9e67b8b906d86f058431505 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 11 May 2019 15:12:49 -0500 Subject: Initial import of abandoned HQEMU version 2.5.2 --- src/roms/SLOF/llfw/boot_abort.S | 95 ++++++++ src/roms/SLOF/llfw/boot_abort.h | 37 +++ src/roms/SLOF/llfw/clib/Makefile.inc | 42 ++++ src/roms/SLOF/llfw/clib/iolib.c | 47 ++++ src/roms/SLOF/llfw/clib/iolib.h | 26 +++ src/roms/SLOF/llfw/io_generic/Makefile.inc | 38 +++ src/roms/SLOF/llfw/io_generic/io_generic.S | 129 ++++++++++ src/roms/SLOF/llfw/nvramlog.S | 350 ++++++++++++++++++++++++++++ src/roms/SLOF/llfw/romfs.S | 362 +++++++++++++++++++++++++++++ src/roms/SLOF/llfw/romfs_wrap.c | 22 ++ 10 files changed, 1148 insertions(+) create mode 100644 src/roms/SLOF/llfw/boot_abort.S create mode 100644 src/roms/SLOF/llfw/boot_abort.h create mode 100644 src/roms/SLOF/llfw/clib/Makefile.inc create mode 100644 src/roms/SLOF/llfw/clib/iolib.c create mode 100644 src/roms/SLOF/llfw/clib/iolib.h create mode 100644 src/roms/SLOF/llfw/io_generic/Makefile.inc create mode 100644 src/roms/SLOF/llfw/io_generic/io_generic.S create mode 100644 src/roms/SLOF/llfw/nvramlog.S create mode 100644 src/roms/SLOF/llfw/romfs.S create mode 100644 src/roms/SLOF/llfw/romfs_wrap.c (limited to 'src/roms/SLOF/llfw') diff --git a/src/roms/SLOF/llfw/boot_abort.S b/src/roms/SLOF/llfw/boot_abort.S new file mode 100644 index 0000000..996bdd7 --- /dev/null +++ b/src/roms/SLOF/llfw/boot_abort.S @@ -0,0 +1,95 @@ +/****************************************************************************** + * 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 "termctrl.h" +#include "boot_abort.h" +#include + +#define MSG_LOOK_HDR TERM_CTRL_BRIGHT, TERM_BG_RED, TERM_FG_WHITE + +ASM_ENTRY(msg_e_crc) + .ascii MSG_LOOK_HDR + .ascii "\n\r\n\rE1001 - Boot ROM CRC failure\n\r" + .ascii TERM_CTRL_RESET, "\0" + .align 2 + +ASM_ENTRY(msg_e_nomem) + .ascii MSG_LOOK_HDR + .ascii "\n\r\n\rE1002 - Memory could not be initialized\n\r" + .ascii TERM_CTRL_RESET, "\0" + .align 2 + +ASM_ENTRY(msg_e_nofile) + .ascii MSG_LOOK_HDR + .ascii "\n\r\n\rE1003 - Firmware image incomplete" + .ascii TERM_CTRL_RESET + .ascii "\n\r internal FLS1-FFS-0.\0" + .align 2 + +ASM_ENTRY(msg_e_ierror) + .ascii MSG_LOOK_HDR + .ascii "\n\r\n\rE1004 - Unspecified Internal Firmware Error" + .ascii TERM_CTRL_RESET + .ascii "\n\r internal FLSX-SE-0.\0" + .align 2 + +/* E1005 : used in memory init code */ + +/***************************************************************************** + * Boot Abort Handler + * + * Input: + * R3 - capability informatin (i/o etc.) + * R4 - handling suggestion + * R5 - error string reference + * R6 - error number + * + * Return: + * if possible input to H8 and NVRAM log and console , then reboot/halt + * + * Input definitions: + * + * R3 bits: 63 (h8/console possible) ... add more + * R4 bits: 63 (do not attempt reboot) + * R5 reference to error message string + * R6 32-bit error enumerator + * + ******************************************************************************/ +ASM_ENTRY(boot_abort) + /* save arguments */ + mr r31, r3 + mr r30, r4 + mr r29, r5 + mr r28, r6 + + /* check if i/o is possible, if yes then print message */ + li r10, ABORT_CANIO + andi. r3, r31, r10 + bne abort_noio + + /* use i/o ..., first print reference message */ + /* then add internal number if != 0 */ + mr r3, r29 + mfspr r4, HSPRG0 /* get runbase */ + or r3, r3, r4 + bl io_print + mr r3, r28 + li r28, 0 + cmpd r3, r28 + beq 0f + bl io_printhex32 +0: + + abort_noio: + b $ // FIXME + /* never reached */ + diff --git a/src/roms/SLOF/llfw/boot_abort.h b/src/roms/SLOF/llfw/boot_abort.h new file mode 100644 index 0000000..b708206 --- /dev/null +++ b/src/roms/SLOF/llfw/boot_abort.h @@ -0,0 +1,37 @@ +/****************************************************************************** + * 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 + *****************************************************************************/ +#ifndef BOOT_ABORT_H +#define BOOT_ABORT_H + +/* boot abort function suitable for assembly */ +#define BOOT_ABORT(cap, action, msg, numhint) \ + li r3, cap; \ + li r4, action; \ + LOAD32(r5, msg); \ + LOAD32(r6, numhint); \ + bl boot_abort + +/* boot abort function suitable called from c (takes r3 as hint) */ +#define BOOT_ABORT_R3HINT(cap, action, msg) \ + mr r6, r3; \ + li r3, cap; \ + li r4, action; \ + LOAD32(r5, msg); \ + bl boot_abort + +#define ABORT_CANIO (1 << 0) +#define ABORT_NOIO (1 << 1) + +#define ALTBOOT (1 << 0) +#define HALT (1 << 1) + +#endif diff --git a/src/roms/SLOF/llfw/clib/Makefile.inc b/src/roms/SLOF/llfw/clib/Makefile.inc new file mode 100644 index 0000000..7003798 --- /dev/null +++ b/src/roms/SLOF/llfw/clib/Makefile.inc @@ -0,0 +1,42 @@ +# ***************************************************************************** +# * 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 ../../make.rules + +CFLAGS_COMLIB = -pedantic -std=gnu99 -O0 +ASFLAGS_COMLIB = + + +COMLIBDIR = $(LLFWCMNDIR)/clib + +COMLIB_SRC_ASM = +COMLIB_SRC_C = iolib.c + +COMLIB_SRCS = $(COMLIB_SRC_ASM:%=$(COMLIBDIR)/%) \ + $(COMLIB_SRC_C:%=$(COMLIBDIR)/%) +COMLIB_OBJ_ASM = $(COMLIB_SRC_ASM:%.S=%.o) +COMLIB_OBJ_C = $(COMLIB_SRC_C:%.c=%.o) + + +comlib.o: $(COMLIB_OBJ_C) $(COMLIB_OBJ_ASM) + $(LD) $(LDFLAGS) $^ -o $@ -r + +%.o: $(LLFWCMNDIR)/clib/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_COMLIB) -c $< -o $@ + +%.o: $(LLFWCMNDIR)/clib/%.S + $(CC) $(CPPFLAGS) $(ASFLAGS) $(ASFLAGS_COMLIB) -c $< -o $@ + +LLFW_CLEAN_TARGETS += clean_clib +.PHONY : clean_clib +clean_clib: + rm -f $(COMLIB_OBJ_C) $(COMLIB_OBJ_ASM) comlib.o diff --git a/src/roms/SLOF/llfw/clib/iolib.c b/src/roms/SLOF/llfw/clib/iolib.c new file mode 100644 index 0000000..7f14b51 --- /dev/null +++ b/src/roms/SLOF/llfw/clib/iolib.c @@ -0,0 +1,47 @@ +/****************************************************************************** + * 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 +#include +#include +#include "iolib.h" + +void uart_send_byte(unsigned char b) +{ + asm volatile ("":::"3","4","5","6","7"); + io_putchar(b); +} + +/** + * Standard write function for the libc. + * + * @param fd file descriptor (should always be 1 or 2) + * @param buf pointer to the array with the output characters + * @param count number of bytes to be written + * @return the number of bytes that have been written successfully + */ +ssize_t write(int fd, const void *buf, size_t count) +{ + size_t i; + char *ptr = (char *)buf; + + if (fd != 1 && fd != 2) + return 0; + + for (i = 0; i < count; i++) { + if (*ptr == '\n') + uart_send_byte('\r'); + uart_send_byte(*ptr++); + } + + return i; +} diff --git a/src/roms/SLOF/llfw/clib/iolib.h b/src/roms/SLOF/llfw/clib/iolib.h new file mode 100644 index 0000000..9145005 --- /dev/null +++ b/src/roms/SLOF/llfw/clib/iolib.h @@ -0,0 +1,26 @@ +/****************************************************************************** + * 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 + *****************************************************************************/ + +#ifndef IOLIB_H +#define IOLIB_H + +#include + +#define addr_t volatile unsigned int +#define addr8_t volatile unsigned char + +extern void halt_sys (unsigned int); + +extern void uart_send_byte(unsigned char b); +extern void io_putchar(unsigned char); + +#endif diff --git a/src/roms/SLOF/llfw/io_generic/Makefile.inc b/src/roms/SLOF/llfw/io_generic/Makefile.inc new file mode 100644 index 0000000..b660725 --- /dev/null +++ b/src/roms/SLOF/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/src/roms/SLOF/llfw/io_generic/io_generic.S b/src/roms/SLOF/llfw/io_generic/io_generic.S new file mode 100644 index 0000000..9c1db41 --- /dev/null +++ b/src/roms/SLOF/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 diff --git a/src/roms/SLOF/llfw/nvramlog.S b/src/roms/SLOF/llfw/nvramlog.S new file mode 100644 index 0000000..3ad2de7 --- /dev/null +++ b/src/roms/SLOF/llfw/nvramlog.S @@ -0,0 +1,350 @@ +/****************************************************************************** + * 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 +#include +#include +#include + +#if !defined(DISABLE_NVRAM) && !defined(RTAS_NVRAM) + +// detect overflow: if(a sum + addi r5, r5, 1 // new sum ++ + rldicl r5, r5, 0, 56 +.L5: + mr r3,r5 // sum = new sum + blt+ 6,.L6 + + mr r4, r6 + blr + +#else /* defined(DISABLE_NVRAM) || defined(RTAS_NVRAM) */ + +ASM_ENTRY(.writeNVRAMbyte) + ENTRY(writeLogByte) + blr + +#endif diff --git a/src/roms/SLOF/llfw/romfs.S b/src/roms/SLOF/llfw/romfs.S new file mode 100644 index 0000000..325f79e --- /dev/null +++ b/src/roms/SLOF/llfw/romfs.S @@ -0,0 +1,362 @@ +/****************************************************************************** + * 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 "romfs.h" + +/******************************************************************* + * Wrapper for romfs_lookup. + * + * Input: + * R3 = address of filename string + * R4 = address of struct romfs_t + * 0: file size (return) + * 8: flags (return) + * 10: fileaddr (return and input: tells if first search) + * 18: nextfile (return) + * 20: namep (return) + * + * Find File Procedure + * - set filename and rombase, on return 0 file properties are stored + * in romfs_t else struct not valid + * + * Listing procedure + * - clear romfs_t (important!) + * - set filename = NULL and rombase and call returns first file + * with properties in romfs_t including next-file pointer + * - if nextpointer is non-zero then just the next file is returned + * + * Returns: + * : + * R3 = 0 + * romfs_t is updated + * : + * R3 = 1 + * romfs_t not touched + * + * Potentially modifies the following registers: + * + + Example usage from C: + + int list_bootrom() + { + struct romfs_t rfs; + int i; + + printf("Build: "__TIME__" "__DATE__" \n"); + + i = 0; + memset((void*) &rfs, 0, sizeof(struct romfs_t)); + printf(" No. File Data Size Name\n"); + + while (romfs_stat(NULL, &rfs) == 0) { + i++; + printf(" %02d: %08X %08X %7d %s\n", + i, rfs.fileaddr, rfs.datap, + rfs.size, rfs.namep); + } + if (0 == i) { + printf("Error in reading ROMFS\n"); + return 1; + } + return 0; + } + *******************************************************************/ +#define RFS_T_SIZE 0x00 +#define RFS_T_FLAGS 0x08 +#define RFS_T_FILEADDR 0x10 +#define RFS_T_NEXT 0x18 +#define RFS_T_NAME 0x20 +#define RFS_T_DATA 0x28 + +#define RFS_H_NEXT 0x00 +#define RFS_H_SIZE 0x08 +#define RFS_H_FLAGS 0x10 +#define RFS_H_DATA 0x18 +#define RFS_H_NAME 0x20 + +ENTRY(romfs_stat_file) + /* save link register and romfs_t pointer */ + mflr r15 + mr r16, r4 + + /* if filename R3 is 0 then its a listing request */ + /* if not then just continue to lookup name */ + /* save R4 to R8 which is the address of header */ + li r7, 0 + cmpd r3, r7 + beq romfs_list + bl romfs_lookup + mfsprg r8, 1 + + /* if file found then go to romfs_fill_properties */ + /* else return 1 to caller */ + cmpwi r3, 0 + beq romfs_fill_properties + b romfs_stat_end + + romfs_list: + /* check if fileaddr == 0, in this case its */ + /* the first search on this handle, so return all */ + /* info for file at rombase (R8=R4) */ + ld r6, RFS_T_FILEADDR(r4) + mfsprg r8, 1 + li r7, 0 + cmpd r7, r6 + beq romfs_fill_properties + + /* check if next file != 0 by looking into */ + /* romfs_t, if not then return (next = 0) 1 */ + li r7, 0 + ld r4, RFS_T_NEXT(r4) + cmpd r7, r4 + li r3, 1 + beq romfs_stat_end + + /* now next file is available so move R8 to next */ + /* file address */ + mr r8, r4 + + romfs_fill_properties: + /* set properties in romfs_t takes R8 as address */ + /* to file header and R16 as address of romfs_t */ + mfsprg r3, 1 + std r8, RFS_T_FILEADDR(r16) + + ld r4, RFS_H_NEXT(r8) + li r7, 0 + cmpd r7, r4 + beq $ + (2 * 4) /* =0 so add no rombase */ + add r4, r4, r3 + std r4, RFS_T_NEXT(r16) + + ld r4, RFS_H_SIZE(r8) + std r4, RFS_T_SIZE(r16) + ld r4, RFS_H_FLAGS(r8) + std r4, RFS_T_FLAGS(r16) + + ld r4, RFS_H_DATA(r8) + add r4, r4, r3 + std r4, RFS_T_DATA(r16) + + addi r4, r8, RFS_H_NAME + std r4, RFS_T_NAME(r16) + + li r3, 0 + + /* restore romfs_t pointer and link register */ + romfs_stat_end: + mr r5, r16 + mtlr r15 + blr + +/******************************************************************* + * Copies the data of file referenced by name string to address + * requires root address of filesystem. + * FIXME: ignores flags + * + * Input: + * R3 = address of filename string + * R4 = ROMBASE + * R5 = destination address + * + * Returns: + * : R3 = 0, R6 = size, : R3 = 1 + * R5 is kept + * + * Potentially modifies the following registers: + * ctr, r15, r16, r17, r18 + * + * Uses the following calls with subsequent register modification: + * - romfs_lookup + *******************************************************************/ +ASM_ENTRY(romfs_load) + mflr r15 + + /* save R5 twice */ + /* lookup file, input regs */ + /* are already set */ + /* if not found, just return */ + mr r16, r5 + mr r17, r5 + bl romfs_lookup + cmpwi r3, 1 + bne 0f + mtlr r15 + blr /* abort, not found */ + + /* save data size for return */ + /* found, copy data */ + /* data size is in R6 */ +0: + //mr r3, r6 + mtctr r6 + addi r16, r16, -1 /* dest */ + addi r5, r5, -1 /* source*/ + + /* data is expected to be */ + /* 8 byte aligned */ + /* copy loop */ +0: lbzu r18, 1(r5) + stbu r18, 1(r16) + bdnz 0b + + /* restore size, keep padding */ + /* restore target address */ + /* return */ + mr r5, r17 + mtlr r15 + blr + +/******************************************************************* + * looks up a file based on filename + * + * Input: + * R3 = address of filename string + * R4 = ROMBASE + * + * Returns: + * : + * R3 = 0 + * R4 = address of file header + * R5 = address of data (real address) + * R6 = size of data + * R7 = flags for file + * : + * R3 = 1 + * + * Potentially modifies the following registers: + * R3, R4, R5, R6, R7, R8, R9 + * + * Uses the following calls with subsequent register modification: + * - romfs_namematch + *******************************************************************/ +ASM_ENTRY(romfs_lookup) + mflr r9 + + romfs_lookup_next: + /* save current file base */ + mr r8, r4 + /* name to look for */ + mr r10, r3 + /* name of file */ + mr r5, r4 + addi r5, r5, (4 /* elems */ * 8 /* elem-size */) + mr r11, r5 /* for namematch */ + /* compare */ + bl romfs_namematch + cmpwi r12, 1 + bne romfs_lookup_match + + /* load next pointer */ + /* check if next is 0 */ + /* apply root-offset */ + ld r5, 0(r4) + cmpwi r5, 0 + add r4, r4, r5 + bne romfs_lookup_next + /* last file reached, abort */ + li r3, 1 + mtlr r9 + blr + + /* here the name did match */ + /* r4 is still usable here and */ + /* pointing to the initial file */ + /* load r5 with data ptr */ + /* load r6 with data size */ + /* load r7 with flags */ + /* get abs addr of data */ + romfs_lookup_match: + li r3, 0 + ld r5, (3 * 8)(r4) /* data */ + ld r6, (1 * 8)(r4) /* len */ + ld r7, (2 * 8)(r4) /* flags */ + add r5, r5, r8 + mtlr r9 + blr + +/******************************************************************* + * compares two strings in memory, + * both must be null-terminated and 8-byte aligned + * + * Input: + * R10 = string 1 + * R11 = string 2 + * + * Returns: + * : R12 = 0 : R12 = 1 + * + * Potentially modifies the following registers: + * R10, R11, r12, r13, r14 + *******************************************************************/ +romfs_namematch: + subi r10, r10, 8 + subi r11, r11, 8 + + /* + * load chars as 8byte chunk from current pos, name is + * always 8 byte aligned :) + */ + romfs_cmp_loop: + ldu r13, 8(r10) /* A */ + ldu r14, 8(r11) /* B */ + + cmpd r13, r14 + li r12, 1 + beq 1f + blr + +1: andi. r14, r14, 0xff + bne romfs_cmp_loop + + li r12, 0 + blr + +/******************************************************************* + * wrapper for romfs_lookup + * this function saves the registers from r13 - r15 on the stack + * calls romfs_lookup + * restores the saved registers + * + * the return parameters are copied to (r5) and (r5) has to + * be 0x20 big + *******************************************************************/ +ENTRY(c_romfs_lookup) + stdu r1,-0x50(r1) # allocate space on stack + + mflr r0 # save link register + std r0,0x30(r1) + + std r15,0x38(r1) # save r15 + std r14,0x40(r1) # save r14 + std r13,0x48(r1) # and r13 + + mr r15,r5 # save the pointer for the return value + + bl romfs_lookup # do the thing + + ld r0,0x30(r1) # restore link register + mtlr r0 + + std r4,0x00(r15) # copy return values + std r5,0x08(r15) # to the return pointer + std r6,0x10(r15) + std r7,0x18(r15) + + ld r13,0x48(r1) # restore registers from stack + ld r14,0x40(r1) + ld r15,0x38(r1) + + addi r1,r1,0x50 # cleanup stack + + blr diff --git a/src/roms/SLOF/llfw/romfs_wrap.c b/src/roms/SLOF/llfw/romfs_wrap.c new file mode 100644 index 0000000..323d975 --- /dev/null +++ b/src/roms/SLOF/llfw/romfs_wrap.c @@ -0,0 +1,22 @@ +/****************************************************************************** + * 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 + +int romfs_stat(char *filename, struct romfs_t *hnd) +{ + asm volatile ("":::"3","4","5","6","7","9","10"); + asm volatile ("":::"11","12"); + asm volatile ("":::"13","14","15","16","17","18"); + + return romfs_stat_file(filename, hnd); +} -- cgit v1.1