ldr.ld

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
ENTRY(_start)

SECTIONS
{
	. = 0x25800;
	.text :
	{
		*(.text)
	}
	.data :
	{
		*(.data)
		*(.rodata)
	}
	.bss :
	{
		bss = .;
		*(.bss)
	}
}

types.h

1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef _TYPES_H_
#define _TYPES_H_

typedef char s8;
typedef unsigned char u8;
typedef short s16;
typedef unsigned short u16;
typedef int s32;
typedef unsigned int u32;
typedef long long int s64;
typedef unsigned long long int u64;

#endif

start.S

1
2
3
4
5
6
7
8
9
10
11
12
13
.text

/* Loader entry. */
.global _start
_start:
	/* Setup stack pointer. */
	ila sp, 0x3DFA0
	
	/* Well... */
	brsl lr, main

	_hang:
		br _hang

main.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "types.h"

void *_memcpy(void *dst, void *src, u32 len);

void main()
{
	//Copy eid root key/iv to shared LS.
	_memcpy((u8 *)0x3E000, (u8 *)0x00000, 0x30);
	//Hang (the PPU should copy the key/iv from shared LS now).
	while(1);
}

void *_memcpy(void *dst, void *src, u32 len)
{
	u8 *d = (u8 *)dst;
	u8 *s = (u8 *)src;
	u32 i;
	
	for(i = 0; i < len; i++)
		d[i] = s[i];
	
	return dst;
}