Skip to content

Commit

Permalink
pongoOS 2.3.0
Browse files Browse the repository at this point in the history
- paging and MM work
- separate phys allocator
- USB now works on A7 and A8
- beginnings of process support... and more.
  • Loading branch information
woachk committed Oct 31, 2020
1 parent 458707a commit 602f59a
Show file tree
Hide file tree
Showing 20 changed files with 1,292 additions and 594 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ifeq ($(HOST_OS),Linux)
endif
endif

PONGO_VERSION := 2.2.0-$(shell git log -1 --pretty=format:"%H" | cut -c1-8)
PONGO_VERSION := 2.3.0-$(shell git log -1 --pretty=format:"%H" | cut -c1-8)
ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SRC := $(ROOT)/src
AUX := $(ROOT)/tools
Expand Down
5 changes: 3 additions & 2 deletions scripts/upload_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Copyright (c) 2019-2020 checkra1n team
# This file is part of pongoOS.
#
import struct
import sys
data = open(sys.argv[1], "rb").read()
import usb.core
Expand All @@ -28,8 +29,8 @@
raise ValueError('Device not found')
dev.set_configuration()

dev.ctrl_transfer(0x21, 2, 0, 0, 0)
dev.ctrl_transfer(0x21, 5, 0, 0, struct.pack('I', len(data)))
dev.ctrl_transfer(0x21, 2, 0, 0, 0)
dev.ctrl_transfer(0x21, 1, 0, 0, 0)
dev.write(2,data,1000000)
if len(data) % 512 == 0:
dev.write(2,"")
3 changes: 0 additions & 3 deletions src/boot/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ _exception_vector_el3:
/* Lower EL with Aarch64 */
mov x18, #0xc
msr spsr_el3, x18
mrs x18, elr_el3
add x18, x18, #4
msr elr_el3, x18
eret

.balign 128
Expand Down
15 changes: 8 additions & 7 deletions src/drivers/usb/synopsys_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,20 +1443,24 @@ static void
ep0_out_interrupt() {
uint32_t doepint = reg_read(rDOEPINT(0));
reg_write(rDOEPINT(0), doepint);
bool is_setup = !!(gSynopsysCoreVersion < 0x300a ? (doepint & 0x8) : (doepint & 0x8000));
bool is_setup = !!(doepint & 0x8008);
bool is_data = !is_setup && !!(doepint & 0x1);
if (is_setup) {
// We've received a setup packet.

spin(1); // this is required because this interrupt is asserted *before* the DMA transfer is complete on some devices.. ugh
struct setup_packet *setup = ep_out_recv_setup_done(&ep0_out);
ep0.setup_packet = *setup;
ep0.setup_packet = *setup;

ep0.setup_packet_pending = true;
ep0.data_out_stage_callback = NULL;
ep0.status_out_stage_callback = NULL;
}
if ((doepint & 0x8) && ep0.setup_packet_pending) {
// The SETUP stage is done, so process the queued setup packet.
ep0.setup_packet_pending = false;
bool success = false;

bool success = false;
// Only begin processing the setup packet if we will have enough room for the whole
// transfer. We could break down the layering to allow even bigger contiguous
// transfers, but this works fine for me.
Expand Down Expand Up @@ -1895,8 +1899,5 @@ void usb_init() {
void usb_teardown() {
if (!gSynopsysOTGBase) return;
reg_write(rGAHBCFG, 0x2e);
*(volatile uint32_t*)(gSynopsysOTGBase + 0x4) &= ~2;
clock_gate(reg3, 0);
clock_gate(reg2, 0);
clock_gate(reg1, 0);
reg_or(rDCTL, 0x2);
}
36 changes: 22 additions & 14 deletions src/dynamic/modload.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,21 @@ struct pongo_exports public_api[] = {
EXPORT_SYMBOL(bzero),
EXPORT_SYMBOL(memset),
EXPORT_SYMBOL(memcpy_trap),
EXPORT_SYMBOL(vm_space_deallocate),
EXPORT_SYMBOL(free_contig),
EXPORT_SYMBOL(phys_reference),
EXPORT_SYMBOL(phys_dereference),
EXPORT_SYMBOL(phys_force_free),
EXPORT_SYMBOL(mark_phys_wired),
EXPORT_SYMBOL(phys_get_entry),
EXPORT_SYMBOL(phys_set_entry),
EXPORT_SYMBOL(vm_flush),
EXPORT_SYMBOL(vm_flush_by_addr),
EXPORT_SYMBOL(free_phys),
EXPORT_SYMBOL(vm_space_map_page_physical_prot),
EXPORT_SYMBOL(proc_reference),
EXPORT_SYMBOL(proc_release),
EXPORT_SYMBOL(proc_create_task),
EXPORT_SYMBOL(vm_deallocate),
EXPORT_SYMBOL(vm_space_allocate),
EXPORT_SYMBOL(vm_allocate),
EXPORT_SYMBOL(strcmp),
EXPORT_SYMBOL(queue_rx_string),
Expand All @@ -103,6 +115,7 @@ struct pongo_exports public_api[] = {
EXPORT_SYMBOL(tz_blackbird),
EXPORT_SYMBOL(tz_lockdown),
EXPORT_SYMBOL(vatophys),
EXPORT_SYMBOL(vatophys_static),
EXPORT_SYMBOL(lock_take),
EXPORT_SYMBOL(lock_take_spin),
EXPORT_SYMBOL(lock_release),
Expand Down Expand Up @@ -155,32 +168,26 @@ struct pongo_exports public_api[] = {
EXPORT_SYMBOL(device_clock_by_id),
EXPORT_SYMBOL(device_clock_by_name),
EXPORT_SYMBOL(clock_gate),
EXPORT_SYMBOL(disable_preemption),
EXPORT_SYMBOL(enable_preemption),
EXPORT_SYMBOL(disable_interrupts),
EXPORT_SYMBOL(enable_interrupts),
EXPORT_SYMBOL(alloc_contig),
EXPORT_SYMBOL(alloc_phys),
EXPORT_SYMBOL(map_physical_range),
EXPORT_SYMBOL(task_vm_space),
EXPORT_SYMBOL(usbloader_init),
EXPORT_SYMBOL(pmgr_init),
EXPORT_SYMBOL(command_init),
EXPORT_SYMBOL(serial_init),
EXPORT_SYMBOL(task_irq_teardown),
EXPORT_SYMBOL(realloc),
EXPORT_SYMBOL(malloc),
EXPORT_SYMBOL(phystokv),
EXPORT_SYMBOL(free),
EXPORT_SYMBOL(hexdump),
EXPORT_SYMBOL(memcmp),
EXPORT_SYMBOL(map_range),
EXPORT_SYMBOL(screen_init),
EXPORT_SYMBOL(screen_puts),
EXPORT_SYMBOL(screen_write),
EXPORT_SYMBOL(screen_putc),
EXPORT_SYMBOL(screen_mark_banner),
EXPORT_SYMBOL(serial_putc),
EXPORT_SYMBOL(serial_disable_rx),
EXPORT_SYMBOL(serial_enable_rx),
EXPORT_SYMBOL(__memset_chk),
EXPORT_SYMBOL(__memcpy_chk),
EXPORT_SYMBOL(resize_loader_xfer_data),
EXPORT_SYMBOL_P(gBootArgs),
EXPORT_SYMBOL_P(gEntryPoint),
EXPORT_SYMBOL_P(gDeviceTree),
Expand All @@ -199,6 +206,7 @@ struct pongo_exports public_api[] = {
EXPORT_SYMBOL_P(sep_boot_hook),
EXPORT_SYMBOL_P(aes),
EXPORT_SYMBOL_P(_impure_ptr),
EXPORT_SYMBOL_P(loader_xfer_recv_size),
{.name = "___stack_chk_guard", .value = &f_stack_chk_guard},
{.name = "___stack_chk_fail", .value = &f_stack_chk_fail},
{.name = "_iprintf", .value = iprintf},
Expand Down Expand Up @@ -237,6 +245,6 @@ void* resolve_symbol(const char* name) {
break;
}
iprintf("resolve_symbol: missing symbol: %s\n", name);
iprintf("usbloader-linker could not load this module!!");
iprintf("usbloader-linker could not load this module!!\n");
return 0;
}
91 changes: 0 additions & 91 deletions src/kernel/alloc.c

This file was deleted.

12 changes: 9 additions & 3 deletions src/kernel/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ char pongo_sched_tick() {
goto out;
}
if (pongo_sched_head) {
struct task* tsk = pongo_sched_head;
struct task* volatile tsk = pongo_sched_head;
pongo_sched_head = pongo_sched_head->next;
if (tsk->flags & TASK_PLEASE_DEREF) {
tsk->flags &= ~TASK_PLEASE_DEREF;
task_release(tsk);
} else
if (tsk->flags & TASK_LINKED) {
_task_switch_asserted(tsk);
disable_interrupts();
Expand Down Expand Up @@ -178,19 +182,21 @@ __attribute__((noinline)) void pongo_entry_cached()

extern struct vm_space kernel_vm_space;
task_current()->vm_space = &kernel_vm_space;
preemption_over = 0;
task_current()->cpsr = 0x205;
task_current()->ttbr0 = kernel_vm_space.ttbr0;
task_current()->ttbr1 = kernel_vm_space.ttbr1 | kernel_vm_space.asid;
task_current()->proc = proc_create(NULL, "kernel", PROC_NO_VM);
task_current()->proc->vm_space = &kernel_vm_space;

void pongo_main_task();
task_register(&pongo_task, pongo_main_task);
task_link(&pongo_task);

/*
Set up FIQ timer
*/

preemption_over = 0;

enable_interrupts();

Expand Down
Loading

0 comments on commit 602f59a

Please sign in to comment.