Skip to content

Commit

Permalink
Add ACT/OK led program
Browse files Browse the repository at this point in the history
  • Loading branch information
mauri870 committed Dec 10, 2017
1 parent f7e6158 commit c59562d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
47 changes: 7 additions & 40 deletions kernel.ld
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
/******************************************************************************
* kernel.ld
* by Alex Chadwick
*
* A linker script for generation of raspberry pi kernel images, with C
* code.
******************************************************************************/

SECTIONS {
/*
* First and formost we need the .init section, containing the code to
* be run first. We allow room for the ATAGs and stack and conform to
* the bootloader's expectation by putting this code at 0x8000.
*/
.init 0x8000 : {
*(.init)
}

/*
* Next we put the data.
*/
.data : {
*(.data)
*.c.o(*)
}

/*
* Next we put the rest of the code.
*/
.text : {
*.c.o(.text)
*(.text)
}
.text 0x8000 : {
*(.text)
}

/*
* Finally comes everything else. A fun trick here is to put all other
* sections into this section, which will be discarded by default.
*/
/DISCARD/ : {
*(*)
}
}
.data : {
*(.data)
}
}
37 changes: 37 additions & 0 deletions src/main.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* A simple program to turn on the OK/ACT LED on Raspberry Pi 3
*/

.globl _start @ define _start label globally available for the linker

.section .data
.align 4 @ last 4 bits of the next label set to 0 (16-byte alligned)
message:
.int size @ message header contains the size of the message
.int 0 @ request code 0

.int 0x00038041 @ header tag ID
.int 8 @ size of tag data
.int 0 @ request/response size

.int 130 @ pin number
.int 1 @ pin state
.int 0 @ signal the GPU that the message is over
size:
.int . - message @ size of the message

.section .text
_start:
ldr r0, =0x3f00b880 @ load the hex number =0x3f00b880 into register r0
@ this is the base address of the mailboxes
wait$:
ldr r1, [r0, #0x18] @ load r1 with the address of the offset 0x18 for mailbox 0 (read mailbox)
tst r1, #0x80000000 @ check if the full flag is set
bne wait$ @ branch to wait$ label if the full flag is not set

ldr r1, =message @ load the message into r1
add r1, #8 @ add the channel 8 as the last 4 bits of the message
str r1, [r0, #0x20] @ put the message into mailbox 1 write register, which is at offset 0x20 from the base address

loop$: @ keep the cpu busy forever in the loop
b loop$

0 comments on commit c59562d

Please sign in to comment.