Skip to content

Commit

Permalink
pongoOS 2.0.0
Browse files Browse the repository at this point in the history
Drivers added:
- TrustZone
- MIPI

Major kernel and newlib support update.
  • Loading branch information
woachk committed Oct 27, 2020
1 parent e111aff commit 696c1ee
Show file tree
Hide file tree
Showing 75 changed files with 4,944 additions and 503 deletions.
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,25 @@ ifeq ($(HOST_OS),Linux)
endif
endif

PONGO_VERSION := 1.3.1-$(shell git log -1 --pretty=format:"%H" | cut -c1-8)
PONGO_VERSION := 2.0.0-$(shell git log -1 --pretty=format:"%H" | cut -c1-8)
ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SRC := $(ROOT)/src
AUX := $(ROOT)/tools
LIB := $(ROOT)/aarch64-none-darwin
INC := $(ROOT)/include
BUILD := $(ROOT)/build
RA1N := $(ROOT)/checkra1n-kpf

# General options
EMBEDDED_LDFLAGS ?= -nostdlib -static -Wl,-fatal_warnings -Wl,-dead_strip -Wl,-Z
EMBEDDED_CC_FLAGS ?= -Wall -Wunused-label -Werror -O3 -flto -ffreestanding -U__nonnull -nostdlibinc -I$(LIB)/include $(EMBEDDED_LDFLAGS)

# Pongo options
PONGO_LDFLAGS ?= -L$(LIB)/lib -lc -lm -lg -Wl,-preload -Wl,-no_uuid -Wl,-e,start -Wl,-order_file,$(SRC)/sym_order.txt -Wl,-image_base,0x418000000 -Wl,-sectalign,__DATA,__common,0x8
PONGO_CC_FLAGS ?= -DPONGO_VERSION='"$(PONGO_VERSION)"' -DAUTOBOOT -DPONGO_PRIVATE=1 -Djit_alloc=calloc -Djit_free=free -I$(INC) -Iapple-include -I$(INC)/linux/ -I$(SRC)/kernel -I$(SRC)/drivers -I$(SRC)/linux/libfdt $(PONGO_LDFLAGS) $(CFLAGS)
PONGO_CC_FLAGS ?= -DPONGO_VERSION='"$(PONGO_VERSION)"' -DAUTOBOOT -DPONGO_PRIVATE=1 -Djit_alloc=calloc -Djit_free=free -I$(SRC)/lib -I$(INC) -Iapple-include -I$(INC)/linux/ -I$(SRC)/kernel -I$(SRC)/drivers -I$(SRC)/linux/libfdt -I $(LIB)/libDER $(PONGO_LDFLAGS) $(CFLAGS) -DDER_TAG_SIZE=8

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/*/*.c) $(wildcard $(SRC)/drivers/*/*.S) $(wildcard $(SRC)/linux/*/*.c) $(wildcard $(SRC)/linux/*.c)


CHECKRA1N_CC ?= $(EMBEDDED_CC)
PONGO_C := $(wildcard $(SRC)/kernel/*.c) $(wildcard $(SRC)/kernel/support/*.c) $(wildcard $(SRC)/dynamic/*.c) $(wildcard $(SRC)/kernel/*.S) $(wildcard $(SRC)/shell/*.c)
PONGO_DRIVERS_C := $(wildcard $(SRC)/drivers/*/*.c) $(wildcard $(SRC)/drivers/*/*.S) $(wildcard $(SRC)/linux/*/*.c) $(wildcard $(SRC)/linux/*.c) $(wildcard $(SRC)/lib/*/*.c)


.PHONY: all clean
Expand All @@ -52,7 +49,7 @@ $(BUILD)/Pongo.bin: $(BUILD)/vmacho $(BUILD)/Pongo | $(BUILD)
$(BUILD)/Pongo: $(SRC)/boot/entry.S $(STAGE3_ENTRY_C) $(PONGO_C) $(PONGO_DRIVERS_C) | $(BUILD)
$(EMBEDDED_CC) -o $@ $(EMBEDDED_CC_FLAGS) $(PONGO_CC_FLAGS) $(SRC)/boot/entry.S $(STAGE3_ENTRY_C) $(PONGO_C) $(PONGO_DRIVERS_C)

$(BUILD)/vmacho: $(SRC)/vmacho.c | $(BUILD)
$(BUILD)/vmacho: $(AUX)/vmacho.c | $(BUILD)
$(CC) -Wall -O3 -o $@ $^ $(CFLAGS)

$(BUILD):
Expand Down
22 changes: 22 additions & 0 deletions include/key.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#define PUBKEY_BITS (const unsigned char[]) { \
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xaf, 0xb0, 0xe8, 0xed, 0x4d, 0xc5, 0x18, \
0x72, 0xcd, 0x0d, 0xbe, 0x8f, 0xd7, 0x00, 0x1a, 0xcf, 0xdb, 0x42, 0x39, 0x6c, 0x77, 0x4f, 0x80, \
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions scripts/arm64-apple-ios12.0.0-clang
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#!/bin/bash -x
# 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.
#
#
# Copyright (c) 2019-2020 checkra1n team
# This file is part of pongoOS.
#
TOOLCHAIN=/opt/ios-arm64e-clang-toolchain
REALNAME="$(realpath "$0")"
DIR="$(dirname "${REALNAME}")"
Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
dev.set_configuration()

#dev.ctrl_transfer(0x21, 4, 0, 0, 0)
print(dev.ctrl_transfer(0xa1, 1, 0, 0, 512).tostring())
print("".join(chr (x) for x in dev.ctrl_transfer(0xa1, 1, 0, 0, 512)))
2 changes: 1 addition & 1 deletion scripts/issue_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
raise ValueError('Device not found')
dev.set_configuration()

dev.ctrl_transfer(0x21, 4, 0, 0, 0)
#dev.ctrl_transfer(0x21, 4, 0, 0, 0)
dev.ctrl_transfer(0x21, 3, 0, 0, sys.argv[1] + "\n")
22 changes: 22 additions & 0 deletions scripts/pongoterm.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
Expand Down
1 change: 1 addition & 0 deletions src/boot/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ start$l0:
sub sp, x5, #0x400
mov x1, x0
mov x0, x9
mov x29, xzr
bl _trampoline_entry
b .

Expand Down
22 changes: 22 additions & 0 deletions src/drivers/aes/aes.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
Expand Down
22 changes: 22 additions & 0 deletions src/drivers/aes/aes.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#ifndef AES_H
#define AES_H

Expand Down
22 changes: 22 additions & 0 deletions src/drivers/aes/aes_a7.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
Expand Down
22 changes: 22 additions & 0 deletions src/drivers/aes/aes_a9.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
Expand Down
22 changes: 22 additions & 0 deletions src/drivers/aes/aes_private.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// 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.
//
//
// Copyright (c) 2019-2020 checkra1n team
// This file is part of pongoOS.
//
#ifndef AES_PRIVATE_H
#define AES_PRIVATE_H

Expand Down
27 changes: 22 additions & 5 deletions src/drivers/framebuffer/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,20 @@ void screen_putc(uint8_t c)
{
if (!gFramebuffer) return;
disable_interrupts();
if (c == '\b') {
if (x_cursor > 8 * SCALE_FACTOR) {
x_cursor -= 8 * SCALE_FACTOR;
} else {
x_cursor = 0;
}
if (LEFT_MARGIN > x_cursor) {
x_cursor = LEFT_MARGIN;
}
enable_interrupts();
return;
}
if (c == '\n' || (x_cursor + (8 * SCALE_FACTOR)) > (gWidth - LEFT_MARGIN*2)) {
if ((y_cursor + (12 * SCALE_FACTOR)) > gHeight) {
if ((y_cursor + (12 * SCALE_FACTOR) + 16) > gHeight) {
y_cursor = bannerHeight;
} else {
y_cursor += 1 + 8 * SCALE_FACTOR;
Expand Down Expand Up @@ -102,14 +114,17 @@ void screen_putc(uint8_t c)
for (int y = 0; y < (8 * SCALE_FACTOR); y++) {
if (font8x8_basic[c & 0x7f][y / SCALE_FACTOR] & (1 << (x / SCALE_FACTOR))) {
uint32_t ind = (x + local_x_cursor) + ((y + local_y_cursor) * gRowPixels);
uint32_t curcolor = gFramebuffer[ind];
uint32_t curcolor = basecolor; // gFramebuffer[ind];
if (curcolor == basecolor && (curcolor & 0x3fffffff) != 0x40000000) {
curcolor ^= 0xFFFFFFFF;
} else {
curcolor ^= 0xFF7F7F7F;
}
curcolor &= 0x3fffffff;
gFramebuffer[ind] = curcolor;
} else {
uint32_t ind = (x + local_x_cursor) + ((y + local_y_cursor) * gRowPixels);
gFramebuffer[ind] = basecolor;
}
}
}
Expand Down Expand Up @@ -139,13 +154,15 @@ void screen_invert() {
cache_clean(gFramebuffer, gHeight * gRowPixels * 4);
}

uint32_t bitmap[] = { 0x0, 0xa00, 0x400, 0x5540, 0x7fc0, 0x3f80, 0x3f80, 0x1f00, 0x1f00, 0x1f00, 0x3f80, 0xffe0, 0x3f80, 0x3f80, 0x3f83, 0x103f9f, 0x18103ffb, 0xe3fffd5, 0x1beabfab, 0x480d7fd5, 0xf80abfab, 0x480d7fd5, 0x1beabfab, 0xe3fffd5, 0x18107ffb, 0x107fdf, 0x7fc3, 0xffe0, 0xffe0, 0xffe0, 0x1fff0, 0x1fff0 };
uint32_t gLogoBitmap[32] = { 0x0, 0xa00, 0x400, 0x5540, 0x7fc0, 0x3f80, 0x3f80, 0x1f00, 0x1f00, 0x1f00, 0x3f80, 0xffe0, 0x3f80, 0x3f80, 0x3f83, 0x103f9f, 0x18103ffb, 0xe3fffd5, 0x1beabfab, 0x480d7fd5, 0xf80abfab, 0x480d7fd5, 0x1beabfab, 0xe3fffd5, 0x18107ffb, 0x107fdf, 0x7fc3, 0xffe0, 0xffe0, 0xffe0, 0x1fff0, 0x1fff0 };

void screen_init() {
gFramebuffer = (uint32_t*)(gBootArgs->Video.v_baseAddr - 0x800000000 + kCacheableView);
gRowPixels = gBootArgs->Video.v_rowBytes >> 2;
uint16_t width = gWidth = gBootArgs->Video.v_width;
uint16_t height = gHeight = gBootArgs->Video.v_height;
uint64_t fbsize = gHeight * gRowPixels * 4;
map_range(0xfb0000000ULL, gBootArgs->Video.v_baseAddr, (fbsize+0x3fff) & ~0x3fff, 3, 1, true);
gFramebuffer = (uint32_t*)(0xfb0000000ULL);

height &= 0xfff0;
scale_factor = 2;
Expand All @@ -161,7 +178,7 @@ void screen_init() {
uint32_t logo_y_begin = (height / 2) - (16 * logo_scaler_factor);

for (uint32_t y = 0; y < (32 * logo_scaler_factor); ++y) {
uint32_t b = bitmap[y / logo_scaler_factor];
uint32_t b = gLogoBitmap[y / logo_scaler_factor];
for (uint32_t x = 0; x < (32 * logo_scaler_factor); ++x) {
uint32_t ind = logo_x_begin + x + ((logo_y_begin + y) * gRowPixels);
uint32_t curcolor = gFramebuffer[ind];
Expand Down

0 comments on commit 696c1ee

Please sign in to comment.