-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$ |