Commit 5717baed authored by Jonathan Currier's avatar Jonathan Currier

WIP Add cmd to adjust kermit buffer location

also delay boot at kermit transfer by ~1s to allow the program to resume listening to the console
parent e2fd6e3a
......@@ -48,6 +48,10 @@
extern void boot_helper(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr);
static inline void mtkasr(uint64_t val)
{
asm volatile("mtspr 850, %0;" : : "r" (val));
}
void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr)
{
printf("Executing booted program at 0x%08x\n\n", addr);
......@@ -71,6 +75,17 @@ void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned
addr += 0x100;
#endif
{
/* delay boot for 1s (or more)*/
int i = CONFIG_CLOCK_FREQUENCY/2;
while(i) {
__asm__ volatile("nop");
i--;
}
}
/* remap the interrupt vector... I hope */
mtkasr(1);
boot_helper(r1, r2, r3, addr);
while(1);
}
......
......@@ -6,6 +6,8 @@
#include <console.h>
#include <stdio.h>
#include "command.h"
/*
* This is a debugging tool for detecting when the kermit
* code is returning to the caller instead of continuing the transfer
......@@ -297,6 +299,24 @@ whole_pkt_start:
return sm->return_status;
}
}
uint8_t *kermit_output_base =
(uint8_t*)(MAIN_RAM_BASE + (MAIN_RAM_SIZE/2));
static void kermbase(int nb_params, char **params)
{
size_t tmp = 0;
char *c;
if (nb_params < 1)
{
printf("kermbase <baseaddr>\n"
"currently: %p\n", kermit_output_base);
return;
}
tmp = strtoul(params[0], &c, 0);
kermit_output_base = (uint8_t*)tmp;
return;
}
define_command(kermbase, kermbase, "Set kermit load base addressi", SYSTEM_CMDS);
#define KERM_MAGIC 0x47921306
static inline struct mini_kerm_sm* init_kermit_sm(void)
......@@ -324,7 +344,8 @@ static inline struct mini_kerm_sm* init_kermit_sm(void)
#endif
sm->pkt_buffer_size = buffer_size;
sm->pkt_buffer = (uint8_t*)(sm + 1);
sm->outbuffer_base = (uint8_t*)(MAIN_RAM_BASE + (MAIN_RAM_SIZE/2));
//sm->outbuffer_base = (uint8_t*)(MAIN_RAM_BASE + (MAIN_RAM_SIZE/2));
sm->outbuffer_base = kermit_output_base;
sm->outbuffer = sm->outbuffer_base;
sm->done = false;
return sm;
......@@ -341,20 +362,6 @@ bool kermit_valid_packet(uint8_t *buffer, size_t len)
return true;
}
#if 0
//int run_kermit(void)
int run_kermit(uint8_t *buffer, size_t len)
{
struct mini_kerm_sm *sm = init_kermit_sm();
size_t l_len = buffer ? 0 : getpacket_length(buffer) + 2;
if (!buffer)
buffer = sm->pkt_buffer;
//memcpy(sm->pkt_buffer, buffer, getpacket_length(buffer) + 2);
return kermit_get_file(sm, buffer, l_len);
}
#endif
void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2,
unsigned long r3, unsigned long addr);
int kermit_maybe(uint8_t mark)
......@@ -362,7 +369,7 @@ int kermit_maybe(uint8_t mark)
if (mark != 1)
return -1;
struct mini_kerm_sm *sm = init_kermit_sm();
printf("Placing output buffer @0x%p\n", sm->outbuffer_base);
//printf("Placing output buffer @0x%p\n", sm->outbuffer_base);
/* boot should'nt return */
if (!kermit_get_file(sm, mark))
boot(0, 0, 0, sm->outbuffer_base);
......
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