Last active
September 28, 2015 00:43
-
-
Save pdumais/be6a5395d806fe1c89d3 to your computer and use it in GitHub Desktop.
ARM bare-metal test.
This file contains hidden or 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
| #define push(a...) stmdb r13!,{a} | |
| #define pop(a...) ldmia r13!,{a} | |
| #define PRINTK(STR)\ | |
| push(r3,r4,r5,r14); \ | |
| adr r4,1f; \ | |
| bl debugprint; \ | |
| bl 2f; \ | |
| 1: .ASCIZ STR; \ | |
| .ALIGN 4; \ | |
| 2: pop(r14,r5,r4,r3) | |
| #define SERIAL0_BASE 0x10009000 | |
| #define SERIAL0_FLAG 0x10009018 | |
| .text | |
| PRINTK("TEST\r\n") | |
| 1: b 1b | |
| debugprint: | |
| ldr r3,=SERIAL0_FLAG | |
| 1: ldr r5,[r3] | |
| ands r5,#(1<<5) | |
| bne 1b | |
| ldr r3,=SERIAL0_BASE | |
| ldrb r5,[r4],#1 | |
| cmp r5,#0 | |
| moveq r15,r14 | |
| str r5,[r3] | |
| b debugprint |
This file contains hidden or 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
| SECTIONS { | |
| . = 0x70001000; | |
| .text : { * (.text); } | |
| } |
This file contains hidden or 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
| SOURCES=init.S | |
| TARGET=os | |
| BINDIR=bin/ | |
| AS=arm-unknown-linux-gnueabi-gcc | |
| LD=arm-unknown-linux-gnueabi-ld | |
| CC=arm-unknown-linux-gnueabi-cc | |
| OBJDUMP=arm-unknown-linux-gnueabi-objdump | |
| OBJCOPY=arm-unknown-linux-gnueabi-objcopy | |
| OBJECTS=$(SOURCES:%.S=$(BINDIR)%.o) | |
| all: $(TARGET).bin | |
| cp $(BINDIR)$(TARGET).bin $(BINDIR)disk.img | |
| $(OBJECTS): $(BINDIR)%.o : ./%.S | |
| $(AS) -mcpu=cortex-a8 -ffreestanding -c $< -o $@ | |
| os.bin: $(OBJECTS) | |
| $(LD) -T link.ld $(OBJECTS) -o $(BINDIR)$(TARGET).elf | |
| $(OBJCOPY) $(BINDIR)$(TARGET).elf -O binary $(BINDIR)$(TARGET).bin | |
| run: all | |
| qemu-system-arm -M realview-pb-a8 -m 512 -kernel $(BINDIR)disk.img -nographic -no-reboot -monitor telnet:127.0.0.1:2048,server,nowait,ipv4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment