Add raspi_os here

Eventually this is gonna be part of Ferrocyanide
This commit is contained in:
greg
2017-03-25 22:47:34 -07:00
parent 76bbf76bd7
commit 4485fbb579
7 changed files with 243 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
all: process
process:
arm-none-eabi-as -I asm -o main.o main.s
arm-none-eabi-ld --no-undefined main.o -Map kernel.map -o output.elf -T kernel.ld
arm-none-eabi-objcopy output.elf -O binary kernel.img
clean:
rm -f main.o
rm -f output.elf
rm -f kernel.img

38
ferrocyanide/raspi_os/kernel.ld Executable file
View File

@@ -0,0 +1,38 @@
/******************************************************************************
* kernel.ld
* by Alex Chadwick
*
* A linker script for generation of raspberry pi kernel images.
******************************************************************************/
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 rest of the code.
*/
.text : {
*(.text)
}
/*
* Next we put the data.
*/
.data : {
*(.data)
}
/*
* Finally comes everything else. A fun trick here is to put all other
* sections into this section, which will be discarded by default.
*/
/DISCARD/ : {
*(*)
}
}

View File

@@ -0,0 +1,32 @@
Discarded input sections
.bss 0x0000000000000000 0x0 main.o
.ARM.attributes
0x0000000000000000 0x14 main.o
Memory Configuration
Name Origin Length Attributes
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
LOAD main.o
.init 0x0000000000008000 0x50
*(.init)
.init 0x0000000000008000 0x50 main.o
0x0000000000008000 _start
.text 0x0000000000008050 0x0
*(.text)
.text 0x0000000000008050 0x0 main.o
.data 0x0000000000008050 0x0
*(.data)
.data 0x0000000000008050 0x0 main.o
/DISCARD/
*(*)
OUTPUT(output.elf elf32-littlearm)

View File

@@ -0,0 +1,36 @@
.section .init
.globl _start
_start:
ldr r0,=0x20200000 //GPIO controller address
mov r1, #1 // put 1 into r1
lsl r1, #18 //logical shift left by 18
str r1, [r0, #4] //store register
loop:
mov r1, #1
lsl r1, #16 //set pin 16
str r1, [r0, #40] // toggle GPIO on
mov r2, #0x3f0000
wait:
sub r2, #1
cmp r2, #0
bne wait
mov r1, #1
lsl r1, #16 //set pin 16
str r1, [r0, #28] // toggle GPIO ofrf
mov r2, #0x3f0000
wait2:
sub r2, #1
cmp r2, #0
bne wait2
b loop

View File

@@ -0,0 +1,22 @@
Copyright (c) 2012 Alex Chadwick
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,64 @@
###############################################################################
# makefile
# by Alex Chadwick
#
# A makefile script for generation of raspberry pi kernel images.
###############################################################################
# The toolchain to use. arm-none-eabi works, but there does exist
# arm-bcm2708-linux-gnueabi.
ARMGNU ?= arm-none-eabi
# The intermediate directory for compiled object files.
BUILD = build/
# The directory in which source files are stored.
SOURCE = source/
# The name of the output file to generate.
TARGET = kernel.img
# The name of the assembler listing file to generate.
LIST = kernel.list
# The name of the map file to generate.
MAP = kernel.map
# The name of the linker script to use.
LINKER = kernel.ld
# The names of all object files that must be generated. Deduced from the
# assembly code files in source.
OBJECTS := $(patsubst $(SOURCE)%.s,$(BUILD)%.o,$(wildcard $(SOURCE)*.s))
# Rule to make everything.
all: $(TARGET) $(LIST)
# Rule to remake everything. Does not include clean.
rebuild: all
# Rule to make the listing file.
$(LIST) : $(BUILD)output.elf
$(ARMGNU)-objdump -d $(BUILD)output.elf > $(LIST)
# Rule to make the image file.
$(TARGET) : $(BUILD)output.elf
$(ARMGNU)-objcopy $(BUILD)output.elf -O binary $(TARGET)
# Rule to make the elf file.
$(BUILD)output.elf : $(OBJECTS) $(LINKER)
$(ARMGNU)-ld --no-undefined $(OBJECTS) -Map $(MAP) -o $(BUILD)output.elf -T $(LINKER)
# Rule to make the object files.
$(BUILD)%.o: $(SOURCE)%.s $(BUILD)
$(ARMGNU)-as -I $(SOURCE) $< -o $@
$(BUILD):
mkdir $@
# Rule to clean files.
clean :
-rm -rf $(BUILD)
-rm -f $(TARGET)
-rm -f $(LIST)
-rm -f $(MAP)

View File

@@ -0,0 +1,39 @@
/******************************************************************************
* kernel.ld
* by Alex Chadwick
*
* A linker script for generation of raspberry pi kernel images.
******************************************************************************/
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 rest of the code.
*/
.text : {
*(.text)
}
/*
* Next we put the data.
*/
.data : {
*(.data)
}
/*
* Finally comes everything else. A fun trick here is to put all other
* sections into this section, which will be discarded by default.
*/
/DISCARD/ : {
*(*)
}
}