Skip to content

Commit

Permalink
Start the kernel in the app
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jul 4, 2021
1 parent c37a04e commit ec76fd1
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 7 deletions.
5 changes: 1 addition & 4 deletions app/App.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ INFOPLIST_PREFIX_HEADER = $(BUILT_PRODUCTS_DIR)/infoplisticons.h
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CODE_SIGN_ENTITLEMENTS = app/iSH.entitlements

ENABLE_ON_DEMAND_RESOURCES = NO

HEADER_SEARCH_PATHS = $(inherited) $(SRCROOT) $(SRCROOT)/deps/libarchive/libarchive
OTHER_LDFLAGS = -ObjC
OTHER_LDFLAGS = -ObjC $(LINUX_APP_LDFLAGS)
7 changes: 7 additions & 0 deletions app/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "fs/devices.h"
#include "fs/path.h"

#if ISH_LINUX
#import "LinuxInterop.h"
#endif

@interface AppDelegate ()

@property BOOL exiting;
Expand Down Expand Up @@ -183,6 +187,9 @@ - (int)boot {
if (err < 0)
return err;
task_start(current);
#else
// TODO: fix issues with having multiple cpus
actuate_kernel("earlyprintk maxcpus=1");
#endif

return 0;
Expand Down
1 change: 1 addition & 0 deletions app/Linux.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ISH_KERNEL = linux
NINJA_TARGETS = deps/liblinux.a libfakefs.a libish_emu.a
LINUX_HOSTCC = env -u SDKROOT -u IPHONEOS_DEPLOYMENT_TARGET xcrun clang
GCC_PREPROCESSOR_DEFINITIONS = ISH_LINUX=1
LINUX_APP_LDFLAGS = -sectalign __DATA __percpu_first 1000 -sectalign __DATA __tracepoints 20 -force_load $(BUILT_PRODUCTS_DIR)/liblinux.a
16 changes: 16 additions & 0 deletions app/LinuxInterop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// LinuxInterop.c
// iSH
//
// Created by Theodore Dubois on 7/3/21.
//

#include <linux/start_kernel.h>
#include <string.h>

extern void run_kernel(void);

void actuate_kernel(char *cmdline) {
strcpy(boot_command_line, cmdline);
run_kernel();
}
13 changes: 13 additions & 0 deletions app/LinuxInterop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// LinuxInterop.h
// iSH
//
// Created by Theodore Dubois on 7/3/21.
//

#ifndef LinuxInterop_h
#define LinuxInterop_h

void actuate_kernel(char *cmdline);

#endif /* LinuxInterop_h */
6 changes: 6 additions & 0 deletions app/StaticLibLinux.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "StaticLib.xcconfig"

HEADER_SEARCH_PATHS = $(SRCROOT)/deps/linux/arch/ish/include $(MESON_BUILD_DIR)/deps/linux/arch/ish/include/generated $(SRCROOT)/deps/linux/include $(MESON_BUILD_DIR)/deps/linux/arch/ish/include/generated $(SRCROOT)/deps/linux/arch/ish/include/uapi $(MESON_BUILD_DIR)/deps/linux/arch/ish/include/generated/uapi $(SRCROOT)/deps/linux/include/uapi $(MESON_BUILD_DIR)/deps/linux/arch/ish/include/generated/uapi
LINK_WITH_STANDARD_LIBRARIES = NO
GCC_PREPROCESSOR_DEFINITIONS = __KERNEL__
OTHER_CFLAGS = -U__weak
212 changes: 209 additions & 3 deletions iSH.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions linux/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <linux/compiler_attributes.h>
#include <linux/start_kernel.h>
#include <linux/string.h>
#include <user/user.h>

extern void run_kernel(void);

Expand All @@ -13,5 +14,6 @@ int main(int argc, const char *argv[])
strcat(boot_command_line, argv[i]);
}
run_kernel();
for (;;) host_pause();
return 0;
}

0 comments on commit ec76fd1

Please sign in to comment.