35 #include "sys/clock.h"
41 #include "dev/flash.h"
43 #include "loader/loader-arch.h"
45 void *loader_arch_codeaddr, *loader_arch_dataaddr;
48 #define FLASHADDR ((char *)0x8000)
49 #define DATAADDR ((char *)0x900)
52 #define beep(n) do { } while (0)
53 #define beep_beep(n) do { } while (0)
57 loader_arch_load(
unsigned short startaddr)
60 unsigned short codelen, datalen, sumlen;
63 unsigned short *flashptr;
64 void (* init)(
void *);
65 unsigned char tmpdata[READSIZE];
77 if(tmp !=
UIP_HTONS(LOADER_ARCH_VERSION)) {
90 for(i = 0; sumlen - i > READSIZE; i += READSIZE) {
93 for(j = 0; j < READSIZE; ++j) {
95 if(sum < tmpdata[j]) {
103 for(j = 0; j < sumlen - i; ++j) {
105 if(sum < tmpdata[j]) {
116 for(i = 0; i < (sum >> 4); ++i) {
118 for(j = 0; j < 2; ++j) {
123 for(j = 0; j < 8; ++j) {
127 for(i = 0; i < (sum & 0x0f); ++i) {
129 for(j = 0; j < 2; ++j) {
140 for(i = 0; i < 4; ++i) {
142 for(j = 0; j < 2; ++j) {
146 leds_off(LEDS_GREEN);
150 leds_on(LEDS_YELLOW);
164 flashptr = (
unsigned short *)FLASHADDR;
165 for(ptr = startaddr + 2; ptr < startaddr + 2 + codelen; ptr += READSIZE) {
171 if((((
unsigned short)flashptr) & 0x01ff) == 0) {
180 for(i = 0; i < READSIZE / 2; ++i) {
181 flash_write(flashptr, ((
unsigned short *)DATAADDR)[i]);
188 leds_off(LEDS_YELLOW);
193 eeprom_read(startaddr + 2 + codelen, (
char *)&datalen, 2);
200 eeprom_read(startaddr + 2 + codelen + 2, DATAADDR, datalen);
203 for(i = 0; i < 4; ++i) {
208 leds_off(LEDS_GREEN);
211 init = ((void (*)(
void *))FLASHADDR);
216 loader_arch_free(
void *code,
void *data)