summaryrefslogtreecommitdiff
path: root/utils/hwstub/stub/pp
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 22:23:54 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 22:26:50 +0200
commitccfa51835e373c74cdda7eaad962a81ba1001fe2 (patch)
treed827d1027626cae478ab25742f78ffa11a90d2bf /utils/hwstub/stub/pp
parent399acc038750943c1a0ee7178a18714334871472 (diff)
downloadrockbox-ccfa51835e373c74cdda7eaad962a81ba1001fe2.tar.gz
rockbox-ccfa51835e373c74cdda7eaad962a81ba1001fe2.zip
Add hwstub support for portal player (manufacturer mode)
It is very similar to how e200tool from MrH works but uses the framework of hwstub which is makes it completely trivial since we already have the USB driver written. Change-Id: I61cdc245d3f828c2682bcd6ecfed5a1cc0094139
Diffstat (limited to 'utils/hwstub/stub/pp')
-rw-r--r--utils/hwstub/stub/pp/Makefile14
-rw-r--r--utils/hwstub/stub/pp/crt0.S42
-rw-r--r--utils/hwstub/stub/pp/hwstub.lds73
-rw-r--r--utils/hwstub/stub/pp/target-config.h9
-rw-r--r--utils/hwstub/stub/pp/target.c66
5 files changed, 204 insertions, 0 deletions
diff --git a/utils/hwstub/stub/pp/Makefile b/utils/hwstub/stub/pp/Makefile
new file mode 100644
index 0000000000..6e79a2b1c8
--- /dev/null
+++ b/utils/hwstub/stub/pp/Makefile
@@ -0,0 +1,14 @@
1#
2# common
3#
4CC=arm-elf-eabi-gcc
5LD=arm-elf-eabi-gcc
6AS=arm-elf-eabi-gcc
7OC=arm-elf-eabi-objcopy
8DEFINES=
9INCLUDES=-I$(CURDIR)
10GCCOPTS=-mcpu=arm926ej-s
11BUILD_DIR=$(CURDIR)/build/
12ROOT_DIR=$(CURDIR)/..
13
14include ../hwstub.make
diff --git a/utils/hwstub/stub/pp/crt0.S b/utils/hwstub/stub/pp/crt0.S
new file mode 100644
index 0000000000..38b6f18ac5
--- /dev/null
+++ b/utils/hwstub/stub/pp/crt0.S
@@ -0,0 +1,42 @@
1.section .text,"ax",%progbits
2.code 32
3.align 0x04
4.global start
5start:
6 sub r7, pc, #8 /* Copy running address */
7 msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */
8 /* The stub could be located at a virtual address so killing the MMU at
9 * this point would be mere suicide. We assume that the remap location
10 * is identically mapped and kill the MMU after the copy */
11
12 /* Relocate to right address */
13 mov r2, r7
14 ldr r3, =_copystart
15 ldr r4, =_copyend
161:
17 cmp r4, r3
18 ldrhi r5, [r2], #4
19 strhi r5, [r3], #4
20 bhi 1b
21 mov r2, #0
22 mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache
23 /* Jump to real location */
24 ldr pc, =remap
25remap:
26 /* Disable MMU, disable caching and buffering;
27 * use low exception range address */
28 mrc p15, 0, r0, c1, c0, 0
29 ldr r1, =0x3005
30 bic r0, r1
31 mcr p15, 0, r0, c1, c0, 0
32 /* clear bss */
33 ldr r2, =bss_start
34 ldr r3, =bss_end
35 mov r4, #0
361:
37 cmp r3, r2
38 strhi r4, [r2], #4
39 bhi 1b
40 /* jump to C code */
41 ldr sp, =oc_stackend
42 b main
diff --git a/utils/hwstub/stub/pp/hwstub.lds b/utils/hwstub/stub/pp/hwstub.lds
new file mode 100644
index 0000000000..baf10252e1
--- /dev/null
+++ b/utils/hwstub/stub/pp/hwstub.lds
@@ -0,0 +1,73 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22
23ENTRY(start)
24OUTPUT_FORMAT(elf32-littlearm)
25OUTPUT_ARCH(arm)
26STARTUP(pp/crt0.o)
27
28#define IRAM_END_ADDR (IRAM_ORIG + IRAM_SIZE)
29
30MEMORY
31{
32 OCRAM : ORIGIN = IRAM_ORIG, LENGTH = IRAM_SIZE
33}
34
35SECTIONS
36{
37 .octext :
38 {
39 _copystart = .;
40 oc_codestart = .;
41 *(.text*)
42 *(.icode*)
43 *(.data*)
44 *(.rodata*)
45 _copyend = .;
46 } > OCRAM
47
48 .bss (NOLOAD) :
49 {
50 bss_start = .;
51 *(.bss)
52 bss_end = .;
53 } > OCRAM
54
55 .stack (NOLOAD) :
56 {
57 oc_codeend = .;
58 oc_stackstart = .;
59 . += STACK_SIZE;
60 oc_stackend = .;
61 oc_bufferstart = .;
62 } > OCRAM
63
64 .ocend IRAM_END_ADDR (NOLOAD) :
65 {
66 oc_bufferend = .;
67 } > OCRAM
68
69 /DISCARD/ :
70 {
71 *(.eh_frame)
72 }
73}
diff --git a/utils/hwstub/stub/pp/target-config.h b/utils/hwstub/stub/pp/target-config.h
new file mode 100644
index 0000000000..0774137277
--- /dev/null
+++ b/utils/hwstub/stub/pp/target-config.h
@@ -0,0 +1,9 @@
1#define CONFIG_PP
2#define IRAM_ORIG 0x40000000
3#define IRAM_SIZE 0x20000
4#define DRAM_ORIG 0x10f00000
5#define DRAM_SIZE (MEMORYSIZE * 0x100000)
6#define CPU_ARM
7#define ARM_ARCH 5
8#define USB_BASE 0xc5000000
9#define USB_NUM_ENDPOINTS 2 \ No newline at end of file
diff --git a/utils/hwstub/stub/pp/target.c b/utils/hwstub/stub/pp/target.c
new file mode 100644
index 0000000000..14eab80080
--- /dev/null
+++ b/utils/hwstub/stub/pp/target.c
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "stddef.h"
22#include "target.h"
23#include "system.h"
24#include "logf.h"
25#include "memory.h"
26
27/**
28 *
29 * Global
30 *
31 */
32
33/* FIXME wrong for PP500x */
34#define USEC_TIMER (*(volatile unsigned long *)(0x60005010))
35
36struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor =
37{
38 sizeof(struct hwstub_target_desc_t),
39 HWSTUB_DT_TARGET,
40 HWSTUB_TARGET_PP,
41 "PP500x / PP502x / PP610x"
42};
43
44void target_init(void)
45{
46}
47
48void target_get_desc(int desc, void **buffer)
49{
50 *buffer = NULL;
51}
52
53void target_get_config_desc(void *buffer, int *size)
54{
55}
56
57void target_udelay(int us)
58{
59 uint32_t end = USEC_TIMER + us;
60 while(USEC_TIMER <= end);
61}
62
63void target_mdelay(int ms)
64{
65 return target_udelay(ms * 1000);
66}