tm_imem_boot.s 1.63 KB
/*
 * tm_imem_boot.s: Bootstrap file which loads tm_imem into rsp imem memory
 *		   from the standard gload point within ramrom.  We always 
 *		   load 0x400 bytes for simplicity of implementation.
 */
#include "regdef.h"
#include "asm.h"
#include <R4300.h>
#include <rcp.h>
#include "tinymon.h"

#define IMEM_LOAD_ADDRESS	0x04001000
#define RAMROM_SRC_ADDRESS	0x10002000
#define TINYMON_IMEM_SIZE	0x00000400

LEAF (tm_imem_boot)			# Address = 0xB0000400.

        .set    noreorder

        li      t1, SR_BEV|SR_CU0	# Initialize SR
        mtc0    t1, C0_SR		# Clear Status Register.

        .set    reorder

 # Load the tinymon program from 0x10002000 in ramrom to 0x04001000 in rsp dmem.
 # (We use 0xB0002000 and 0xa4001000, since K1 seg guarantees uncached access).

	la	t0, PHYS_TO_K1(RAMROM_SRC_ADDRESS)
	la	t1, PHYS_TO_K1(IMEM_LOAD_ADDRESS)
	la	t2, PHYS_TO_K1(RAMROM_SRC_ADDRESS)
	addiu	t2, TINYMON_IMEM_SIZE
send:
	lw	t3, 0(t0)		# load monitor from ramrom
	sw	t3, 0(t1)		# store monitor to imem
	/*
	jal	waitForIdle
	*/
	addiu	t0, 4			# add monitor address
	addiu	t1, 4			# add imem adress
	bne	t0, t2, send

 # Jump to the loaded program in imem.

	la	t4, PHYS_TO_K1(IMEM_LOAD_ADDRESS)
	jr	t4


/*
 * General purpose subroutine which spins, waiting for the PI controller to
 * become idle.  Should be called after each RAMROM cartridge interface request
 * (for either memory or registers).
 */
        .set    noreorder
waitForIdle:
	lui	t4, PI_BASE_REG_UPPER_K1
waitLoop:
	lw	t5, PI_STATUS_REG_OFFSET(t4)
	nop
	andi	t6, t5, (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)
	bne	t6, zero, waitLoop
	nop
	jr      ra
	nop
        .set    reorder

END (tm_imem_boot)