Skip to content

Commit

Permalink
pongoOS(S) first release
Browse files Browse the repository at this point in the history
  • Loading branch information
woachk committed Mar 1, 2020
0 parents commit daa2ede
Show file tree
Hide file tree
Showing 95 changed files with 45,160 additions and 0 deletions.
10 changes: 10 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The MIT License (MIT)

Copyright © 2020 checkra1n team

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.

45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ifndef $(HOST_OS)
ifeq ($(OS),Windows_NT)
HOST_OS = Windows
else
HOST_OS := $(shell uname -s)
endif
endif

PONGO_VERSION := 1.0.2-$(shell git log -1 --pretty=format:"%H" | cut -c1-8)
ROOT := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
SRC := $(ROOT)/src
INC := $(ROOT)/include
BUILD := $(ROOT)/build

EMBEDDED_CC ?= aarch64-none-elf-gcc
EMBEDDED_OBJCOPY ?= aarch64-none-elf-objcopy
EMBEDDED_LDFLAGS ?= -static -lc -lm -lg -Xlinker -T -Xlinker Pongo.ld -Wl,--gc-sections -Wl,--build-id=none
EMBEDDED_CC_FLAGS ?= -Wunused-label -D'OBFUSCATE_C_FUNC(F)'='F' -DDEV_BUILD=1 -DPONGO_VERSION='"$(PONGO_VERSION)"' $(EMBEDDED_LDFLAGS) -pie -O2 -flto -ffunction-sections -fdata-sections -mcpu=cortex-a57 -mtune=cortex-a57 -DAUTOBOOT

STAGE3_ENTRY_C := $(patsubst %, $(SRC)/boot/%, stage3.c clearhook.s patches.s demote_patch.s jump_to_image.s main.c)
PONGO_C := $(wildcard $(SRC)/kernel/*.c) $(wildcard $(SRC)/dynamic/*.c) $(wildcard $(SRC)/kernel/*.s) $(wildcard $(SRC)/shell/*.c)
PONGO_DRIVERS_C := $(wildcard $(SRC)/drivers/usb/*.c) $(wildcard $(SRC)/drivers/framebuffer/*.c) $(wildcard $(SRC)/drivers/uart/*.c) $(wildcard $(SRC)/drivers/timer/*.c) $(wildcard $(SRC)/drivers/gpio/*.c) $(wildcard $(SRC)/linux/lzma/*.c) $(wildcard $(SRC)/linux/libfdt/*.c) $(wildcard $(SRC)/linux/*.c)
PONGO_FLAGS := -ffreestanding -Iinclude -Iapple-include -Iinclude/linux/ -I$(SRC)/kernel -I$(SRC)/drivers -Wl,-e,_main -I$(SRC)/linux/libfdt

# CLANG_SPECIFIC should be $(BUILD)/entry.o, because of LLD builds.
# Note that we do not officially support building pongoOS with Clang for this early release.

.PHONY: all clean

all: $(BUILD)/Pongo.bin | $(BUILD)

$(BUILD)/Pongo.bin: $(BUILD)/Pongo.elf | $(BUILD)
$(EMBEDDED_OBJCOPY) -O binary $(BUILD)/Pongo.elf $@

$(BUILD)/Pongo.elf: $(STAGE3_ENTRY_C) $(PONGO_C) $(PONGO_DRIVERS_C) $(BUILD)/entry.o | $(BUILD)
$(EMBEDDED_CC) -o $@ $(EMBEDDED_CC_FLAGS) $(PONGO_FLAGS) $(STAGE3_ENTRY_C) $(PONGO_C) $(PONGO_DRIVERS_C) $(CLANG_SPECIFIC)

$(BUILD)/entry.o: $(SRC)/boot/entry.s | $(BUILD)
$(EMBEDDED_CC) -c -o $@ $(SRC)/boot/entry.s -pie -flto

$(BUILD):
mkdir -p $@

clean:
rm -rf $(BUILD)
157 changes: 157 additions & 0 deletions Pongo.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/* pongoOS linker script
* Parts Copyright (C) 2019 checkra1n team
* Parts Copyright (C) 2014-2019 Free Software Foundation, Inc.
* Copying and distribution of this script, with or without modification,
* are permitted in any medium without royalty provided the copyright
* notice and this notice are preserved.
*/

OUTPUT_FORMAT("elf64-littleaarch64")
OUTPUT_ARCH(aarch64)

ENTRY_INIT_STACK_SIZE = 0x2000;

SECTIONS
{
/* the entry point, before enabling paging. The code to enable paing
needs to have the same virtual/physical address. entry.S and start.c
run in this initial setting.*/
/* . = 0x10000; */
. = 0x428000000;

.start_sec : {
build/entry.o(.text)

build/entry.o(.rodata .rodata.*)

build/entry.o(.data .data.*)

build/entry.o(.bss .bss.* COMMON)
}

.text : { /** here to make code also copied into phymem **/
*(EXCLUDE_FILE(*/crt0.o).text .text.* .gnu.linkonce.t.*)
}


.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
}

.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = . + 0x400000000);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = . + 0x400000000);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}

/* aligned the data to a (4K) page, so it can be assigned
different protection than the code*/
. = ALIGN(0x1000);

PROVIDE (data_start = .);

.data : {
*(.data .data.*)
}

__bss_start = .;
.bss : {
*(.bss .bss.* COMMON)
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
__bss_end = .;
. = ALIGN(0x1000);
PROVIDE (end = .);
. = ALIGN(32 / 8);


/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF Extension. */
.debug_macro 0 : { *(.debug_macro) }
.debug_addr 0 : { *(.debug_addr) }
.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }

}

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pongoOS(S)
=========

An experimental pre-boot execution environment for Apple boards built on top of checkra1n.

Contributions
-------------

By submitting a pull request, you certify that this contribution is coming from you and no one else. If you want to import third-party code, that shall be noted prominently for us to evaluate it appropriately.

Module
------
You can build the module at example/ with an iOS cross-compiler on Linux or a Mac. Refer to scripts/ to see how to load modules.

Loading

0 comments on commit daa2ede

Please sign in to comment.