Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (c) 2018 Atmosphère-NX
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- .section .text.start
- .align 4
- .globl _start
- _start:
- b reboot_to_rcm
- adr r0, (restore_svc_vector+1)
- mov lr, pc
- bx r0
- bl usb_init
- b _crt0
- .pool
- .globl _crt0
- .type _crt0,%function
- reboot_to_rcm:
- ldr r0, =0x7000E400
- mov r1, #1
- str r1, [r0, #0x50]
- mov r1, #0x10
- str r1, [r0]
- _crt0:
- ldr r0,=0x52425430 @ RBT0
- mov r1, #0x0
- mov r2, #0x0
- mov r3, #0x0
- mov r4, #0x0
- mov r5, #0x0
- mov r6, #0x0
- mov r7, #0x0
- mov r8, #0x0
- mov r9, #0x0
- mov r10,#0x0
- mov r11,#0x0
- mov r12,#0x0
- mov lr, #0x0
- ldr sp,=0x40010000
- ldr pc,=0x40010000
- .thumb
- restore_svc_vector:
- ldr r0, =0x6000F208 /* SVC vector address */
- ldr r1, =0x40004C30 /* original SVC handler address */
- str r1, [r0]
- bx lr
- usb_init:
- push {lr} /* save return address on the stack */
- adr r0, usb_mode
- ldr r1, =0x1021B3
- ldr r2, =(set_usb_ops+1)
- mov lr, r2 /* required; early revision ARM does not have the ability to load directly into r8-r15 in thumb mode. */
- bx r1 /* get_usb_mode(&usb_mode) */
- set_usb_ops:
- adr r0, usb_mode
- ldr r0, [r0]
- ldr r1, =0x102B75
- ldr r2, =(usb_initialize+1)
- mov lr, r2
- bx r1 /* set_usb_ops(usb_mode) */
- usb_initialize:
- ldr r0, =0x40003114 /* r0 = &g_usb_ops */
- ldr r0, [r0, #4] /* load usb_initialize func ptr from usb_ops */
- ldr r1, =(charger_setup+1)
- mov lr, r1
- bx r0 /* usb_ops->usb_initialize() */
- charger_setup:
- ldr r0, =0x40003114 /* r0 = &g_usb_ops */
- mov r1, #1
- strb r1, [r0, #1] /* set is_initialized flag to 1 */
- strb r1, [r0, #2] /* set buffer to 1; causes rcm_read_command_and_payload() to be called immediately */
- ldr r0, =0x104283
- ldr r1, =(handle_rcm+1)
- mov lr, r1
- bx r0
- handle_rcm:
- ldr r0, =0x40003114 /* r0 = &g_usb_ops */
- pop {r1} /* set r1 to the return address */
- str r1, [r0, #0x10] /* replace read_ep1_out_finish with a jump to return address */
- mov r0, #0 /* this seems to be an "rcm reason" flag. Doesn't matter how it's set */
- mov r1, r0 /* set other args to 0 as they are unused for our purposes. */
- mov r2, r0
- mov r3, r0
- ldr r4, =0x102897 /* handle_rcm(0, 0, 0, 0) */
- bx r4
- .pool
- usb_mode:
- .word 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement