

#include "../lowram.h"


//---------------------------------------------------------------------------------------
void _main(void)
{
    /* Set the copy parameters. */
    unsigned char* src_stt = (unsigned char*)lowram_bin_dat;
    unsigned long length   =                 LOWRAM_BIN_SIZ;
    unsigned char* dst_stt = (unsigned char*)0x00200000;


    /* Copy the target program from the buffer to the execution area. */
    unsigned char* dst_end = dst_stt + length;
    unsigned char* ptr1 = src_stt;
    unsigned char* ptr2 = dst_stt;
    while(ptr2 != dst_end)
    {
        *(ptr2++) = *(ptr1++);
    }


    /* Execute the target program (-> quit this program).
     * (code scrap from antime's satclient.c, http://www.iki.fi/~antime/)
     */
    void (*pFun)(void);
    pFun = (void(*)(void))dst_stt;
    (*pFun)();
}

