freemyipod r719 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r718‎ | r719 | r720 >
Date:21:19, 29 June 2011
Author:theseven
Status:new
Tags:
Comment:
New app: fastboot-of
Modified paths:
  • /apps/fastboot-of (added) (history)
  • /apps/fastboot-of/Makefile (added) (history)
  • /apps/fastboot-of/SOURCES (added) (history)
  • /apps/fastboot-of/ls.x (added) (history)
  • /apps/fastboot-of/main.c (added) (history)
  • /apps/fastboot-of/version.h (added) (history)

Diff [purge]

Index: apps/fastboot-of/SOURCES
@@ -0,0 +1 @@
 2+main.c
Index: apps/fastboot-of/ls.x
@@ -0,0 +1,42 @@
 2+ENTRY(__emcore_entrypoint)
 3+OUTPUT_FORMAT(elf32-littlearm)
 4+OUTPUT_ARCH(arm)
 5+
 6+MEMORY
 7+{
 8+ VIRTUAL : ORIGIN = 0x00000000, LENGTH = 0x10000000
 9+}
 10+
 11+SECTIONS
 12+{
 13+ .text :
 14+ {
 15+ __emcore_app_base = .;
 16+ KEEP(.emcoreentrypoint*)
 17+ *(.emcoreentrypoint*)
 18+ *(.text*)
 19+ *(.glue_7)
 20+ *(.glue_7t)
 21+ . = ALIGN(0x10);
 22+ } > VIRTUAL
 23+
 24+ .data :
 25+ {
 26+ *(.rodata*)
 27+ . = ALIGN(0x4);
 28+ *(.data*)
 29+ . = ALIGN(0x10);
 30+ } > VIRTUAL
 31+
 32+ .bss (NOLOAD) :
 33+ {
 34+ *(.bss*)
 35+ *(COMMON)
 36+ } > VIRTUAL
 37+
 38+ /DISCARD/ :
 39+ {
 40+ *(.eh_frame)
 41+ }
 42+
 43+}
Index: apps/fastboot-of/main.c
@@ -0,0 +1,56 @@
 2+//
 3+//
 4+// Copyright 2011 TheSeven
 5+//
 6+//
 7+// This file is part of emCORE.
 8+//
 9+// emCORE is free software: you can redistribute it and/or
 10+// modify it under the terms of the GNU General Public License as
 11+// published by the Free Software Foundation, either version 2 of the
 12+// License, or (at your option) any later version.
 13+//
 14+// emCORE is distributed in the hope that it will be useful,
 15+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 17+// See the GNU General Public License for more details.
 18+//
 19+// You should have received a copy of the GNU General Public License along
 20+// with emCORE. If not, see <http://www.gnu.org/licenses/>.
 21+//
 22+//
 23+
 24+
 25+#include "emcoreapp.h"
 26+#include "libboot.h"
 27+
 28+
 29+static void main()
 30+{
 31+ void* firmware = NULL;
 32+ int size;
 33+ struct emcorelib_header* lib = get_library(LIBBOOT_IDENTIFIER, LIBBOOT_API_VERSION, LIBSOURCE_BOOTFLASH, "libboot ");
 34+ if (!lib) panicf(PANIC_KILLTHREAD, "Could not load libboot");
 35+ struct libboot_api* boot = (struct libboot_api*)lib->api;
 36+ if (!(clickwheel_get_state() & 0x1f))
 37+ {
 38+ boot->load_from_file(&firmware, &size, false, "/.boot/appleos.ucl", 0x800000);
 39+ if (!firmware) boot->load_from_file(&firmware, &size, false, "/.boot/appleos.bin", 0);
 40+ }
 41+ if (firmware)
 42+ {
 43+ release_library(lib);
 44+ library_unload(lib);
 45+ shutdown(false);
 46+ execfirmware((void*)0x08000000, firmware, size);
 47+ }
 48+ else
 49+ {
 50+ boot->load_from_flash(&firmware, &size, false, "bootmenu", 0);
 51+ if (!firmware || execimage(firmware, false) == NULL)
 52+ panic(PANIC_KILLTHREAD, "Failed to launch boot menu");
 53+ }
 54+}
 55+
 56+
 57+EMCORE_APP_HEADER("Fastboot launcher for OF", main, 127)
Index: apps/fastboot-of/version.h
@@ -0,0 +1,36 @@
 2+//
 3+//
 4+// Copyright 2010 TheSeven
 5+//
 6+//
 7+// This file is part of emCORE.
 8+//
 9+// emCORE is free software: you can redistribute it and/or
 10+// modify it under the terms of the GNU General Public License as
 11+// published by the Free Software Foundation, either version 2 of the
 12+// License, or (at your option) any later version.
 13+//
 14+// emCORE is distributed in the hope that it will be useful,
 15+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 17+// See the GNU General Public License for more details.
 18+//
 19+// You should have received a copy of the GNU General Public License along
 20+// with emCORE. If not, see <http://www.gnu.org/licenses/>.
 21+//
 22+//
 23+
 24+
 25+#ifndef __VERSION_H__
 26+#define __VERSION_H__
 27+
 28+
 29+#define VERSION "0.1.1"
 30+#define VERSION_MAJOR 0
 31+#define VERSION_MINOR 1
 32+#define VERSION_PATCH 1
 33+#define VERSION_SVN "$REVISION$"
 34+#define VERSION_SVN_INT $REVISIONINT$
 35+
 36+
 37+#endif
\ No newline at end of file
Index: apps/fastboot-of/Makefile
@@ -0,0 +1,121 @@
 2+NAME := fastboot-of
 3+STACKSIZE := 4096
 4+COMPRESS := true
 5+
 6+EMCOREDIR ?= ../../emcore/trunk/
 7+LIBBOOTDIR ?= ../../libs/boot/
 8+
 9+ifeq ($(shell uname),WindowsNT)
 10+CCACHE :=
 11+else
 12+CCACHE := $(shell which ccache)
 13+endif
 14+
 15+CROSS ?= arm-elf-eabi-
 16+CC := $(CCACHE) $(CROSS)gcc
 17+AS := $(CROSS)as
 18+LD := $(CROSS)ld
 19+OBJCOPY := $(CROSS)objcopy
 20+ELF2ECA := $(CROSS)elf2emcoreapp
 21+
 22+LIBINCLUDES := -I$(LIBBOOTDIR)/export
 23+
 24+CFLAGS += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMCOREDIR)/export $(LIBINCLUDES) -ffunction-sections -fdata-sections -mcpu=arm940t -DARM_ARCH=4
 25+LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --emit-relocs --gc-sections
 26+
 27+preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
 28+preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
 29+
 30+REVISION := $(shell svnversion .)
 31+REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
 32+
 33+HELPERS := build/__emcore_armhelpers.o
 34+
 35+SRC := $(call preprocesspaths,SOURCES,-I. -I..)
 36+OBJ := $(SRC:%.c=build/%.o)
 37+OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
 38+
 39+all: $(NAME)
 40+
 41+-include $(OBJ:%=%.dep)
 42+
 43+$(NAME): build/$(NAME).emcoreapp
 44+
 45+build/$(NAME).emcoreapp: build/$(NAME).elf
 46+ @echo [EMCAPP] $<
 47+ifeq ($(COMPRESS),true)
 48+ @$(ELF2ECA) -z -s $(STACKSIZE) -o $@ $^
 49+else
 50+ @$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
 51+endif
 52+
 53+build/$(NAME).elf: ls.x $(OBJ)
 54+ @echo [LD] $@
 55+ @$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
 56+
 57+build/%.o: %.c build/version.h
 58+ @echo [CC] $<
 59+ifeq ($(shell uname),WindowsNT)
 60+ @-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
 61+else
 62+ @-mkdir -p $(dir $@)
 63+endif
 64+ @$(CC) -c $(CFLAGS) -o $@ $<
 65+ @$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
 66+ @sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
 67+ifeq ($(shell uname),WindowsNT)
 68+ @sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
 69+else
 70+ @sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
 71+endif
 72+ @rm -f $@.dep.tmp
 73+
 74+build/%.o: %.S build/version.h
 75+ @echo [CC] $<
 76+ifeq ($(shell uname),WindowsNT)
 77+ @-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
 78+else
 79+ @-mkdir -p $(dir $@)
 80+endif
 81+ @$(CC) -c $(CFLAGS) -o $@ $<
 82+ @$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
 83+ @sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
 84+ifeq ($(shell uname),WindowsNT)
 85+ @sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
 86+else
 87+ @sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
 88+endif
 89+ @rm -f $@.dep.tmp
 90+
 91+build/__emcore_%.o: $(EMCOREDIR)/export/%.c
 92+ @echo [CC] $<
 93+ifeq ($(shell uname),WindowsNT)
 94+ @-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
 95+else
 96+ @-mkdir -p $(dir $@)
 97+endif
 98+ @$(CC) -c $(CFLAGS) -o $@ $<
 99+
 100+build/__emcore_%.o: $(EMCOREDIR)/export/%.S
 101+ @echo [CC] $<
 102+ifeq ($(shell uname),WindowsNT)
 103+ @-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
 104+else
 105+ @-mkdir -p $(dir $@)
 106+endif
 107+ @$(CC) -c $(CFLAGS) -o $@ $<
 108+
 109+build/version.h: version.h .svn/entries
 110+ @echo [PP] $<
 111+ifeq ($(shell uname),WindowsNT)
 112+ @-if not exist build md build
 113+ @sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
 114+else
 115+ @-mkdir -p build
 116+ @sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
 117+endif
 118+
 119+clean:
 120+ @rm -rf build
 121+
 122+.PHONY: all clean $(NAME)
Index: apps/fastboot-of
Property changes on: apps/fastboot-of
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
 123+build