Read about our upcoming Code of Conduct on this issue

Commit b2b56ebe authored by hudson@kremvax.wan's avatar hudson@kremvax.wan
Browse files

Canon firmware 2.0.3 support

- Use the gcc stdio library for common string functions
- Disable everything except early boot code for initial testing
- Find more functions in 2.0.3
parent bfe7b475c9e0
/** \file
* Code to run on the 5D once it has been relocated.
*
* This has been updated to work with the 1.1.0 firmware.
* IT DOES NOT WORK WITH 1.0.7 ANY MORE!
* This has been updated to work with the 2.0.3 firmware.
* IT DOES NOT WORK WITH 1.1.0 NOR 1.0.7 ANY MORE!
*/
/*
* Copyright (C) 2009 Trammell Hudson <hudson+ml@osresearch.net>
......@@ -31,6 +31,9 @@
#include "menu.h"
#include "version.h"
/** If CONFIG_EARLY_PORT is defined, only a few things will be enabled */
#define CONFIG_EARLY_PORT
/** These are called when new tasks are created */
void my_task_dispatch_hook( struct context ** );
void my_init_task(void);
......@@ -76,9 +79,10 @@ copy_and_restart( void )
blob_memcpy( new_image, firmware_start, firmware_start + firmware_len );
/*
* in entry2() (0xff812a98) make this change:
*/
// Return to our code before calling cstart()
* in entry2() (0xff812a98) make this change to
* return to our code before calling cstart().
* This should be a "BL cstart" instruction.
*/
INSTR( 0xFF812AE8 ) = RET_INSTR;
......@@ -86,6 +90,7 @@ copy_and_restart( void )
* in cstart() (0xff810894) make these changes:
*/
// Reserve memory after the BSS for our application
// should be a pointer to 0x4d458 or thereabouts
INSTR( 0xFF81093C ) = (uintptr_t) _bss_end;
// Fix the calls to bzero32() and create_init_task()
......@@ -95,7 +100,6 @@ copy_and_restart( void )
// Set our init task to run instead of the firmware one
INSTR( 0xFF810948 ) = (uint32_t) my_init_task;
// Make sure that our self-modifying code clears the cache
clean_d_cache();
flush_caches();
......@@ -121,8 +125,10 @@ copy_and_restart( void )
* install our own handlers.
*/
#ifndef CONFIG_EARLY_PORT
// Install our task creation hooks
task_dispatch_hook = my_task_dispatch_hook;
#endif
// This will jump into the RAM version of the firmware,
// but the last branch instruction at the end of this
......@@ -137,6 +143,8 @@ copy_and_restart( void )
}
#ifndef CONFIG_EARLY_PORT
void
null_task( void )
{
......@@ -239,6 +247,8 @@ call_init_funcs( void * priv )
init_funcs_done = 1;
}
#endif // !CONFIG_EARLY_PORT
/** Initial task setup.
......@@ -253,8 +263,10 @@ my_init_task(void)
// Call their init task
init_task();
#ifndef CONFIG_EARLY_PORT
// Overwrite the PTPCOM message
dm_names[ DM_MAGIC ] = "[MAGIC] ";
dmstart();
DebugMsg( DM_MAGIC, 3, "Magic Lantern %s (%s)",
build_version,
......@@ -265,9 +277,7 @@ my_init_task(void)
build_date,
build_user
);
dmstart();
#endif
// Re-write the version string.
// Don't use strcpy() so that this can be done
......@@ -284,6 +294,8 @@ my_init_task(void)
additional_version[8] = build_version[4];
additional_version[9] = '\0';
#ifndef CONFIG_EARLY_PORT
msleep( 750 );
menu_init();
......@@ -318,7 +330,6 @@ my_init_task(void)
msleep( 1000 );
#if 1
// Create all of our auto-create tasks
extern struct task_create _tasks_start[];
extern struct task_create _tasks_end[];
......@@ -342,7 +353,7 @@ my_init_task(void)
task->arg
);
}
#endif
DebugMsg( DM_MAGIC, 3, "magic lantern init done" );
#endif // !CONFIG_EARLY_PORT
}
ARM_PATH=/opt/local/bin
CC=$(ARM_PATH)/arm-elf-gcc-4.3.2
OBJCOPY=$(ARM_PATH)/arm-elf-objcopy
AR=$(ARM_PATH)/arm-elf-ar
LD=$(CC)
HOST_CC=gcc
HOST_CFLAGS=-g -O3 -W -Wall
VERSION=0.1.7
VERSION=0.1.8
CONFIG_PYMITE = n
CONFIG_RELOC = n
CONFIG_TIMECODE = y
CONFIG_TIMECODE = n
CONFIG_LUA = n
# 5D memory map
# RESTARTSTART is selected to be just above the end of the bss
#
ROMBASEADDR = 0xFF810000
RESTARTSTART = 0x00048000
RESTARTSTART = 0x00050000
# Firmware file IDs
FIRMWARE_ID_5D = 0x80000218
......@@ -148,6 +149,10 @@ ML_OBJS-y = \
magiclantern.lds \
entry.o \
5d-hack.o \
stubs-5d2.203.o \
version.o \
NO=\
stdio.o \
menu.o \
debug.o \
......@@ -167,8 +172,6 @@ ML_OBJS-y = \
font-large.o \
font-med.o \
font-small.o \
stubs-5d2.110.o \
version.o \
ML_OBJS-$(CONFIG_PYMITE) += \
......@@ -179,6 +182,7 @@ ML_OBJS-$(CONFIG_PYMITE) += \
$(PYMITE_LIB) \
ML_OBJS-$(CONFIG_LUA) += \
lua-glue.o \
$(LUA_LIB) \
ML_OBJS-$(CONFIG_RELOC) += \
......@@ -188,7 +192,29 @@ ML_OBJS-$(CONFIG_RELOC) += \
ML_OBJS-$(CONFIG_TIMECODE) += \
timecode.o \
magiclantern: $(ML_OBJS-y)
# Extract the stdio files that we need
STDIO_OBJ = \
lib_a-setjmp.o \
lib_a-strchr.o \
lib_a-strrchr.o \
lib_a-strlen.o \
lib_a-strcat.o \
lib_a-strncat.o \
lib_a-strcmp.o \
lib_a-strncmp.o \
lib_a-strncpy.o \
lib_a-memcmp.o \
lib_a-strcoll.o \
ARM_LIBC_A = /opt/local/arm-elf/lib/libc.a
$(STDIO_OBJ): $(ARM_LIBC_A)
$(AR) xv $? $(STDIO_OBJ)
libstdio.a: $(STDIO_OBJ)
$(AR) cr $@ $^
magiclantern: $(ML_OBJS-y) libstdio.a
$(call build,LD,$(LD) \
-o $@ \
-N \
......@@ -429,6 +455,6 @@ build = \
clean:
-rm -f *.o *.a font-*.c
-rm -f *.o *.a font-*.c magiclantern.lds
-include .*.d
......@@ -9,6 +9,7 @@
*/
#include "dryos.h"
#include <errno.h>
int
fprintf(
......@@ -47,52 +48,6 @@ snprintf(
}
char *
strncpy(
char * dest,
const char * src,
size_t n
)
{
while( n-- )
{
char c = *src++;
*dest++ = c;
if( !c )
break;
}
return dest;
}
/* NOTE: This is the simple-minded O(len(s1) * len(s2)) worst-case approach.
* Copied from uClibc 0.9.30 libc/string/strstr.c under the GPL.
*/
char *
strstr(
const char * s1,
const char * s2
)
{
register const char *s = s1;
register const char *p = s2;
do {
if( !*p )
return (char *) s1;;
if( *p == *s )
{
++p;
++s;
} else {
p = s2;
if( !*s )
return NULL;
s = ++s1;
}
} while (1);
}
static inline int
......@@ -101,7 +56,10 @@ ISSPACE( char c )
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
#define SET_ERRNO(x) /* We have no errno */
//int __errno;
#define SET_ERRNO(x) __errno = (x)
static unsigned long
......@@ -210,6 +168,26 @@ strtol(
}
double
strtod(
const char * str,
char ** endptr
)
{
return 0;
#if 0
double val;
int len;
int rc = sscanf( str, "%lf%n", &val, &len );
if( rc != 2 )
return HUGE_VAL;
if( endptr )
*endptr = str + len;
return val;
#endif
}
unsigned long
strtoul(
const char * str,
......@@ -221,21 +199,3 @@ strtoul(
}
/** \todo This could be much more optimized to handle 32-bit writes, etc.
*/
void *
memset(
void * b,
int c,
size_t n
)
{
size_t i;
char * buf = b;
for( i=0 ; i<n ; i++ )
buf[i] = c;
return b;
}
......@@ -34,9 +34,6 @@
NSTUB( ROMBASEADDR, firmware_entry )
/** Camera interface? */
NSTUB( 0xC0220000, camera_engine )
/** These must be found first for any progress to be made */
NSTUB( 0xFF810894, cstart )
NSTUB( 0xFFC456C0, bzero32 ) // called by cstart()
......@@ -46,3 +43,21 @@ NSTUB( 0xFF817470, create_init_task )
/** Look for the normal printf strings */
NSTUB( 0xFF86AF48, DebugMsg )
/** Task dispatch hook hasn't moved in several versions */
NSTUB( 0x1934, task_dispatch_hook )
/** Find the additioanl version string in GUI_GetFirmVersion */
NSTUB( 0x13420, additional_version )
// Everything below here is not needed for the first boot
/** Camera interface? */
NSTUB( 0xC0220000, camera_engine )
/** Find the shell register commands */
NSTUB( 0xFF81C4DC, register_func )
/** Debugging commands are all registered by name. Search for the strings */
NSTUB( 0xFF86AEC8, dmstart )
NSTUB( 0xFF86B7DC, dumpf )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment