Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tcp tunnel #119

Open
wants to merge 65 commits into
base: ipod_touch_2g_tunnel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e01813b
Started working on iPod Touch 2G
devos50 Dec 23, 2022
fefcf90
More work on iPod Touch 2G emulation
devos50 Dec 24, 2022
bcb4f83
Added NOR SPI peripheral
devos50 Dec 25, 2022
5ed081e
S5L8720 SPI seems to be functional
devos50 Dec 25, 2022
a8aa1cc
NOR SPI seems to work
devos50 Dec 26, 2022
7016eae
Implemented a first version of the PKE engine
devos50 Dec 27, 2022
d368c00
PKE engine seems to be operational
devos50 Dec 28, 2022
91b22b8
Fixed various things
devos50 Dec 28, 2022
07725f5
AES engine is correctly decrypting LLB payload
devos50 Jan 7, 2023
c386a81
Worked on LLB
devos50 Jan 8, 2023
b2b7110
Fixed SPI again
devos50 Jan 8, 2023
77da535
Working on iBoot
devos50 Jan 13, 2023
4f7625e
Hardcoded iBoot decryption keys
devos50 Jan 30, 2023
3e17ca7
Some work on LCD/MIPI DSI
devos50 Jan 31, 2023
463e8d8
Worked on several components
devos50 Feb 7, 2023
999255e
Got some of the NAND initializations working
devos50 Feb 12, 2023
fa67c82
Got the NAND working a bit more
devos50 Feb 12, 2023
4ba0092
Implemented missing registers
devos50 Jun 12, 2023
1f85f98
Circumventing NAND
devos50 Jun 18, 2023
ac405b5
Able to load kernel, with some hacks!
devos50 Jul 1, 2023
f260d84
Added workaround for device tree and several memory mappings
devos50 Jul 2, 2023
5b185bc
Got more peripherals up and running!
devos50 Jul 3, 2023
0b74ae5
Got some more stuff running
devos50 Jul 5, 2023
2889428
Mikey is loading
devos50 Jul 7, 2023
9a2d42c
Got NOR up and running on both SPI0 and SPI1
devos50 Jul 7, 2023
6c4f881
Several fixes and changes
devos50 Jul 8, 2023
1744cb2
Multiple fixes for SPI
devos50 Jul 12, 2023
dd673b6
Booting SpringBoard
devos50 Jul 27, 2023
37f8199
Booting up until lockdownd!
devos50 Jul 27, 2023
c3c1830
Update ipod_touch_fmss.c
zoe-vb Aug 10, 2023
9836218
Merge pull request #55 from zoe-vb/ipod_touch_2g
devos50 Aug 11, 2023
0a48ea3
Started working on SDIO
devos50 Aug 12, 2023
8ed16c6
Merge branch 'ipod_touch_2g' of github.com:devos50/qemu-ios into ipod…
devos50 Aug 12, 2023
ee22d61
Made some progress with the BCM4325
devos50 Aug 29, 2023
86be721
Got a tiny bit further in the boot process
devos50 Aug 30, 2023
cbc8c89
Got SDIO IRQ working
devos50 Sep 1, 2023
182f275
More work on SDIO/BCM4325
devos50 Sep 3, 2023
94972bf
BCM4325 driver gets past initialization!!
devos50 Sep 4, 2023
f7b6729
Device is activated!
devos50 Sep 6, 2023
cc21020
Started working on TVOut
devos50 Sep 6, 2023
0bdff11
Worked on TVOut
devos50 Sep 8, 2023
603dafd
LCD + Multitouch working!!
devos50 Nov 3, 2023
8b4c145
Prevent GUI grab
devos50 Nov 3, 2023
9390b5a
Home/power buttons working
devos50 Nov 4, 2023
4a95aea
Removed print statement
devos50 Nov 8, 2023
6024cbc
Made paths flexible
devos50 Nov 8, 2023
817beee
Added run instructions
devos50 Nov 8, 2023
374d3a3
Changed README.md
devos50 Nov 8, 2023
472781b
Update README.md
devos50 Nov 8, 2023
93121ee
fix the configure command for apple silicon macs
breakgimme Nov 8, 2023
1ad020b
Merge pull request #68 from breakgimme/patch-1
devos50 Nov 9, 2023
ce0ce0a
Different file paths on Microsoft Windows
spetterman66 Nov 23, 2023
6c18b04
Switch position of "extern" and "G_NORETURN"
spetterman66 Nov 23, 2023
65a80f9
Include disablement of the stack protector in the configure script
spetterman66 Nov 23, 2023
aaee2c4
Deleted workflow from IT2G branch
devos50 Nov 28, 2023
26bdb75
Merge pull request #82 from spetterman66/ipod_touch_2g
devos50 Dec 2, 2023
04eeb53
Check if Bootrom/NOR/NAND files exist before attempting to use
jvyden Dec 15, 2023
b4aacff
Fix NAND path check
jvyden Dec 15, 2023
c6f78c8
Merge pull request #93 from jvyden/ipod-2g-file-error-handling
devos50 Dec 16, 2023
09e689f
Update README.md with a schematic
devos50 Dec 16, 2023
be55c40
Update RUNNING.md
devos50 Dec 24, 2023
87dafcd
Update RUNNING.md
MrDiagnose Dec 24, 2023
ad39d64
Merge pull request #103 from MrDiagnose/patch-1
devos50 Dec 24, 2023
3ed141c
TCP TUNNEL compiled and Emulator working fine, Guest side to be tested
artifactrepo Dec 27, 2023
344662c
Merge branch 'ipod_touch_2g_tunnel' into tcp_tunnel
jeppojeps Jan 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RUNNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cd build
# On Intel Macs
../configure --target-list=arm-softmmu --extra-cflags=-I/usr/local/opt/openssl@3/include --extra-ldflags='-L/usr/local/opt/openssl@3/lib -lcrypto'


# On Apple Silicon Macs
../configure --enable-sdl --disable-cocoa --target-list=arm-softmmu --disable-capstone --disable-pie --disable-slirp --extra-cflags=-I/opt/homebrew/opt/openssl@3/include --extra-ldflags='-L/opt/homebrew/opt/openssl@3/lib -lcrypto'

Expand Down
2 changes: 1 addition & 1 deletion configs/devices/arm-softmmu/default.mak
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# CONFIG_TEST_DEVICES=n

CONFIG_ARM_VIRT=y

# These are selected by default when TCG is enabled, uncomment them to
# keep out of the build.
# CONFIG_CUBIEBOARD=n
Expand Down Expand Up @@ -45,3 +44,4 @@ CONFIG_ARM_VIRT=y
# CONFIG_FSL_IMX6UL=n
# CONFIG_ALLWINNER_H3=n
CONFIG_IPOD_TOUCH_2G=y

72 changes: 72 additions & 0 deletions hw/arm/guest-fds.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* QEMU TCP Tunnelling
*
* Copyright (c) 2019 Lev Aronsky <[email protected]>
*
* 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 retvaltriction, 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, EXPretvalS 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.
*/

#include <stdarg.h>

#include "hw/arm/guest-services/fds.h"
#include "cpu.h"

int32_t guest_svcs_fds[MAX_FD_COUNT] = { [0 ... MAX_FD_COUNT-1] = -1 };

int32_t qc_handle_close(CPUState *cpu, int32_t fd)
{
VERIFY_FD(fd);

int retval = -1;

if ((retval = close(guest_svcs_fds[fd])) < 0) {
guest_svcs_errno = errno;
} else {
// TODO: should this be in the "else" clause, or performed regardless?
guest_svcs_fds[fd] = -1;
}

return retval;
}

int32_t qc_handle_fcntl_getfl(CPUState *cpu, int32_t fd)
{
VERIFY_FD(fd);

int retval = -1;

if ((retval = fcntl(guest_svcs_fds[fd], F_GETFL)) < 0) {
guest_svcs_errno = errno;
}

return retval;
}

int32_t qc_handle_fcntl_setfl(CPUState *cpu, int32_t fd, int32_t flags)
{
VERIFY_FD(fd);

int retval = -1;

if ((retval = fcntl(guest_svcs_fds[fd], F_SETFL, flags)) < 0) {
guest_svcs_errno = errno;
}

return retval;
}
111 changes: 111 additions & 0 deletions hw/arm/guest-file.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* QEMU Host file guest access
*
* Copyright (c) 2020 Jonathan Afek <[email protected]>
*
* 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.
*/

#include "hw/arm/guest-services/file.h"
#include "cpu.h"

static int32_t file_fds[MAX_FILE_FDS] = { [0 ... MAX_FILE_FDS-1] = -1 };

void qc_file_open(uint64_t index, const char *filename)
{
if (index >= MAX_FILE_FDS) {
abort();
}
if (-1 != file_fds[index]) {
abort();
}
file_fds[index] = open(filename, O_RDWR);
if (-1 == file_fds[index]) {
abort();
}
}

int64_t qc_handle_write_file(CPUState *cpu, uint64_t buffer_guest_ptr,
uint64_t length, uint64_t offset, uint64_t index)
{
uint8_t buf[MAX_FILE_TRANSACTION_LEN];

if (index >= MAX_FILE_FDS) {
abort();
}
int fd = file_fds[index];
if (-1 == fd) {
abort();
}
if (offset != lseek(fd, offset, SEEK_SET)) {
abort();
}
if (length > MAX_FILE_TRANSACTION_LEN) {
abort();
}
cpu_memory_rw_debug(cpu, buffer_guest_ptr, &buf[0], length, 0);
if (length != write(fd, &buf[0], length)) {
abort();
}

return 0;
}

int64_t qc_handle_read_file(CPUState *cpu, uint64_t buffer_guest_ptr,
uint64_t length, uint64_t offset, uint64_t index)
{
uint8_t buf[MAX_FILE_TRANSACTION_LEN];
if (index >= MAX_FILE_FDS) {
abort();
}
int fd = file_fds[index];
if (-1 == fd) {
abort();
}
if (offset != lseek(fd, offset, SEEK_SET)) {
abort();
}
if (length > MAX_FILE_TRANSACTION_LEN) {
abort();
}
if (length != read(fd, &buf[0], length)) {
abort();
}
cpu_memory_rw_debug(cpu, buffer_guest_ptr, &buf[0], length, 1);

return 0;
}

int64_t qc_handle_size_file(uint64_t index)
{
struct stat st;

if (index >= MAX_FILE_FDS) {
abort();
}
int fd = file_fds[index];
if (-1 == fd) {
abort();
}
if (-1 == fstat(fd, &st)) {
abort();
}

return st.st_size;
}
178 changes: 178 additions & 0 deletions hw/arm/guest-services.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
* QEMU TCP Tunnelling
*
* Copyright (c) 2019 Lev Aronsky <[email protected]>
*
* 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.
*/

#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/arm/boot.h"
#include "exec/address-spaces.h"
#include "hw/misc/unimp.h"
#include "sysemu/sysemu.h"
#include "qemu/error-report.h"
#include "hw/platform-bus.h"
#include "hw/arm/ipod_touch_2g.h"
#include "cpu.h"

int32_t guest_svcs_errno = 0;

uint32_t qemu_call_status(CPUARMState *env)
{
// NOT USED FOR NOW
return 0;
}

void qemu_call(CPUARMState *env, uint32_t value)
{
CPUState *cpu = qemu_get_cpu(0);
qemu_call_t qcall;
uint64_t i = 0;

/* static uint8_t hooks_installed = false;

if (!value) {
// Special case: not a regular QEMU call. This is used by our
// kernel task port patch to notify of the readiness for the
// hook installation.

IPodTouchMachineState *nms = IPOD_TOUCH_MACHINE(qdev_get_machine());
KernelTrHookParams *hook = &nms->hook;

if (0 != hook->va) {
//install the hook here because we need the MMU to be already
//configured and all the memory mapped before installing the hook
xnu_hook_tr_copy_install(hook->va, hook->pa, hook->buf_va,
hook->buf_pa, hook->code, hook->code_size,
hook->buf_size, hook->scratch_reg);

}

if (!hooks_installed) {
for (i = 0; i < nms->hook_funcs_count; i++) {
xnu_hook_tr_copy_install(nms->hook_funcs[i].va,
nms->hook_funcs[i].pa,
nms->hook_funcs[i].buf_va,
nms->hook_funcs[i].buf_pa,
nms->hook_funcs[i].code,
nms->hook_funcs[i].code_size,
nms->hook_funcs[i].buf_size,
nms->hook_funcs[i].scratch_reg);
}
hooks_installed = true;
}

//emulate original opcode: str x20, [x23]
value = env->xregs[20];
cpu_memory_rw_debug(cpu, env->xregs[23], (uint8_t*) &value,
sizeof(value), 1);

return;
}
*/
// Read the request
cpu_memory_rw_debug(cpu, value, (uint8_t*) &qcall, sizeof(qcall), 0);

switch (qcall.call_number) {
// File Descriptors
case QC_CLOSE:
qcall.retval = qc_handle_close(cpu, qcall.args.close.fd);
break;
case QC_FCNTL:
switch (qcall.args.fcntl.cmd) {
case F_GETFL:
qcall.retval = qc_handle_fcntl_getfl(
cpu, qcall.args.fcntl.fd);
break;
case F_SETFL:
qcall.retval = qc_handle_fcntl_setfl(
cpu, qcall.args.fcntl.fd, qcall.args.fcntl.flags);
break;
default:
guest_svcs_errno = EINVAL;
qcall.retval = -1;
}
break;

// Socket API
case QC_SOCKET:
qcall.retval = qc_handle_socket(cpu, qcall.args.socket.domain,
qcall.args.socket.type,
qcall.args.socket.protocol);
break;
case QC_ACCEPT:
qcall.retval = qc_handle_accept(cpu, qcall.args.accept.socket,
qcall.args.accept.addr,
qcall.args.accept.addrlen);
break;
case QC_BIND:
qcall.retval = qc_handle_bind(cpu, qcall.args.bind.socket,
qcall.args.bind.addr,
qcall.args.bind.addrlen);
break;
case QC_CONNECT:
qcall.retval = qc_handle_connect(cpu, qcall.args.connect.socket,
qcall.args.connect.addr,
qcall.args.connect.addrlen);
break;
case QC_LISTEN:
qcall.retval = qc_handle_listen(cpu, qcall.args.listen.socket,
qcall.args.listen.backlog);
break;
case QC_RECV:
qcall.retval = qc_handle_recv(cpu, qcall.args.recv.socket,
qcall.args.recv.buffer,
qcall.args.recv.length,
qcall.args.recv.flags);
break;
case QC_SEND:
qcall.retval = qc_handle_send(cpu, qcall.args.send.socket,
qcall.args.send.buffer,
qcall.args.send.length,
qcall.args.send.flags);
break;
case QC_WRITE_FILE:
qcall.retval = qc_handle_write_file(cpu,
qcall.args.write_file.buffer_guest_ptr,
qcall.args.write_file.length,
qcall.args.write_file.offset,
qcall.args.write_file.index);
break;
case QC_READ_FILE:
qcall.retval = qc_handle_read_file(cpu,
qcall.args.read_file.buffer_guest_ptr,
qcall.args.read_file.length,
qcall.args.read_file.offset,
qcall.args.read_file.index);
break;
case QC_SIZE_FILE:
qcall.retval = qc_handle_size_file(qcall.args.size_file.index);
break;
default:
// TODO: handle unknown call numbers
break;
}

qcall.error = guest_svcs_errno;

// Write the response
cpu_memory_rw_debug(cpu, value, (uint8_t*) &qcall, sizeof(qcall), 1);
}
Loading