tm_dmem_boot.s 1.63 KB
/*
 * tm_dmem_boot.s: Bootstrap file which loads tm_dmem into rsp dmem 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 DMEM_LOAD_ADDRESS	0x04000000
#define RAMROM_SRC_ADDRESS	0x10002000
#define TINYMON_DMEM_SIZE	0x00000400

LEAF (tm_dmem_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 0x04000000 in rsp dmem.
 # (We use 0xB0002000 and 0xa4000000, since K1 seg guarantees uncached access).

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

	bne	t0, t2, send

 # Jump to the loaded program in dmem.

	la	t4, PHYS_TO_K1(DMEM_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_dmem_boot)