/*
 *               Copyright (C) 2006, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */
#include <ios.h>
#include <arm.h>
#include <asm.h>

/* This file _must_ be linked in as the last .o, so that 
 * runOS is put at the end of all code we want to erase.
 */
BEGIN_PROC(runOS)
    /* parameter r0 = new start */
    ldr r1, =_start /* old start */
    ldr r2, =runOS  /* old end */
    sub r1, r0, r1  /* offset */
    add r2, r2, r1  /* new end = old end + offset */
    ldr r1, =0

wipe:
    str  r1, [r0], #4
    cmp  r2, r0 
    bne  wipe
    
    ldr     pc, =0xffff0000 /* run kernel */
END_PROC(runOS)
