Skip to content

Commit

Permalink
Checkpoint, build 321 I think
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Miller committed Oct 15, 2022
1 parent ce20992 commit 410615e
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 22 deletions.
1 change: 1 addition & 0 deletions emu/cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static inline void do_cpuid(dword_t *eax, dword_t *ebx, dword_t *ecx, dword_t *e
*edx = (1 << 0) // fpu
| (1 << 15) // cmov
| (1 << 23) // mmx
| (1 << 25) // sse
| (1 << 26) // sse2
;
break;
Expand Down
4 changes: 2 additions & 2 deletions fs/fake.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ static void __attribute__((constructor)) init_fake_fdops() {

static int fakefs_mount(struct mount *mount) {
char db_path[PATH_MAX];
strcpy(db_path, mount->source);
strncpy(db_path, mount->source, PATH_MAX -1);
char *basename = strrchr(db_path, '/') + 1;
assert(strcmp(basename, "data") == 0);
strcpy(basename, "meta.db");
strncpy(basename, "meta.db", 8);

// do this now so rebuilding can use root_fd
int err = realfs.mount(mount);
Expand Down
9 changes: 5 additions & 4 deletions fs/proc/ish.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,18 @@ static int proc_ish_show_ips(struct proc_entry *UNUSED(entry), struct proc_data
char * int_ip = malloc(100);
char * int_dstaddr = malloc(100);
if(cursor->ifa_addr->sa_family == AF_INET) {
strcpy(type, "IF_INET");
strncpy(type, "IF_INET", 9);
} else {
strcpy(type, "IF_INET6");
strncpy(type, "IF_INET6", 9);
}
//cursor->ifa_addr->sa_family = AF_INET;
get_ip_str(cursor->ifa_addr, int_ip, 100);
char * mac = malloc(100);
if(cursor->ifa_dstaddr != NULL) {
if(cursor->ifa_dstaddr->sa_family == AF_INET) {
strcpy(type, "IF_INET");
strncpy(type, "IF_INET", 9);
} else {
strcpy(type, "IF_INET6");
strncpy(type, "IF_INET6", 9);
cursor->ifa_dstaddr->sa_family = AF_INET6;
}
get_ip_str(cursor->ifa_dstaddr, int_dstaddr, 100);
Expand All @@ -315,6 +315,7 @@ static int proc_ish_show_ips(struct proc_entry *UNUSED(entry), struct proc_data
);
free(int_ip);
free(int_flags);
free(int_dstaddr);
}
cursor = cursor->ifa_next;
}
Expand Down
32 changes: 32 additions & 0 deletions iSH-AOK.xcodeproj/xcshareddata/xcschemes/iSH.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,38 @@
ReferencedContainer = "container:iSH-AOK.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "MallocStackLogging"
value = ""
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "DYLD_INSERT_LIBRARIES"
value = "/usr/lib/libgmalloc.dylib"
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "PrefersMallocStackLoggingLite"
value = ""
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "MallocGuardEdges"
value = ""
isEnabled = "YES">
</AdditionalOption>
<AdditionalOption
key = "MallocScribble"
value = ""
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
1 change: 1 addition & 0 deletions kernel/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ syscall_t syscall_table[] = {
[157] = (syscall_t) sys_sched_getscheduler,
[158] = (syscall_t) sys_sched_yield,
[159] = (syscall_t) sys_sched_get_priority_max,
[160] = (syscall_t) sys_sched_get_priority_min,
[162] = (syscall_t) sys_nanosleep,
[163] = (syscall_t) sys_mremap,
[168] = (syscall_t) sys_poll,
Expand Down
17 changes: 10 additions & 7 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ static struct task *find_new_parent(struct task *task) {

noreturn void do_exit(int status) {
//atomic_l_lockf(0,__FILE__, __LINE__);
pthread_mutex_lock(&current->death_lock);
// if(!lock(current->death_lock))
// return; // Task is already in the process of being deleted, most likely by do_exit(). -mke
// pthread_mutex_lock(&current->death_lock);
if(!pthread_mutex_trylock(&current->death_lock)) {
goto EXIT;
} else {
//nanosleep(&lock_pause, NULL); // Stupid place holder
}

current->exiting = true;

Expand Down Expand Up @@ -151,8 +154,8 @@ noreturn void do_exit(int status) {
send_signal(parent, leader->exit_signal, info);
}

if (exit_hook != NULL)
exit_hook(current, status);
//if (exit_hook != NULL)
// exit_hook(current, status);
}

modify_critical_region_counter(current, -1, __FILE__, __LINE__);
Expand All @@ -163,7 +166,7 @@ noreturn void do_exit(int status) {
unlock(&pids_lock);
//atomic_l_unlockf();

pthread_exit(NULL);
EXIT:pthread_exit(NULL);
}

noreturn void do_exit_group(int status) {
Expand Down Expand Up @@ -198,9 +201,9 @@ noreturn void do_exit_group(int status) {
notify(&task->group->stopped_cond);
}

unlock(&group->lock);
unlock(&pids_lock);
modify_critical_region_counter(current, -1, __FILE__, __LINE__);
unlock(&group->lock);
do_exit(status);
}

Expand Down
7 changes: 7 additions & 0 deletions kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ int_t sys_sched_get_priority_max(int_t policy) {
return _EINVAL;
}

int_t sys_sched_get_priority_min(int_t policy) {
STRACE("sched_get_priority_min(%d)", policy);
if (policy == 0)
return 0;
return _EINVAL;
}

int_t sys_ioprio_get(int_t UNUSED(which), int_t UNUSED(who), int_t UNUSED(ioprio)) {
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions kernel/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ int_t sys_sched_getparam(pid_t_ pid, addr_t param_addr);
int_t sys_sched_getscheduler(pid_t_ UNUSED(pid));
int_t sys_sched_setscheduler(pid_t_ UNUSED(pid), int_t policy, addr_t param_addr);
int_t sys_sched_get_priority_max(int_t policy);
int_t sys_sched_get_priority_min(int_t policy);

int_t sys_ioprio_set(int_t UNUSED(which), int_t UNUSED(who), int_t UNUSED(ioprio));
int_t sys_ioprio_get(int_t UNUSED(which), int_t UNUSED(who), int_t UNUSED(ioprio));
Expand Down
14 changes: 5 additions & 9 deletions util/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static inline void _read_unlock(wrlock_t *lock, __attribute__((unused)) const ch
printk("ERROR: read_unlock(%x) error(PID: %d Process: %s count %d) (%s:%d)\n",lock, current_pid(), current_comm(), lock->val, file, line);
lock->val = 0;
lock->pid = -1;
strcpy(lock->comm, "");
strncpy(lock->comm, "", 1);
modify_locks_held_count_wrapper(-1);
//modify_critical_region_counter_wrapper(-1, __FILE__, __LINE__);
//STRACE("read_unlock(%x, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line);
Expand Down Expand Up @@ -362,7 +362,7 @@ static inline void _write_unlock(wrlock_t *lock, __attribute__((unused)) const c
//assert(lock->val == -1);
lock->val = lock->line = lock->pid = 0;
lock->pid = -1;
strcpy(lock->comm, "");
strncpy(lock->comm, "", 1);
//STRACE("write_unlock(%x, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line);
lock->file = NULL;
modify_locks_held_count_wrapper(-1);
Expand Down Expand Up @@ -392,10 +392,8 @@ static inline void __write_lock(wrlock_t *lock, const char *file, int line) { //
lock->file = file;
lock->line = line;
lock->pid = current_pid();
char *IhateC = malloc(16);
IhateC = current_comm();
if(lock->pid > 9)
strncpy((char *)lock->comm, IhateC, 16);
if(lock->pid > 9)
strncpy((char *)lock->comm, current_comm(), 16);
//STRACE("write_lock(%x, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line);
//modify_critical_region_counter_wrapper(-1,__FILE__, __LINE__);
}
Expand Down Expand Up @@ -560,10 +558,8 @@ static inline void _read_lock(wrlock_t *lock, __attribute__((unused)) const char
}

lock->pid = current_pid();
char *IhateC = malloc(16);
IhateC = current_comm();
if(lock->pid > 9)
strncpy((char *)lock->comm, IhateC, 16);
strncpy((char *)lock->comm, current_comm(), 16);
//strncpy(lock->comm, current_comm(), 16);
modify_critical_region_counter_wrapper(-1, __FILE__, __LINE__);
//STRACE("read_lock(%d, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line);
Expand Down

0 comments on commit 410615e

Please sign in to comment.