Passing kernel state to syscalls via arguments

This commit is contained in:
Alexandro Sanchez Bach 2017-10-28 23:46:20 +02:00
parent 06c459abce
commit 8ca6d1cc41
50 changed files with 728 additions and 883 deletions

View file

@ -34,7 +34,7 @@
#include <cstring>
#define SYSCALL(name, flags) { wrap(name), #name, flags }
#define SYSCALL_WRAP(name, flags) { wrap(name), #name, flags }
namespace sys {
@ -42,155 +42,155 @@ LV2::LV2(std::shared_ptr<mem::Memory> memory, U32 fw_type) : memory(std::move(me
// Initialize syscall table
memset(syscalls, 0, sizeof(syscalls));
if (fw_type & (LV2_CEX | LV2_DEX | LV2_DECR)) {
syscalls[0x001] = SYSCALL(sys_process_getpid, LV2_NONE);
syscalls[0x003] = SYSCALL(sys_process_exit, LV2_NONE);
syscalls[0x00E] = SYSCALL(sys_process_is_spu_lock_line_reservation_address, LV2_NONE);
syscalls[0x012] = SYSCALL(sys_process_getppid, LV2_NONE);
syscalls[0x016] = SYSCALL(sys_process_exit, LV2_NONE);
syscalls[0x019] = SYSCALL(sys_process_get_sdk_version, LV2_NONE);
syscalls[0x01E] = SYSCALL(sys_process_get_paramsfo, LV2_NONE);
syscalls[0x029] = SYSCALL(sys_ppu_thread_exit, LV2_NONE);
syscalls[0x02C] = SYSCALL(sys_ppu_thread_join, LV2_NONE);
syscalls[0x030] = SYSCALL(sys_ppu_thread_get_priority, LV2_NONE);
syscalls[0x031] = SYSCALL(sys_ppu_thread_get_stack_information, LV2_NONE);
syscalls[0x034] = SYSCALL(sys_ppu_thread_create, LV2_NONE);
syscalls[0x035] = SYSCALL(sys_ppu_thread_start, LV2_NONE);
syscalls[0x052] = SYSCALL(sys_event_flag_create, LV2_NONE);
syscalls[0x053] = SYSCALL(sys_event_flag_destroy, LV2_NONE);
syscalls[0x055] = SYSCALL(sys_event_flag_wait, LV2_NONE);
syscalls[0x056] = SYSCALL(sys_event_flag_trywait, LV2_NONE);
syscalls[0x057] = SYSCALL(sys_event_flag_set, LV2_NONE);
syscalls[0x05A] = SYSCALL(sys_semaphore_create, LV2_NONE);
syscalls[0x05B] = SYSCALL(sys_semaphore_destroy, LV2_NONE);
syscalls[0x05C] = SYSCALL(sys_semaphore_wait, LV2_NONE);
syscalls[0x05D] = SYSCALL(sys_semaphore_trywait, LV2_NONE);
syscalls[0x05E] = SYSCALL(sys_semaphore_post, LV2_NONE);
syscalls[0x05F] = SYSCALL(sys_lwmutex_create, LV2_NONE);
syscalls[0x060] = SYSCALL(sys_lwmutex_destroy, LV2_NONE);
syscalls[0x061] = SYSCALL(sys_lwmutex_lock, LV2_NONE);
syscalls[0x062] = SYSCALL(sys_lwmutex_trylock, LV2_NONE);
syscalls[0x063] = SYSCALL(sys_lwmutex_unlock, LV2_NONE);
syscalls[0x064] = SYSCALL(sys_mutex_create, LV2_NONE);
syscalls[0x065] = SYSCALL(sys_mutex_destroy, LV2_NONE);
syscalls[0x066] = SYSCALL(sys_mutex_lock, LV2_NONE);
syscalls[0x067] = SYSCALL(sys_mutex_trylock, LV2_NONE);
syscalls[0x068] = SYSCALL(sys_mutex_unlock, LV2_NONE);
syscalls[0x069] = SYSCALL(sys_cond_create, LV2_NONE);
syscalls[0x06A] = SYSCALL(sys_cond_destroy, LV2_NONE);
syscalls[0x06B] = SYSCALL(sys_cond_wait, LV2_NONE);
syscalls[0x06C] = SYSCALL(sys_cond_signal, LV2_NONE);
syscalls[0x06D] = SYSCALL(sys_cond_signal_all, LV2_NONE);
syscalls[0x06E] = SYSCALL(sys_cond_signal_to, LV2_NONE);
syscalls[0x06F] = SYSCALL(sys_lwcond_create, LV2_NONE);
syscalls[0x070] = SYSCALL(sys_lwcond_destroy, LV2_NONE);
syscalls[0x071] = SYSCALL(sys_lwcond_queue_wait, LV2_NONE);
syscalls[0x072] = SYSCALL(sys_semaphore_get_value, LV2_NONE);
syscalls[0x073] = SYSCALL(sys_lwcond_signal, LV2_NONE);
syscalls[0x074] = SYSCALL(sys_lwcond_signal_all, LV2_NONE);
syscalls[0x076] = SYSCALL(sys_event_flag_clear, LV2_NONE);
syscalls[0x080] = SYSCALL(sys_event_queue_create, LV2_NONE);
syscalls[0x081] = SYSCALL(sys_event_queue_destroy, LV2_NONE);
syscalls[0x082] = SYSCALL(sys_event_queue_receive, LV2_NONE);
syscalls[0x084] = SYSCALL(sys_event_flag_cancel, LV2_NONE);
syscalls[0x086] = SYSCALL(sys_event_port_create, LV2_NONE);
syscalls[0x087] = SYSCALL(sys_event_port_destroy, LV2_NONE);
syscalls[0x088] = SYSCALL(sys_event_port_connect_local, LV2_NONE);
syscalls[0x08B] = SYSCALL(sys_event_flag_get, LV2_NONE);
syscalls[0x08D] = SYSCALL(sys_timer_usleep, LV2_NONE);
syscalls[0x08E] = SYSCALL(sys_timer_sleep, LV2_NONE);
syscalls[0x090] = SYSCALL(sys_time_get_timezone, LV2_NONE);
syscalls[0x091] = SYSCALL(sys_time_get_current_time, LV2_NONE);
syscalls[0x093] = SYSCALL(sys_time_get_timebase_frequency, LV2_NONE);
//syscalls[0x096] = SYSCALL(sys_raw_spu_create_interrupt_tag, LV2_NONE);
//syscalls[0x097] = SYSCALL(sys_raw_spu_set_int_mask, LV2_NONE);
//syscalls[0x098] = SYSCALL(sys_raw_spu_get_int_mask, LV2_NONE);
//syscalls[0x099] = SYSCALL(sys_raw_spu_set_int_stat, LV2_NONE);
//syscalls[0x09A] = SYSCALL(sys_raw_spu_get_int_stat, LV2_NONE);
//syscalls[0x09B] = SYSCALL(sys_spu_image_get_information, LV2_NONE);
//syscalls[0x09C] = SYSCALL(sys_spu_image_open, LV2_NONE);
//syscalls[0x09D] = SYSCALL(sys_spu_image_import, LV2_NONE);
//syscalls[0x09E] = SYSCALL(sys_spu_image_close, LV2_NONE);
//syscalls[0x09F] = SYSCALL(sys_raw_spu_load, LV2_NONE);
//syscalls[0x0A0] = SYSCALL(sys_raw_spu_create, LV2_NONE);
//syscalls[0x0A1] = SYSCALL(sys_raw_spu_destroy, LV2_NONE);
//syscalls[0x0A3] = SYSCALL(sys_raw_spu_read_puint_mb, LV2_NONE);
//syscalls[0x0A5] = SYSCALL(sys_spu_thread_get_exit_status, LV2_NONE);
//syscalls[0x0A6] = SYSCALL(sys_spu_thread_set_argument, LV2_NONE);
//syscalls[0x0A7] = SYSCALL(sys_spu_thread_group_start_on_exit, LV2_NONE);
syscalls[0x0A9] = SYSCALL(sys_spu_initialize, LV2_NONE);
syscalls[0x0AA] = SYSCALL(sys_spu_thread_group_create, LV2_NONE);
syscalls[0x0AB] = SYSCALL(sys_spu_thread_group_destroy, LV2_NONE);
syscalls[0x0AC] = SYSCALL(sys_spu_thread_initialize, LV2_NONE);
syscalls[0x0AD] = SYSCALL(sys_spu_thread_group_start, LV2_NONE);
//syscalls[0x0AE] = SYSCALL(sys_spu_thread_group_suspend, LV2_NONE);
//syscalls[0x0AF] = SYSCALL(sys_spu_thread_group_resume, LV2_NONE);
//syscalls[0x0B0] = SYSCALL(sys_spu_thread_group_yield, LV2_NONE);
//syscalls[0x0B1] = SYSCALL(sys_spu_thread_group_terminate, LV2_NONE);
syscalls[0x0B2] = SYSCALL(sys_spu_thread_group_join, LV2_NONE);
//syscalls[0x0B3] = SYSCALL(sys_spu_thread_group_set_priority, LV2_NONE);
//syscalls[0x0B4] = SYSCALL(sys_spu_thread_group_get_priority, LV2_NONE);
//syscalls[0x0B5] = SYSCALL(sys_spu_thread_write_ls, LV2_NONE);
syscalls[0x0B6] = SYSCALL(sys_spu_thread_read_ls, LV2_NONE);
//syscalls[0x0B8] = SYSCALL(sys_spu_thread_write_snr, LV2_NONE);
syscalls[0x0B9] = SYSCALL(sys_spu_thread_group_connect_event, LV2_NONE);
//syscalls[0x0BA] = SYSCALL(sys_spu_thread_group_disconnect_event, LV2_NONE);
//syscalls[0x0BB] = SYSCALL(sys_spu_thread_set_spu_cfg, LV2_NONE);
//syscalls[0x0BC] = SYSCALL(sys_spu_thread_get_spu_cfg, LV2_NONE);
//syscalls[0x0BE] = SYSCALL(sys_spu_thread_write_spu_mb, LV2_NONE);
//syscalls[0x0BF] = SYSCALL(sys_spu_thread_connect_event, LV2_NONE);
//syscalls[0x0C0] = SYSCALL(sys_spu_thread_disconnect_event, LV2_NONE);
//syscalls[0x0C1] = SYSCALL(sys_spu_thread_bind_queue, LV2_NONE);
//syscalls[0x0C2] = SYSCALL(sys_spu_thread_unbind_queue, LV2_NONE);
//syscalls[0x0C4] = SYSCALL(sys_raw_spu_set_spu_cfg, LV2_NONE);
//syscalls[0x0C5] = SYSCALL(sys_raw_spu_get_spu_cfg, LV2_NONE);
//syscalls[0x0C6] = SYSCALL(sys_spu_thread_recover_page_fault, LV2_NONE);
//syscalls[0x0C7] = SYSCALL(sys_raw_spu_recover_page_fault, LV2_NONE);
syscalls[0x0FB] = SYSCALL(sys_spu_thread_group_connect_event_all_threads, LV2_NONE);
//syscalls[0x0FC] = SYSCALL(sys_spu_thread_group_disconnect_event_all_threads, LV2_NONE);
syscalls[0x14A] = SYSCALL(sys_mmapper_allocate_address, LV2_NONE);
syscalls[0x14C] = SYSCALL(sys_mmapper_allocate_shared_memory, LV2_NONE);
syscalls[0x15C] = SYSCALL(sys_memory_allocate, LV2_NONE);
syscalls[0x15D] = SYSCALL(sys_memory_free, LV2_NONE);
syscalls[0x155] = SYSCALL(sys_memory_container_create2, LV2_NONE);
syscalls[0x15E] = SYSCALL(sys_memory_allocate_from_container, LV2_NONE);
syscalls[0x15F] = SYSCALL(sys_memory_get_page_attribute, LV2_NONE);
syscalls[0x160] = SYSCALL(sys_memory_get_user_memory_size, LV2_NONE);
syscalls[0x161] = SYSCALL(sys_memory_get_user_memory_stat, LV2_NONE);
syscalls[0x193] = SYSCALL(sys_tty_write, LV2_NONE);
syscalls[0x1D1] = SYSCALL(sys_prx_load_module_list, LV2_NONE);
syscalls[0x1E0] = SYSCALL(sys_prx_load_module, LV2_NONE);
syscalls[0x1E1] = SYSCALL(sys_prx_start_module, LV2_NONE);
syscalls[0x1E4] = SYSCALL(sys_prx_register_module, LV2_NONE);
syscalls[0x1E6] = SYSCALL(sys_prx_register_library, LV2_NONE);
syscalls[0x1EE] = SYSCALL(sys_prx_get_module_list, LV2_NONE);
syscalls[0x1F0] = SYSCALL(sys_prx_get_module_id_by_name, LV2_NONE);
syscalls[0x1FE] = SYSCALL(sys_hid_0x1FE, LV2_NONE);
syscalls[0x200] = SYSCALL(sys_hid_0x200, LV2_NONE);
syscalls[0x202] = SYSCALL(sys_hid_0x202, LV2_NONE);
syscalls[0x204] = SYSCALL(sys_config_open, LV2_NONE);
syscalls[0x205] = SYSCALL(sys_config_close, LV2_NONE);
syscalls[0x207] = SYSCALL(sys_config_add_service_listener, LV2_NONE);
syscalls[0x26D] = SYSCALL(sys_gamepad_ycon_if, LV2_NONE);
syscalls[0x29C] = SYSCALL(sys_rsx_memory_allocate, LV2_NONE);
syscalls[0x29E] = SYSCALL(sys_rsx_context_allocate, LV2_NONE);
syscalls[0x2A0] = SYSCALL(sys_rsx_context_iomap, LV2_NONE);
syscalls[0x2A1] = SYSCALL(sys_rsx_context_iounmap, LV2_NONE);
syscalls[0x2A2] = SYSCALL(sys_rsx_context_attribute, LV2_NONE);
syscalls[0x2A3] = SYSCALL(sys_rsx_device_map, LV2_NONE);
syscalls[0x2A5] = SYSCALL(sys_rsx_attribute, LV2_NONE);
syscalls[0x321] = SYSCALL(sys_fs_open, LV2_NONE);
syscalls[0x322] = SYSCALL(sys_fs_read, LV2_NONE);
syscalls[0x323] = SYSCALL(sys_fs_write, LV2_NONE);
syscalls[0x324] = SYSCALL(sys_fs_close, LV2_NONE);
syscalls[0x328] = SYSCALL(sys_fs_stat, LV2_NONE);
syscalls[0x329] = SYSCALL(sys_fs_fstat, LV2_NONE);
syscalls[0x331] = SYSCALL(sys_fs_fcntl, LV2_NONE);
syscalls[0x332] = SYSCALL(sys_fs_lseek, LV2_NONE);
syscalls[0x367] = SYSCALL(sys_ss_access_control_engine, LV2_DBG);
syscalls[0x3DC] = SYSCALL(sys_dbg_ppu_exception_handler, LV2_NONE);
syscalls[0x001] = SYSCALL_WRAP(sys_process_getpid, LV2_NONE);
syscalls[0x003] = SYSCALL_WRAP(sys_process_exit, LV2_NONE);
syscalls[0x00E] = SYSCALL_WRAP(sys_process_is_spu_lock_line_reservation_address, LV2_NONE);
syscalls[0x012] = SYSCALL_WRAP(sys_process_getppid, LV2_NONE);
syscalls[0x016] = SYSCALL_WRAP(sys_process_exit, LV2_NONE);
syscalls[0x019] = SYSCALL_WRAP(sys_process_get_sdk_version, LV2_NONE);
syscalls[0x01E] = SYSCALL_WRAP(sys_process_get_paramsfo, LV2_NONE);
syscalls[0x029] = SYSCALL_WRAP(sys_ppu_thread_exit, LV2_NONE);
syscalls[0x02C] = SYSCALL_WRAP(sys_ppu_thread_join, LV2_NONE);
syscalls[0x030] = SYSCALL_WRAP(sys_ppu_thread_get_priority, LV2_NONE);
syscalls[0x031] = SYSCALL_WRAP(sys_ppu_thread_get_stack_information, LV2_NONE);
syscalls[0x034] = SYSCALL_WRAP(sys_ppu_thread_create, LV2_NONE);
syscalls[0x035] = SYSCALL_WRAP(sys_ppu_thread_start, LV2_NONE);
syscalls[0x052] = SYSCALL_WRAP(sys_event_flag_create, LV2_NONE);
syscalls[0x053] = SYSCALL_WRAP(sys_event_flag_destroy, LV2_NONE);
syscalls[0x055] = SYSCALL_WRAP(sys_event_flag_wait, LV2_NONE);
syscalls[0x056] = SYSCALL_WRAP(sys_event_flag_trywait, LV2_NONE);
syscalls[0x057] = SYSCALL_WRAP(sys_event_flag_set, LV2_NONE);
syscalls[0x05A] = SYSCALL_WRAP(sys_semaphore_create, LV2_NONE);
syscalls[0x05B] = SYSCALL_WRAP(sys_semaphore_destroy, LV2_NONE);
syscalls[0x05C] = SYSCALL_WRAP(sys_semaphore_wait, LV2_NONE);
syscalls[0x05D] = SYSCALL_WRAP(sys_semaphore_trywait, LV2_NONE);
syscalls[0x05E] = SYSCALL_WRAP(sys_semaphore_post, LV2_NONE);
syscalls[0x05F] = SYSCALL_WRAP(sys_lwmutex_create, LV2_NONE);
syscalls[0x060] = SYSCALL_WRAP(sys_lwmutex_destroy, LV2_NONE);
syscalls[0x061] = SYSCALL_WRAP(sys_lwmutex_lock, LV2_NONE);
syscalls[0x062] = SYSCALL_WRAP(sys_lwmutex_trylock, LV2_NONE);
syscalls[0x063] = SYSCALL_WRAP(sys_lwmutex_unlock, LV2_NONE);
syscalls[0x064] = SYSCALL_WRAP(sys_mutex_create, LV2_NONE);
syscalls[0x065] = SYSCALL_WRAP(sys_mutex_destroy, LV2_NONE);
syscalls[0x066] = SYSCALL_WRAP(sys_mutex_lock, LV2_NONE);
syscalls[0x067] = SYSCALL_WRAP(sys_mutex_trylock, LV2_NONE);
syscalls[0x068] = SYSCALL_WRAP(sys_mutex_unlock, LV2_NONE);
syscalls[0x069] = SYSCALL_WRAP(sys_cond_create, LV2_NONE);
syscalls[0x06A] = SYSCALL_WRAP(sys_cond_destroy, LV2_NONE);
syscalls[0x06B] = SYSCALL_WRAP(sys_cond_wait, LV2_NONE);
syscalls[0x06C] = SYSCALL_WRAP(sys_cond_signal, LV2_NONE);
syscalls[0x06D] = SYSCALL_WRAP(sys_cond_signal_all, LV2_NONE);
syscalls[0x06E] = SYSCALL_WRAP(sys_cond_signal_to, LV2_NONE);
syscalls[0x06F] = SYSCALL_WRAP(sys_lwcond_create, LV2_NONE);
syscalls[0x070] = SYSCALL_WRAP(sys_lwcond_destroy, LV2_NONE);
syscalls[0x071] = SYSCALL_WRAP(sys_lwcond_queue_wait, LV2_NONE);
syscalls[0x072] = SYSCALL_WRAP(sys_semaphore_get_value, LV2_NONE);
syscalls[0x073] = SYSCALL_WRAP(sys_lwcond_signal, LV2_NONE);
syscalls[0x074] = SYSCALL_WRAP(sys_lwcond_signal_all, LV2_NONE);
syscalls[0x076] = SYSCALL_WRAP(sys_event_flag_clear, LV2_NONE);
syscalls[0x080] = SYSCALL_WRAP(sys_event_queue_create, LV2_NONE);
syscalls[0x081] = SYSCALL_WRAP(sys_event_queue_destroy, LV2_NONE);
syscalls[0x082] = SYSCALL_WRAP(sys_event_queue_receive, LV2_NONE);
syscalls[0x084] = SYSCALL_WRAP(sys_event_flag_cancel, LV2_NONE);
syscalls[0x086] = SYSCALL_WRAP(sys_event_port_create, LV2_NONE);
syscalls[0x087] = SYSCALL_WRAP(sys_event_port_destroy, LV2_NONE);
syscalls[0x088] = SYSCALL_WRAP(sys_event_port_connect_local, LV2_NONE);
syscalls[0x08B] = SYSCALL_WRAP(sys_event_flag_get, LV2_NONE);
syscalls[0x08D] = SYSCALL_WRAP(sys_timer_usleep, LV2_NONE);
syscalls[0x08E] = SYSCALL_WRAP(sys_timer_sleep, LV2_NONE);
syscalls[0x090] = SYSCALL_WRAP(sys_time_get_timezone, LV2_NONE);
syscalls[0x091] = SYSCALL_WRAP(sys_time_get_current_time, LV2_NONE);
syscalls[0x093] = SYSCALL_WRAP(sys_time_get_timebase_frequency, LV2_NONE);
//syscalls[0x096] = SYSCALL_WRAP(sys_raw_spu_create_interrupt_tag, LV2_NONE);
//syscalls[0x097] = SYSCALL_WRAP(sys_raw_spu_set_int_mask, LV2_NONE);
//syscalls[0x098] = SYSCALL_WRAP(sys_raw_spu_get_int_mask, LV2_NONE);
//syscalls[0x099] = SYSCALL_WRAP(sys_raw_spu_set_int_stat, LV2_NONE);
//syscalls[0x09A] = SYSCALL_WRAP(sys_raw_spu_get_int_stat, LV2_NONE);
//syscalls[0x09B] = SYSCALL_WRAP(sys_spu_image_get_information, LV2_NONE);
//syscalls[0x09C] = SYSCALL_WRAP(sys_spu_image_open, LV2_NONE);
//syscalls[0x09D] = SYSCALL_WRAP(sys_spu_image_import, LV2_NONE);
//syscalls[0x09E] = SYSCALL_WRAP(sys_spu_image_close, LV2_NONE);
//syscalls[0x09F] = SYSCALL_WRAP(sys_raw_spu_load, LV2_NONE);
//syscalls[0x0A0] = SYSCALL_WRAP(sys_raw_spu_create, LV2_NONE);
//syscalls[0x0A1] = SYSCALL_WRAP(sys_raw_spu_destroy, LV2_NONE);
//syscalls[0x0A3] = SYSCALL_WRAP(sys_raw_spu_read_puint_mb, LV2_NONE);
//syscalls[0x0A5] = SYSCALL_WRAP(sys_spu_thread_get_exit_status, LV2_NONE);
//syscalls[0x0A6] = SYSCALL_WRAP(sys_spu_thread_set_argument, LV2_NONE);
//syscalls[0x0A7] = SYSCALL_WRAP(sys_spu_thread_group_start_on_exit, LV2_NONE);
syscalls[0x0A9] = SYSCALL_WRAP(sys_spu_initialize, LV2_NONE);
syscalls[0x0AA] = SYSCALL_WRAP(sys_spu_thread_group_create, LV2_NONE);
syscalls[0x0AB] = SYSCALL_WRAP(sys_spu_thread_group_destroy, LV2_NONE);
syscalls[0x0AC] = SYSCALL_WRAP(sys_spu_thread_initialize, LV2_NONE);
syscalls[0x0AD] = SYSCALL_WRAP(sys_spu_thread_group_start, LV2_NONE);
//syscalls[0x0AE] = SYSCALL_WRAP(sys_spu_thread_group_suspend, LV2_NONE);
//syscalls[0x0AF] = SYSCALL_WRAP(sys_spu_thread_group_resume, LV2_NONE);
//syscalls[0x0B0] = SYSCALL_WRAP(sys_spu_thread_group_yield, LV2_NONE);
//syscalls[0x0B1] = SYSCALL_WRAP(sys_spu_thread_group_terminate, LV2_NONE);
syscalls[0x0B2] = SYSCALL_WRAP(sys_spu_thread_group_join, LV2_NONE);
//syscalls[0x0B3] = SYSCALL_WRAP(sys_spu_thread_group_set_priority, LV2_NONE);
//syscalls[0x0B4] = SYSCALL_WRAP(sys_spu_thread_group_get_priority, LV2_NONE);
//syscalls[0x0B5] = SYSCALL_WRAP(sys_spu_thread_write_ls, LV2_NONE);
syscalls[0x0B6] = SYSCALL_WRAP(sys_spu_thread_read_ls, LV2_NONE);
//syscalls[0x0B8] = SYSCALL_WRAP(sys_spu_thread_write_snr, LV2_NONE);
syscalls[0x0B9] = SYSCALL_WRAP(sys_spu_thread_group_connect_event, LV2_NONE);
//syscalls[0x0BA] = SYSCALL_WRAP(sys_spu_thread_group_disconnect_event, LV2_NONE);
//syscalls[0x0BB] = SYSCALL_WRAP(sys_spu_thread_set_spu_cfg, LV2_NONE);
//syscalls[0x0BC] = SYSCALL_WRAP(sys_spu_thread_get_spu_cfg, LV2_NONE);
//syscalls[0x0BE] = SYSCALL_WRAP(sys_spu_thread_write_spu_mb, LV2_NONE);
//syscalls[0x0BF] = SYSCALL_WRAP(sys_spu_thread_connect_event, LV2_NONE);
//syscalls[0x0C0] = SYSCALL_WRAP(sys_spu_thread_disconnect_event, LV2_NONE);
//syscalls[0x0C1] = SYSCALL_WRAP(sys_spu_thread_bind_queue, LV2_NONE);
//syscalls[0x0C2] = SYSCALL_WRAP(sys_spu_thread_unbind_queue, LV2_NONE);
//syscalls[0x0C4] = SYSCALL_WRAP(sys_raw_spu_set_spu_cfg, LV2_NONE);
//syscalls[0x0C5] = SYSCALL_WRAP(sys_raw_spu_get_spu_cfg, LV2_NONE);
//syscalls[0x0C6] = SYSCALL_WRAP(sys_spu_thread_recover_page_fault, LV2_NONE);
//syscalls[0x0C7] = SYSCALL_WRAP(sys_raw_spu_recover_page_fault, LV2_NONE);
syscalls[0x0FB] = SYSCALL_WRAP(sys_spu_thread_group_connect_event_all_threads, LV2_NONE);
//syscalls[0x0FC] = SYSCALL_WRAP(sys_spu_thread_group_disconnect_event_all_threads, LV2_NONE);
syscalls[0x14A] = SYSCALL_WRAP(sys_mmapper_allocate_address, LV2_NONE);
syscalls[0x14C] = SYSCALL_WRAP(sys_mmapper_allocate_shared_memory, LV2_NONE);
syscalls[0x15C] = SYSCALL_WRAP(sys_memory_allocate, LV2_NONE);
syscalls[0x15D] = SYSCALL_WRAP(sys_memory_free, LV2_NONE);
syscalls[0x155] = SYSCALL_WRAP(sys_memory_container_create2, LV2_NONE);
syscalls[0x15E] = SYSCALL_WRAP(sys_memory_allocate_from_container, LV2_NONE);
syscalls[0x15F] = SYSCALL_WRAP(sys_memory_get_page_attribute, LV2_NONE);
syscalls[0x160] = SYSCALL_WRAP(sys_memory_get_user_memory_size, LV2_NONE);
syscalls[0x161] = SYSCALL_WRAP(sys_memory_get_user_memory_stat, LV2_NONE);
syscalls[0x193] = SYSCALL_WRAP(sys_tty_write, LV2_NONE);
syscalls[0x1D1] = SYSCALL_WRAP(sys_prx_load_module_list, LV2_NONE);
syscalls[0x1E0] = SYSCALL_WRAP(sys_prx_load_module, LV2_NONE);
syscalls[0x1E1] = SYSCALL_WRAP(sys_prx_start_module, LV2_NONE);
syscalls[0x1E4] = SYSCALL_WRAP(sys_prx_register_module, LV2_NONE);
syscalls[0x1E6] = SYSCALL_WRAP(sys_prx_register_library, LV2_NONE);
syscalls[0x1EE] = SYSCALL_WRAP(sys_prx_get_module_list, LV2_NONE);
syscalls[0x1F0] = SYSCALL_WRAP(sys_prx_get_module_id_by_name, LV2_NONE);
syscalls[0x1FE] = SYSCALL_WRAP(sys_hid_0x1FE, LV2_NONE);
syscalls[0x200] = SYSCALL_WRAP(sys_hid_0x200, LV2_NONE);
syscalls[0x202] = SYSCALL_WRAP(sys_hid_0x202, LV2_NONE);
syscalls[0x204] = SYSCALL_WRAP(sys_config_open, LV2_NONE);
syscalls[0x205] = SYSCALL_WRAP(sys_config_close, LV2_NONE);
syscalls[0x207] = SYSCALL_WRAP(sys_config_add_service_listener, LV2_NONE);
syscalls[0x26D] = SYSCALL_WRAP(sys_gamepad_ycon_if, LV2_NONE);
syscalls[0x29C] = SYSCALL_WRAP(sys_rsx_memory_allocate, LV2_NONE);
syscalls[0x29E] = SYSCALL_WRAP(sys_rsx_context_allocate, LV2_NONE);
syscalls[0x2A0] = SYSCALL_WRAP(sys_rsx_context_iomap, LV2_NONE);
syscalls[0x2A1] = SYSCALL_WRAP(sys_rsx_context_iounmap, LV2_NONE);
syscalls[0x2A2] = SYSCALL_WRAP(sys_rsx_context_attribute, LV2_NONE);
syscalls[0x2A3] = SYSCALL_WRAP(sys_rsx_device_map, LV2_NONE);
syscalls[0x2A5] = SYSCALL_WRAP(sys_rsx_attribute, LV2_NONE);
syscalls[0x321] = SYSCALL_WRAP(sys_fs_open, LV2_NONE);
syscalls[0x322] = SYSCALL_WRAP(sys_fs_read, LV2_NONE);
syscalls[0x323] = SYSCALL_WRAP(sys_fs_write, LV2_NONE);
syscalls[0x324] = SYSCALL_WRAP(sys_fs_close, LV2_NONE);
syscalls[0x328] = SYSCALL_WRAP(sys_fs_stat, LV2_NONE);
syscalls[0x329] = SYSCALL_WRAP(sys_fs_fstat, LV2_NONE);
syscalls[0x331] = SYSCALL_WRAP(sys_fs_fcntl, LV2_NONE);
syscalls[0x332] = SYSCALL_WRAP(sys_fs_lseek, LV2_NONE);
syscalls[0x367] = SYSCALL_WRAP(sys_ss_access_control_engine, LV2_DBG);
syscalls[0x3DC] = SYSCALL_WRAP(sys_dbg_ppu_exception_handler, LV2_NONE);
}
if (fw_type & (LV2_DEX | LV2_DECR)) {
syscalls[0x1CE] = SYSCALL(sys_prx_0x1CE, LV2_NONE);
syscalls[0x1CE] = SYSCALL_WRAP(sys_prx_0x1CE, LV2_NONE);
}
if (fw_type & LV2_DECR) {
// TODO: No syscalls for now

View file

@ -7,14 +7,11 @@
#include "sys_mutex.h"
#include "nucleus/emulator.h"
#include "nucleus/logger/logger.h"
#include "nucleus/system/scei/cellos/lv2.h"
namespace sys {
S32 sys_cond_create(BE<U32>* cond_id, U32 mutex_id, sys_cond_attribute_t* attr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* mutex = lv2.objects.get<sys_mutex_t>(mutex_id);
LV2_SYSCALL(sys_cond_create, BE<U32>* cond_id, U32 mutex_id, sys_cond_attribute_t* attr) {
auto* mutex = kernel.objects.get<sys_mutex_t>(mutex_id);
// Check requisites
if (!mutex) {
@ -37,23 +34,19 @@ S32 sys_cond_create(BE<U32>* cond_id, U32 mutex_id, sys_cond_attribute_t* attr)
cond->mutex = mutex;
cond->attr = *attr;
*cond_id = lv2.objects.add(cond, SYS_COND_OBJECT);
*cond_id = kernel.objects.add(cond, SYS_COND_OBJECT);
return CELL_OK;
}
S32 sys_cond_destroy(U32 cond_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(cond_id)) {
LV2_SYSCALL(sys_cond_destroy, U32 cond_id) {
if (!kernel.objects.remove(cond_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_cond_signal(U32 cond_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* cond = lv2.objects.get<sys_cond_t>(cond_id);
LV2_SYSCALL(sys_cond_signal, U32 cond_id) {
auto* cond = kernel.objects.get<sys_cond_t>(cond_id);
// Check requisites
if (!cond) {
@ -64,10 +57,8 @@ S32 sys_cond_signal(U32 cond_id) {
return CELL_OK;
}
S32 sys_cond_signal_all(U32 cond_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* cond = lv2.objects.get<sys_cond_t>(cond_id);
LV2_SYSCALL(sys_cond_signal_all, U32 cond_id) {
auto* cond = kernel.objects.get<sys_cond_t>(cond_id);
// Check requisites
if (!cond) {
@ -78,10 +69,8 @@ S32 sys_cond_signal_all(U32 cond_id) {
return CELL_OK;
}
S32 sys_cond_signal_to(U32 cond_id, U32 thread_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* cond = lv2.objects.get<sys_cond_t>(cond_id);
LV2_SYSCALL(sys_cond_signal_to, U32 cond_id, U32 thread_id) {
auto* cond = kernel.objects.get<sys_cond_t>(cond_id);
// Check requisites
if (!cond) {
@ -93,10 +82,8 @@ S32 sys_cond_signal_to(U32 cond_id, U32 thread_id) {
return CELL_OK;
}
S32 sys_cond_wait(U32 cond_id, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* cond = lv2.objects.get<sys_cond_t>(cond_id);
LV2_SYSCALL(sys_cond_wait, U32 cond_id, U64 timeout) {
auto* cond = kernel.objects.get<sys_cond_t>(cond_id);
// Check requisites
if (!cond) {

View file

@ -5,7 +5,6 @@
#pragma once
#include "nucleus/common.h"
#include "sys_mutex.h"
#include <condition_variable>
@ -30,11 +29,11 @@ struct sys_cond_t
};
// SysCalls
S32 sys_cond_create(BE<U32>* cond_id, U32 mutex_id, sys_cond_attribute_t* attr);
S32 sys_cond_destroy(U32 cond_id);
S32 sys_cond_wait(U32 cond_id, U64 timeout);
S32 sys_cond_signal(U32 cond_id);
S32 sys_cond_signal_all(U32 cond_id);
S32 sys_cond_signal_to(U32 cond_id, U32 thread_id);
LV2_SYSCALL(sys_cond_create, BE<U32>* cond_id, U32 mutex_id, sys_cond_attribute_t* attr);
LV2_SYSCALL(sys_cond_destroy, U32 cond_id);
LV2_SYSCALL(sys_cond_wait, U32 cond_id, U64 timeout);
LV2_SYSCALL(sys_cond_signal, U32 cond_id);
LV2_SYSCALL(sys_cond_signal_all, U32 cond_id);
LV2_SYSCALL(sys_cond_signal_to, U32 cond_id, U32 thread_id);
} // namespace sys

View file

@ -4,21 +4,21 @@
*/
#include "sys_config.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
namespace sys {
S32 sys_config_add_service_listener() {
LV2_SYSCALL(sys_config_add_service_listener) {
// TODO: ?
return CELL_OK;
}
S32 sys_config_close() {
LV2_SYSCALL(sys_config_close) {
// TODO: ?
return CELL_OK;
}
S32 sys_config_open() {
LV2_SYSCALL(sys_config_open) {
// TODO: ?
return CELL_OK;
}

View file

@ -6,12 +6,13 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
// SysCalls
S32 sys_config_add_service_listener();
S32 sys_config_close();
S32 sys_config_open();
LV2_SYSCALL(sys_config_add_service_listener);
LV2_SYSCALL(sys_config_close);
LV2_SYSCALL(sys_config_open);
} // namespace sys

View file

@ -4,20 +4,16 @@
*/
#include "sys_dbg.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_dbg_ppu_exception_handler() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_dbg_ppu_exception_handler) {
return CELL_OK;
}
S32 sys_dbg_get_thread_list(U32 pid, U64* ids, U64* ids_num, U64* all_ids_num) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_dbg_get_thread_list, U32 pid, U64* ids, U64* ids_num, U64* all_ids_num) {
if (ids_num == nucleus.memory->ptr(0) || all_ids_num == nucleus.memory->ptr(0)) {
return CELL_LV2DBG_ERROR_DEINVALIDARGUMENTS;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -45,59 +46,59 @@ struct sys_dbg_spu_thread_context2_t {
};
// SysCalls
S32 sys_dbg_continue_processes();
S32 sys_dbg_continue_threads();
S32 sys_dbg_create_kernel_event_queue();
S32 sys_dbg_create_scratch_data_area_ext();
S32 sys_dbg_destroy_kernel_event_queue();
S32 sys_dbg_disable_floating_point_enabled_exception();
S32 sys_dbg_enable_floating_point_enabled_exception();
S32 sys_dbg_finalize_ppu_exception_handler();
S32 sys_dbg_get_address_from_dabr();
S32 sys_dbg_get_cond_list();
S32 sys_dbg_get_cond_information();
S32 sys_dbg_get_event_flag_list();
S32 sys_dbg_get_event_flag_information();
S32 sys_dbg_get_event_queue_list();
S32 sys_dbg_get_event_queue_information();
S32 sys_dbg_get_kernel_thread_list();
S32 sys_dbg_get_kernel_thread_info();
S32 sys_dbg_get_lwmutex_list();
S32 sys_dbg_get_lwmutex_information();
S32 sys_dbg_get_lwcond_list();
S32 sys_dbg_get_lwcond_information();
S32 sys_dbg_get_mutex_list();
S32 sys_dbg_get_mutex_information();
S32 sys_dbg_get_process_event_ctrl_flag();
S32 sys_dbg_get_raw_spu_list();
S32 sys_dbg_get_rwlock_list();
S32 sys_dbg_get_rwlock_information();
S32 sys_dbg_get_semaphore_list();
S32 sys_dbg_get_semaphore_information();
S32 sys_dbg_get_spu_thread_group_event_cntl_flag();
S32 sys_dbg_get_thread_list(U32 pid, U64* ids, U64* ids_num, U64* all_ids_num);
S32 sys_dbg_get_ppu_thread_name();
S32 sys_dbg_get_process_list();
S32 sys_dbg_get_process_info();
S32 sys_dbg_initialize_ppu_exception_handler();
S32 sys_dbg_kill_process();
S32 sys_dbg_ppu_exception_handler();
S32 sys_dbg_read_kernel_event_queue();
S32 sys_dbg_read_process_memory();
S32 sys_dbg_read_thread_register();
S32 sys_dbg_read_spu_thread_context2();
S32 sys_dbg_set_address_to_dabr();
S32 sys_dbg_set_process_event_cntl_flag();
S32 sys_dbg_set_run_control_bit_to_spu();
S32 sys_dbg_set_spu_thread_group_event_cntl_flag();
S32 sys_dbg_spu_thread_get_exception_cause();
S32 sys_dbg_spu_thread_read_from_ls();
S32 sys_dbg_spu_thread_write_to_ls();
S32 sys_dbg_stop_processes();
S32 sys_dbg_stop_threads();
S32 sys_dbg_vm_get_page_information();
S32 sys_dbg_vm_get_info();
S32 sys_dbg_write_process_memory();
S32 sys_dbg_write_thread_register();
LV2_SYSCALL(sys_dbg_continue_processes);
LV2_SYSCALL(sys_dbg_continue_threads);
LV2_SYSCALL(sys_dbg_create_kernel_event_queue);
LV2_SYSCALL(sys_dbg_create_scratch_data_area_ext);
LV2_SYSCALL(sys_dbg_destroy_kernel_event_queue);
LV2_SYSCALL(sys_dbg_disable_floating_point_enabled_exception);
LV2_SYSCALL(sys_dbg_enable_floating_point_enabled_exception);
LV2_SYSCALL(sys_dbg_finalize_ppu_exception_handler);
LV2_SYSCALL(sys_dbg_get_address_from_dabr);
LV2_SYSCALL(sys_dbg_get_cond_list);
LV2_SYSCALL(sys_dbg_get_cond_information);
LV2_SYSCALL(sys_dbg_get_event_flag_list);
LV2_SYSCALL(sys_dbg_get_event_flag_information);
LV2_SYSCALL(sys_dbg_get_event_queue_list);
LV2_SYSCALL(sys_dbg_get_event_queue_information);
LV2_SYSCALL(sys_dbg_get_kernel_thread_list);
LV2_SYSCALL(sys_dbg_get_kernel_thread_info);
LV2_SYSCALL(sys_dbg_get_lwmutex_list);
LV2_SYSCALL(sys_dbg_get_lwmutex_information);
LV2_SYSCALL(sys_dbg_get_lwcond_list);
LV2_SYSCALL(sys_dbg_get_lwcond_information);
LV2_SYSCALL(sys_dbg_get_mutex_list);
LV2_SYSCALL(sys_dbg_get_mutex_information);
LV2_SYSCALL(sys_dbg_get_process_event_ctrl_flag);
LV2_SYSCALL(sys_dbg_get_raw_spu_list);
LV2_SYSCALL(sys_dbg_get_rwlock_list);
LV2_SYSCALL(sys_dbg_get_rwlock_information);
LV2_SYSCALL(sys_dbg_get_semaphore_list);
LV2_SYSCALL(sys_dbg_get_semaphore_information);
LV2_SYSCALL(sys_dbg_get_spu_thread_group_event_cntl_flag);
LV2_SYSCALL(sys_dbg_get_thread_list, U32 pid, U64* ids, U64* ids_num, U64* all_ids_num);
LV2_SYSCALL(sys_dbg_get_ppu_thread_name);
LV2_SYSCALL(sys_dbg_get_process_list);
LV2_SYSCALL(sys_dbg_get_process_info);
LV2_SYSCALL(sys_dbg_initialize_ppu_exception_handler);
LV2_SYSCALL(sys_dbg_kill_process);
LV2_SYSCALL(sys_dbg_ppu_exception_handler);
LV2_SYSCALL(sys_dbg_read_kernel_event_queue);
LV2_SYSCALL(sys_dbg_read_process_memory);
LV2_SYSCALL(sys_dbg_read_thread_register);
LV2_SYSCALL(sys_dbg_read_spu_thread_context2);
LV2_SYSCALL(sys_dbg_set_address_to_dabr);
LV2_SYSCALL(sys_dbg_set_process_event_cntl_flag);
LV2_SYSCALL(sys_dbg_set_run_control_bit_to_spu);
LV2_SYSCALL(sys_dbg_set_spu_thread_group_event_cntl_flag);
LV2_SYSCALL(sys_dbg_spu_thread_get_exception_cause);
LV2_SYSCALL(sys_dbg_spu_thread_read_from_ls);
LV2_SYSCALL(sys_dbg_spu_thread_write_to_ls);
LV2_SYSCALL(sys_dbg_stop_processes);
LV2_SYSCALL(sys_dbg_stop_threads);
LV2_SYSCALL(sys_dbg_vm_get_page_information);
LV2_SYSCALL(sys_dbg_vm_get_info);
LV2_SYSCALL(sys_dbg_write_process_memory);
LV2_SYSCALL(sys_dbg_write_thread_register);
} // namespace sys

View file

@ -5,7 +5,6 @@
#include "sys_event.h"
#include "sys_mutex.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/cpu/cpu.h"
#include "nucleus/emulator.h"
@ -22,9 +21,7 @@ namespace sys {
/**
* LV2: Event flags
*/
S32 sys_event_flag_create(BE<U32>* eflag_id, sys_event_flag_attr_t* attr, U64 init) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_event_flag_create, BE<U32>* eflag_id, sys_event_flag_attr_t* attr, U64 init) {
// Check requisites
if (eflag_id == nucleus.memory->ptr(0) || attr == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -38,23 +35,19 @@ S32 sys_event_flag_create(BE<U32>* eflag_id, sys_event_flag_attr_t* attr, U64 in
eflag->attr = *attr;
eflag->value = init;
*eflag_id = lv2.objects.add(eflag, SYS_EVENT_FLAG_OBJECT);
*eflag_id = kernel.objects.add(eflag, SYS_EVENT_FLAG_OBJECT);
return CELL_OK;
}
S32 sys_event_flag_destroy(U32 eflag_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(eflag_id)) {
LV2_SYSCALL(sys_event_flag_destroy, U32 eflag_id) {
if (!kernel.objects.remove(eflag_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_event_flag_wait(U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eflag = lv2.objects.get<sys_event_flag_t>(eflag_id);
LV2_SYSCALL(sys_event_flag_wait, U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result, U64 timeout) {
auto* eflag = kernel.objects.get<sys_event_flag_t>(eflag_id);
// Check requisites
if (!eflag) {
@ -107,10 +100,8 @@ S32 sys_event_flag_wait(U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result, U64
return CELL_OK;
}
S32 sys_event_flag_trywait(U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eflag = lv2.objects.get<sys_event_flag_t>(eflag_id);
LV2_SYSCALL(sys_event_flag_trywait, U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result) {
auto* eflag = kernel.objects.get<sys_event_flag_t>(eflag_id);
// Check requisites
if (!eflag) {
@ -143,10 +134,8 @@ S32 sys_event_flag_trywait(U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result)
return CELL_EBUSY;
}
S32 sys_event_flag_set(U32 eflag_id, U64 bitptn) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eflag = lv2.objects.get<sys_event_flag_t>(eflag_id);
LV2_SYSCALL(sys_event_flag_set, U32 eflag_id, U64 bitptn) {
auto* eflag = kernel.objects.get<sys_event_flag_t>(eflag_id);
// Check requisites
if (!eflag) {
@ -158,10 +147,8 @@ S32 sys_event_flag_set(U32 eflag_id, U64 bitptn) {
return CELL_OK;
}
S32 sys_event_flag_clear(U32 eflag_id, U64 bitptn) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eflag = lv2.objects.get<sys_event_flag_t>(eflag_id);
LV2_SYSCALL(sys_event_flag_clear, U32 eflag_id, U64 bitptn) {
auto* eflag = kernel.objects.get<sys_event_flag_t>(eflag_id);
// Check requisites
if (!eflag) {
@ -173,10 +160,8 @@ S32 sys_event_flag_clear(U32 eflag_id, U64 bitptn) {
return CELL_OK;
}
S32 sys_event_flag_cancel(U32 eflag_id, BE<U32>* num) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eflag = lv2.objects.get<sys_event_flag_t>(eflag_id);
LV2_SYSCALL(sys_event_flag_cancel, U32 eflag_id, BE<U32>* num) {
auto* eflag = kernel.objects.get<sys_event_flag_t>(eflag_id);
// Check requisites
if (!eflag) {
@ -189,10 +174,8 @@ S32 sys_event_flag_cancel(U32 eflag_id, BE<U32>* num) {
return CELL_OK;
}
S32 sys_event_flag_get(U32 eflag_id, BE<U64>* flags) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eflag = lv2.objects.get<sys_event_flag_t>(eflag_id);
LV2_SYSCALL(sys_event_flag_get, U32 eflag_id, BE<U64>* flags) {
auto* eflag = kernel.objects.get<sys_event_flag_t>(eflag_id);
// Check requisites
if (flags == nucleus.memory->ptr(0)) {
@ -209,9 +192,7 @@ S32 sys_event_flag_get(U32 eflag_id, BE<U64>* flags) {
/**
* LV2: Event ports
*/
S32 sys_event_port_create(BE<U32>* eport_id, S32 port_type, U64 name) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_event_port_create, BE<U32>* eport_id, S32 port_type, U64 name) {
// Check requisites
if (eport_id == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -222,24 +203,20 @@ S32 sys_event_port_create(BE<U32>* eport_id, S32 port_type, U64 name) {
eport-> type = port_type;
eport->name_value = name;
*eport_id = lv2.objects.add(eport, SYS_EVENT_PORT_OBJECT);
*eport_id = kernel.objects.add(eport, SYS_EVENT_PORT_OBJECT);
return CELL_OK;
}
S32 sys_event_port_destroy(U32 eport_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(eport_id)) {
LV2_SYSCALL(sys_event_port_destroy, U32 eport_id) {
if (!kernel.objects.remove(eport_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_event_port_connect_local(U32 eport_id, U32 equeue_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eport = lv2.objects.get<sys_event_port_t>(eport_id);
auto* equeue = lv2.objects.get<sys_event_queue_t>(equeue_id);
LV2_SYSCALL(sys_event_port_connect_local, U32 eport_id, U32 equeue_id) {
auto* eport = kernel.objects.get<sys_event_port_t>(eport_id);
auto* equeue = kernel.objects.get<sys_event_queue_t>(equeue_id);
// Check requisites
if (!eport || !equeue) {
@ -256,10 +233,8 @@ S32 sys_event_port_connect_local(U32 eport_id, U32 equeue_id) {
return CELL_OK;
}
S32 sys_event_port_disconnect(U32 eport_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eport = lv2.objects.get<sys_event_port_t>(eport_id);
LV2_SYSCALL(sys_event_port_disconnect, U32 eport_id) {
auto* eport = kernel.objects.get<sys_event_port_t>(eport_id);
// Check requisites
if (!eport) {
@ -270,10 +245,8 @@ S32 sys_event_port_disconnect(U32 eport_id) {
return CELL_OK;
}
S32 sys_event_port_send(U32 eport_id, U64 data1, U64 data2, U64 data3) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* eport = lv2.objects.get<sys_event_port_t>(eport_id);
LV2_SYSCALL(sys_event_port_send, U32 eport_id, U64 data1, U64 data2, U64 data3) {
auto* eport = kernel.objects.get<sys_event_port_t>(eport_id);
// Check requisites
if (!eport) {
@ -294,9 +267,7 @@ S32 sys_event_port_send(U32 eport_id, U64 data1, U64 data2, U64 data3) {
/**
* LV2: Event queues
*/
S32 sys_event_queue_create(BE<U32>* equeue_id, sys_event_queue_attr_t* attr, U64 event_queue_key, S32 size) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_event_queue_create, BE<U32>* equeue_id, sys_event_queue_attr_t* attr, U64 event_queue_key, S32 size) {
// Check requisites
if (equeue_id == nucleus.memory->ptr(0) || attr == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -309,24 +280,20 @@ S32 sys_event_queue_create(BE<U32>* equeue_id, sys_event_queue_attr_t* attr, U64
auto* equeue = new sys_event_queue_t();
equeue->attr = *attr;
*equeue_id = lv2.objects.add(equeue, SYS_EVENT_QUEUE_OBJECT);
*equeue_id = kernel.objects.add(equeue, SYS_EVENT_QUEUE_OBJECT);
return CELL_OK;
}
S32 sys_event_queue_destroy(U32 equeue_id, S32 mode) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_event_queue_destroy, U32 equeue_id, S32 mode) {
// TODO: What's up with mode?
if (!lv2.objects.remove(equeue_id)) {
if (!kernel.objects.remove(equeue_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_event_queue_receive(U32 equeue_id, sys_event_t* evt, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* equeue = lv2.objects.get<sys_event_queue_t>(equeue_id);
LV2_SYSCALL(sys_event_queue_receive, U32 equeue_id, sys_event_t* evt, U64 timeout) {
auto* equeue = kernel.objects.get<sys_event_queue_t>(equeue_id);
// Check requisites
if (!equeue) {
@ -360,10 +327,8 @@ S32 sys_event_queue_receive(U32 equeue_id, sys_event_t* evt, U64 timeout) {
return CELL_OK;
}
S32 sys_event_queue_tryreceive(U32 equeue_id, sys_event_t* event_array, S32 size, BE<S32>* number) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* equeue = lv2.objects.get<sys_event_queue_t>(equeue_id);
LV2_SYSCALL(sys_event_queue_tryreceive, U32 equeue_id, sys_event_t* event_array, S32 size, BE<S32>* number) {
auto* equeue = kernel.objects.get<sys_event_queue_t>(equeue_id);
// Check requisites
if (!equeue) {
@ -382,10 +347,8 @@ S32 sys_event_queue_tryreceive(U32 equeue_id, sys_event_t* event_array, S32 size
return CELL_OK;
}
S32 sys_event_queue_drain(U32 equeue_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* equeue = lv2.objects.get<sys_event_queue_t>(equeue_id);
LV2_SYSCALL(sys_event_queue_drain, U32 equeue_id) {
auto* equeue = kernel.objects.get<sys_event_queue_t>(equeue_id);
// Check requisites
if (!equeue) {

View file

@ -6,7 +6,8 @@
#pragma once
#include "nucleus/common.h"
#include "nucleus/system/scei/cellos/lv2/sys_synchronization.h"
#include "../lv2_macro.h"
#include "sys_synchronization.h"
#include <condition_variable>
#include <mutex>
@ -81,25 +82,25 @@ struct sys_event_port_t
};
// SysCalls
S32 sys_event_flag_create(BE<U32>* eflag_id, sys_event_flag_attr_t* attr, U64 init);
S32 sys_event_flag_destroy(U32 eflag_id);
S32 sys_event_flag_wait(U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result, U64 timeout);
S32 sys_event_flag_trywait(U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result);
S32 sys_event_flag_set(U32 eflag_id, U64 bitptn);
S32 sys_event_flag_clear(U32 eflag_id, U64 bitptn);
S32 sys_event_flag_cancel(U32 eflag_id, BE<U32>* num);
S32 sys_event_flag_get(U32 eflag_id, BE<U64>* flags);
LV2_SYSCALL(sys_event_flag_create, BE<U32>* eflag_id, sys_event_flag_attr_t* attr, U64 init);
LV2_SYSCALL(sys_event_flag_destroy, U32 eflag_id);
LV2_SYSCALL(sys_event_flag_wait, U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result, U64 timeout);
LV2_SYSCALL(sys_event_flag_trywait, U32 eflag_id, U64 bitptn, U32 mode, BE<U64>* result);
LV2_SYSCALL(sys_event_flag_set, U32 eflag_id, U64 bitptn);
LV2_SYSCALL(sys_event_flag_clear, U32 eflag_id, U64 bitptn);
LV2_SYSCALL(sys_event_flag_cancel, U32 eflag_id, BE<U32>* num);
LV2_SYSCALL(sys_event_flag_get, U32 eflag_id, BE<U64>* flags);
S32 sys_event_port_create(BE<U32>* eport_id, S32 port_type, U64 name);
S32 sys_event_port_destroy(U32 eport_id);
S32 sys_event_port_connect_local(U32 eport_id, U32 equeue_id);
S32 sys_event_port_disconnect(U32 eport_id);
S32 sys_event_port_send(U32 eport_id, U64 data1, U64 data2, U64 data3);
LV2_SYSCALL(sys_event_port_create, BE<U32>* eport_id, S32 port_type, U64 name);
LV2_SYSCALL(sys_event_port_destroy, U32 eport_id);
LV2_SYSCALL(sys_event_port_connect_local, U32 eport_id, U32 equeue_id);
LV2_SYSCALL(sys_event_port_disconnect, U32 eport_id);
LV2_SYSCALL(sys_event_port_send, U32 eport_id, U64 data1, U64 data2, U64 data3);
S32 sys_event_queue_create(BE<U32>* equeue_id, sys_event_queue_attr_t* attr, U64 event_queue_key, S32 size);
S32 sys_event_queue_destroy(U32 equeue_id, S32 mode);
S32 sys_event_queue_receive(U32 equeue_id, sys_event_t* dummy_event, U64 timeout);
S32 sys_event_queue_tryreceive(U32 equeue_id, sys_event_t* event_array, S32 size, BE<S32>* number);
S32 sys_event_queue_drain(U32 equeue_id);
LV2_SYSCALL(sys_event_queue_create, BE<U32>* equeue_id, sys_event_queue_attr_t* attr, U64 event_queue_key, S32 size);
LV2_SYSCALL(sys_event_queue_destroy, U32 equeue_id, S32 mode);
LV2_SYSCALL(sys_event_queue_receive, U32 equeue_id, sys_event_t* dummy_event, U64 timeout);
LV2_SYSCALL(sys_event_queue_tryreceive, U32 equeue_id, sys_event_t* event_array, S32 size, BE<S32>* number);
LV2_SYSCALL(sys_event_queue_drain, U32 equeue_id);
} // namespace sys

View file

@ -7,19 +7,16 @@
#include "nucleus/emulator.h"
#include "nucleus/filesystem/filesystem_virtual.h"
#include "nucleus/logger/logger.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include <cstring>
namespace sys {
// SysCalls
S32 sys_fs_open(const S08* path, S32 flags, BE<S32>* fd, U64 mode, const void* arg, U64 size) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_fs_open, const S08* path, S32 flags, BE<S32>* fd, U64 mode, const void* arg, U64 size) {
// Create file
if (flags & CELL_FS_O_CREAT) {
lv2.vfs.createFile(path);
kernel.vfs.createFile(path);
}
// Access mode
@ -46,62 +43,54 @@ S32 sys_fs_open(const S08* path, S32 flags, BE<S32>* fd, U64 mode, const void* a
case CELL_FS_O_RDWR:
if (flags & CELL_FS_O_TRUNC) {
lv2.vfs.createFile(path);
kernel.vfs.createFile(path);
}
openMode = fs::ReadWrite;
}
if (!lv2.vfs.existsFile(path)) {
if (!kernel.vfs.existsFile(path)) {
return CELL_ENOENT;
}
auto* file = new sys_fs_t();
file->type = CELL_FS_S_IFREG;
file->path = path;
file->file = lv2.vfs.openFile(path, openMode);
file->file = kernel.vfs.openFile(path, openMode);
*fd = lv2.objects.add(file, SYS_FS_FD_OBJECT);
*fd = kernel.objects.add(file, SYS_FS_FD_OBJECT);
return CELL_OK;
}
S32 sys_fs_read(S32 fd, void* buf, U64 nbytes, BE<U64>* nread) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* descriptor = lv2.objects.get<sys_fs_t>(fd);
LV2_SYSCALL(sys_fs_read, S32 fd, void* buf, U64 nbytes, BE<U64>* nread) {
auto* descriptor = kernel.objects.get<sys_fs_t>(fd);
auto* file = descriptor->file;
*nread = file->read(buf, nbytes);
return CELL_OK;
}
S32 sys_fs_write(S32 fd, const void* buf, U64 nbytes, BE<U64>* nwrite) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* descriptor = lv2.objects.get<sys_fs_t>(fd);
LV2_SYSCALL(sys_fs_write, S32 fd, const void* buf, U64 nbytes, BE<U64>* nwrite) {
auto* descriptor = kernel.objects.get<sys_fs_t>(fd);
auto* file = descriptor->file;
*nwrite = file->write(buf, nbytes);
return CELL_OK;
}
S32 sys_fs_close(S32 fd) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* descriptor = lv2.objects.get<sys_fs_t>(fd);
LV2_SYSCALL(sys_fs_close, S32 fd) {
auto* descriptor = kernel.objects.get<sys_fs_t>(fd);
delete descriptor->file;
return CELL_OK;
}
S32 sys_fs_fstat(S32 fd, sys_fs_stat_t* sb) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_fs_fstat, S32 fd, sys_fs_stat_t* sb) {
// Check requisites
if (sb == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
}
auto* descriptor = lv2.objects.get<sys_fs_t>(fd);
auto* descriptor = kernel.objects.get<sys_fs_t>(fd);
auto* file = descriptor->file;
auto attributes = file->attributes();
@ -117,7 +106,7 @@ S32 sys_fs_fstat(S32 fd, sys_fs_stat_t* sb) {
return CELL_OK;
}
S32 sys_fs_stat(const S08* path, sys_fs_stat_t* sb) {
LV2_SYSCALL(sys_fs_stat, const S08* path, sys_fs_stat_t* sb) {
// Check requisites
if (path == nucleus.memory->ptr(0) || sb == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -136,17 +125,13 @@ S32 sys_fs_stat(const S08* path, sys_fs_stat_t* sb) {
return CELL_OK;
}
S32 sys_fs_fcntl(S32 fd, S32 cmd, void* argv, U32 argc) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_fs_fcntl, S32 fd, S32 cmd, void* argv, U32 argc) {
logger.warning(LOG_HLE, "LV2 Syscall (0x331) called: sys_fs_fcntl");
return CELL_OK;
}
S32 sys_fs_lseek(S32 fd, S64 offset, S32 whence, BE<U64>* pos) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* descriptor = lv2.objects.get<sys_fs_t>(fd);
LV2_SYSCALL(sys_fs_lseek, S32 fd, S64 offset, S32 whence, BE<U64>* pos) {
auto* descriptor = kernel.objects.get<sys_fs_t>(fd);
auto* file = descriptor->file;
switch (whence) {

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include "nucleus/filesystem/file.h"
#include <string>
@ -85,21 +86,21 @@ struct sys_fs_t
};
// SysCalls
S32 sys_fs_open(const S08* path, S32 flags, BE<S32>* fd, U64 mode, const void* arg, U64 size);
S32 sys_fs_read(S32 fd, void* buf, U64 nbytes, BE<U64>* nread);
S32 sys_fs_write(S32 fd, const void* buf, U64 nbytes, BE<U64>* nwrite);
S32 sys_fs_close(S32 fd);
S32 sys_fs_opendir(const S08* path, BE<S32>* fd);
S32 sys_fs_readdir(S32 fd, sys_fs_dirent_t* dir, BE<U64>* nread);
S32 sys_fs_closedir(S32 fd);
S32 sys_fs_stat(const S08* path, sys_fs_stat_t* sb);
S32 sys_fs_fstat(S32 fd, sys_fs_stat_t* sb);
S32 sys_fs_link(const S08* path, const S08* arg0);
S32 sys_fs_mkdir(const S08* path, U32 mode);
S32 sys_fs_rename(const S08* from, const S08* to);
S32 sys_fs_rmdir(const S08* path);
S32 sys_fs_unlink(const S08* path);
S32 sys_fs_fcntl(S32 fd, S32 cmd, void* argv, U32 argc);
S32 sys_fs_lseek(S32 fd, S64 offset, S32 whence, BE<U64>* pos);
LV2_SYSCALL(sys_fs_open, const S08* path, S32 flags, BE<S32>* fd, U64 mode, const void* arg, U64 size);
LV2_SYSCALL(sys_fs_read, S32 fd, void* buf, U64 nbytes, BE<U64>* nread);
LV2_SYSCALL(sys_fs_write, S32 fd, const void* buf, U64 nbytes, BE<U64>* nwrite);
LV2_SYSCALL(sys_fs_close, S32 fd);
LV2_SYSCALL(sys_fs_opendir, const S08* path, BE<S32>* fd);
LV2_SYSCALL(sys_fs_readdir, S32 fd, sys_fs_dirent_t* dir, BE<U64>* nread);
LV2_SYSCALL(sys_fs_closedir, S32 fd);
LV2_SYSCALL(sys_fs_stat, const S08* path, sys_fs_stat_t* sb);
LV2_SYSCALL(sys_fs_fstat, S32 fd, sys_fs_stat_t* sb);
LV2_SYSCALL(sys_fs_link, const S08* path, const S08* arg0);
LV2_SYSCALL(sys_fs_mkdir, const S08* path, U32 mode);
LV2_SYSCALL(sys_fs_rename, const S08* from, const S08* to);
LV2_SYSCALL(sys_fs_rmdir, const S08* path);
LV2_SYSCALL(sys_fs_unlink, const S08* path);
LV2_SYSCALL(sys_fs_fcntl, S32 fd, S32 cmd, void* argv, U32 argc);
LV2_SYSCALL(sys_fs_lseek, S32 fd, S64 offset, S32 whence, BE<U64>* pos);
} // namespace sys

View file

@ -4,11 +4,11 @@
*/
#include "sys_gamepad.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
namespace sys {
S32 sys_gamepad_ycon_if() {
LV2_SYSCALL(sys_gamepad_ycon_if) {
// TODO: ?
return CELL_OK;
}

View file

@ -6,10 +6,11 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
// SysCalls
S32 sys_gamepad_ycon_if();
LV2_SYSCALL(sys_gamepad_ycon_if);
} // namespace sys

View file

@ -4,21 +4,21 @@
*/
#include "sys_hid.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
namespace sys {
S32 sys_hid_0x1FE() {
LV2_SYSCALL(sys_hid_0x1FE) {
// TODO: ?
return CELL_OK;
}
S32 sys_hid_0x200() {
LV2_SYSCALL(sys_hid_0x200) {
// TODO: ?
return CELL_OK;
}
S32 sys_hid_0x202() {
LV2_SYSCALL(sys_hid_0x202) {
// TODO: ?
return CELL_OK;
}

View file

@ -6,12 +6,13 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
// SysCalls
S32 sys_hid_0x1FE();
S32 sys_hid_0x200();
S32 sys_hid_0x202();
LV2_SYSCALL(sys_hid_0x1FE);
LV2_SYSCALL(sys_hid_0x200);
LV2_SYSCALL(sys_hid_0x202);
} // namespace sys

View file

@ -6,15 +6,13 @@
#include "sys_lwcond.h"
#include "nucleus/emulator.h"
#include "nucleus/logger/logger.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/system/scei/cellos/lv2/sys_lwmutex.h"
namespace sys {
S32 sys_lwcond_create(BE<U32>* lwcond_id, U32 lwmutex_id, sys_lwcond_attribute_t* attr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwmutex = lv2.objects.get<sys_lwmutex_t>(lwmutex_id);
LV2_SYSCALL(sys_lwcond_create, BE<U32>* lwcond_id, U32 lwmutex_id, sys_lwcond_attribute_t* attr) {
auto* lwmutex = kernel.objects.get<sys_lwmutex_t>(lwmutex_id);
// Check requisites
if (!lwmutex) {
@ -30,23 +28,19 @@ S32 sys_lwcond_create(BE<U32>* lwcond_id, U32 lwmutex_id, sys_lwcond_attribute_t
lwcond->lwmutex = lwmutex;
lwcond->attr = *attr;
*lwcond_id = lv2.objects.add(lwcond, SYS_LWCOND_OBJECT);
*lwcond_id = kernel.objects.add(lwcond, SYS_LWCOND_OBJECT);
return CELL_OK;
}
S32 sys_lwcond_destroy(U32 lwcond_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(lwcond_id)) {
LV2_SYSCALL(sys_lwcond_destroy, U32 lwcond_id) {
if (!kernel.objects.remove(lwcond_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_lwcond_signal(U32 lwcond_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwcond = lv2.objects.get<sys_lwcond_t>(lwcond_id);
LV2_SYSCALL(sys_lwcond_signal, U32 lwcond_id) {
auto* lwcond = kernel.objects.get<sys_lwcond_t>(lwcond_id);
// Check requisites
if (!lwcond) {
@ -57,10 +51,8 @@ S32 sys_lwcond_signal(U32 lwcond_id) {
return CELL_OK;
}
S32 sys_lwcond_signal_all(U32 lwcond_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwcond = lv2.objects.get<sys_lwcond_t>(lwcond_id);
LV2_SYSCALL(sys_lwcond_signal_all, U32 lwcond_id) {
auto* lwcond = kernel.objects.get<sys_lwcond_t>(lwcond_id);
// Check requisites
if (!lwcond) {
@ -71,10 +63,8 @@ S32 sys_lwcond_signal_all(U32 lwcond_id) {
return CELL_OK;
}
S32 sys_lwcond_queue_wait(U32 lwcond_id, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwcond = lv2.objects.get<sys_lwcond_t>(lwcond_id);
LV2_SYSCALL(sys_lwcond_queue_wait, U32 lwcond_id, U64 timeout) {
auto* lwcond = kernel.objects.get<sys_lwcond_t>(lwcond_id);
// Check requisites
if (!lwcond) {

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include <condition_variable>
@ -27,10 +28,10 @@ struct sys_lwcond_t {
};
// SysCalls
S32 sys_lwcond_create(BE<U32>* lwcond_id, U32 lwmutex_id, sys_lwcond_attribute_t* attr);
S32 sys_lwcond_destroy(U32 lwcond_id);
S32 sys_lwcond_queue_wait(U32 lwcond_id, U64 timeout);
S32 sys_lwcond_signal(U32 lwcond_id);
S32 sys_lwcond_signal_all(U32 lwcond_id);
LV2_SYSCALL(sys_lwcond_create, BE<U32>* lwcond_id, U32 lwmutex_id, sys_lwcond_attribute_t* attr);
LV2_SYSCALL(sys_lwcond_destroy, U32 lwcond_id);
LV2_SYSCALL(sys_lwcond_queue_wait, U32 lwcond_id, U64 timeout);
LV2_SYSCALL(sys_lwcond_signal, U32 lwcond_id);
LV2_SYSCALL(sys_lwcond_signal_all, U32 lwcond_id);
} // namespace sys

View file

@ -4,14 +4,12 @@
*/
#include "sys_lwmutex.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_lwmutex_create(BE<U32>* lwmutex_id, sys_lwmutex_attribute_t* attr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_lwmutex_create, BE<U32>* lwmutex_id, sys_lwmutex_attribute_t* attr) {
// Check requisites
if (lwmutex_id == nucleus.memory->ptr(0) || attr == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -21,23 +19,19 @@ S32 sys_lwmutex_create(BE<U32>* lwmutex_id, sys_lwmutex_attribute_t* attr) {
auto* lwmutex = new sys_lwmutex_t();
//lwmutex->attr = *attr; It causes a segfault upon startup
*lwmutex_id = lv2.objects.add(lwmutex, SYS_LWMUTEX_OBJECT);
*lwmutex_id = kernel.objects.add(lwmutex, SYS_LWMUTEX_OBJECT);
return CELL_OK;
}
S32 sys_lwmutex_destroy(U32 lwmutex_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(lwmutex_id)) {
LV2_SYSCALL(sys_lwmutex_destroy, U32 lwmutex_id) {
if (!kernel.objects.remove(lwmutex_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_lwmutex_lock(U32 lwmutex_id, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwmutex = lv2.objects.get<sys_lwmutex_t>(lwmutex_id);
LV2_SYSCALL(sys_lwmutex_lock, U32 lwmutex_id, U64 timeout) {
auto* lwmutex = kernel.objects.get<sys_lwmutex_t>(lwmutex_id);
// Check requisites
if (!lwmutex) {
@ -64,10 +58,8 @@ S32 sys_lwmutex_lock(U32 lwmutex_id, U64 timeout) {
return CELL_OK;
}
S32 sys_lwmutex_trylock(U32 lwmutex_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwmutex = lv2.objects.get<sys_lwmutex_t>(lwmutex_id);
LV2_SYSCALL(sys_lwmutex_trylock, U32 lwmutex_id) {
auto* lwmutex = kernel.objects.get<sys_lwmutex_t>(lwmutex_id);
// Check requisites
if (!lwmutex) {
@ -78,10 +70,8 @@ S32 sys_lwmutex_trylock(U32 lwmutex_id) {
return CELL_OK;
}
S32 sys_lwmutex_unlock(U32 lwmutex_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* lwmutex = lv2.objects.get<sys_lwmutex_t>(lwmutex_id);
LV2_SYSCALL(sys_lwmutex_unlock, U32 lwmutex_id) {
auto* lwmutex = kernel.objects.get<sys_lwmutex_t>(lwmutex_id);
// Check requisites
if (!lwmutex) {

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include <mutex>
@ -30,10 +31,10 @@ struct sys_lwmutex_t
};
// SysCalls
S32 sys_lwmutex_create(BE<U32>* lwmutex_id, sys_lwmutex_attribute_t* attr);
S32 sys_lwmutex_destroy(U32 lwmutex_id);
S32 sys_lwmutex_lock(U32 lwmutex_id, U64 timeout);
S32 sys_lwmutex_trylock(U32 lwmutex_id);
S32 sys_lwmutex_unlock(U32 lwmutex_id);
LV2_SYSCALL(sys_lwmutex_create, BE<U32>* lwmutex_id, sys_lwmutex_attribute_t* attr);
LV2_SYSCALL(sys_lwmutex_destroy, U32 lwmutex_id);
LV2_SYSCALL(sys_lwmutex_lock, U32 lwmutex_id, U64 timeout);
LV2_SYSCALL(sys_lwmutex_trylock, U32 lwmutex_id);
LV2_SYSCALL(sys_lwmutex_unlock, U32 lwmutex_id);
} // namespace sys

View file

@ -4,14 +4,12 @@
*/
#include "sys_memory.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_memory_allocate(U32 size, U64 flags, BE<U32>* alloc_addr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_allocate, U32 size, U64 flags, BE<U32>* alloc_addr) {
// Check requisites
if (alloc_addr == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -45,60 +43,42 @@ S32 sys_memory_allocate(U32 size, U64 flags, BE<U32>* alloc_addr) {
return CELL_OK;
}
S32 sys_memory_allocate_from_container(U32 size, U32 cid, U64 flags, BE<U32>* alloc_addr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_allocate_from_container, U32 size, U32 cid, U64 flags, BE<U32>* alloc_addr) {
return CELL_OK;
}
S32 sys_memory_container_create2() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_container_create2) {
return CELL_OK;
}
S32 sys_memory_free(U32 start_addr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_free, U32 start_addr) {
return CELL_OK;
}
S32 sys_memory_get_page_attribute(U32 addr, sys_page_attr_t* attr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_get_page_attribute, U32 addr, sys_page_attr_t* attr) {
return CELL_OK;
}
S32 sys_memory_get_user_memory_size(sys_memory_info_t* mem_info) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_get_user_memory_size, sys_memory_info_t* mem_info) {
const auto& userMemory = nucleus.memory->getSegment(mem::SEG_USER_MEMORY);
mem_info->total_user_memory = userMemory.getTotalMemory();
mem_info->available_user_memory = userMemory.getTotalMemory() - userMemory.getUsedMemory();
return CELL_OK;
}
S32 sys_memory_container_create(BE<U32>* cid, U32 yield_size) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_container_create, BE<U32>* cid, U32 yield_size) {
return CELL_OK;
}
S32 sys_memory_container_destroy(U32 cid) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_container_destroy, U32 cid) {
return CELL_OK;
}
S32 sys_memory_container_get_size(sys_memory_info_t* mem_info, U32 cid) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_container_get_size, sys_memory_info_t* mem_info, U32 cid) {
return CELL_OK;
}
S32 sys_memory_get_user_memory_stat() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_memory_get_user_memory_stat) {
return CELL_OK;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -29,15 +30,15 @@ struct sys_page_attr_t
};
// SysCalls
S32 sys_memory_allocate(U32 size, U64 flags, BE<U32>* alloc_addr);
S32 sys_memory_allocate_from_container(U32 size, U32 cid, U64 flags, BE<U32>* alloc_addr);
S32 sys_memory_container_create2();
S32 sys_memory_free(U32 start_addr);
S32 sys_memory_get_page_attribute(U32 addr, sys_page_attr_t* attr);
S32 sys_memory_get_user_memory_size(sys_memory_info_t* mem_info);
S32 sys_memory_container_create(BE<U32>* cid, U32 yield_size);
S32 sys_memory_container_destroy(U32 cid);
S32 sys_memory_container_get_size(sys_memory_info_t* mem_info, U32 cid);
S32 sys_memory_get_user_memory_stat();
LV2_SYSCALL(sys_memory_allocate, U32 size, U64 flags, BE<U32>* alloc_addr);
LV2_SYSCALL(sys_memory_allocate_from_container, U32 size, U32 cid, U64 flags, BE<U32>* alloc_addr);
LV2_SYSCALL(sys_memory_container_create2);
LV2_SYSCALL(sys_memory_free, U32 start_addr);
LV2_SYSCALL(sys_memory_get_page_attribute, U32 addr, sys_page_attr_t* attr);
LV2_SYSCALL(sys_memory_get_user_memory_size, sys_memory_info_t* mem_info);
LV2_SYSCALL(sys_memory_container_create, BE<U32>* cid, U32 yield_size);
LV2_SYSCALL(sys_memory_container_destroy, U32 cid);
LV2_SYSCALL(sys_memory_container_get_size, sys_memory_info_t* mem_info, U32 cid);
LV2_SYSCALL(sys_memory_get_user_memory_stat);
} // namespace sys

View file

@ -5,14 +5,12 @@
#include "sys_mmapper.h"
#include "sys_memory.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_mmapper_allocate_address(U32 size, U64 flags, U32 alignment, U32* alloc_addr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_mmapper_allocate_address, U32 size, U64 flags, U32 alignment, U32* alloc_addr) {
switch (flags & (SYS_MEMORY_PAGE_SIZE_1M | SYS_MEMORY_PAGE_SIZE_64K)) {
/*case SYS_MEMORY_PAGE_SIZE_1M:
*alloc_addr = memory->alloc(size, 0x100000);
@ -30,9 +28,7 @@ S32 sys_mmapper_allocate_address(U32 size, U64 flags, U32 alignment, U32* alloc_
return CELL_OK;
}
S32 sys_mmapper_allocate_shared_memory(U32 size, U64 flags, U32 alignment, U32* alloc_addr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_mmapper_allocate_shared_memory, U32 size, U64 flags, U32 alignment, U32* alloc_addr) {
*alloc_addr = nucleus.memory->alloc(size, alignment);
return CELL_OK;
}

View file

@ -6,11 +6,12 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
// SysCalls
S32 sys_mmapper_allocate_address(U32 size, U64 flags, U32 alignment, U32* alloc_addr);
S32 sys_mmapper_allocate_shared_memory(U32 size, U64 flags, U32 alignment, U32* alloc_addr);
LV2_SYSCALL(sys_mmapper_allocate_address, U32 size, U64 flags, U32 alignment, U32* alloc_addr);
LV2_SYSCALL(sys_mmapper_allocate_shared_memory, U32 size, U64 flags, U32 alignment, U32* alloc_addr);
} // namespace sys

View file

@ -4,14 +4,12 @@
*/
#include "sys_mutex.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_mutex_create(BE<U32>* mutex_id, sys_mutex_attribute_t* attr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_mutex_create, BE<U32>* mutex_id, sys_mutex_attribute_t* attr) {
// Check requisites
if (mutex_id == nucleus.memory->ptr(0) || attr == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -24,23 +22,19 @@ S32 sys_mutex_create(BE<U32>* mutex_id, sys_mutex_attribute_t* attr) {
auto* mutex = new sys_mutex_t();
mutex->attr = *attr;
*mutex_id = lv2.objects.add(mutex, SYS_MUTEX_OBJECT);
*mutex_id = kernel.objects.add(mutex, SYS_MUTEX_OBJECT);
return CELL_OK;
}
S32 sys_mutex_destroy(U32 mutex_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(mutex_id)) {
LV2_SYSCALL(sys_mutex_destroy, U32 mutex_id) {
if (!kernel.objects.remove(mutex_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_mutex_lock(U32 mutex_id, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* mutex = lv2.objects.get<sys_mutex_t>(mutex_id);
LV2_SYSCALL(sys_mutex_lock, U32 mutex_id, U64 timeout) {
auto* mutex = kernel.objects.get<sys_mutex_t>(mutex_id);
// Check requisites
if (!mutex) {
@ -67,10 +61,8 @@ S32 sys_mutex_lock(U32 mutex_id, U64 timeout) {
return CELL_OK;
}
S32 sys_mutex_trylock(U32 mutex_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* mutex = lv2.objects.get<sys_mutex_t>(mutex_id);
LV2_SYSCALL(sys_mutex_trylock, U32 mutex_id) {
auto* mutex = kernel.objects.get<sys_mutex_t>(mutex_id);
// Check requisites
if (!mutex) {
@ -81,10 +73,8 @@ S32 sys_mutex_trylock(U32 mutex_id) {
return CELL_OK;
}
S32 sys_mutex_unlock(U32 mutex_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* mutex = lv2.objects.get<sys_mutex_t>(mutex_id);
LV2_SYSCALL(sys_mutex_unlock, U32 mutex_id) {
auto* mutex = kernel.objects.get<sys_mutex_t>(mutex_id);
// Check requisites
if (!mutex) {

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include <mutex>
@ -40,10 +41,10 @@ struct sys_mutex_t
};
// SysCalls
S32 sys_mutex_create(BE<U32>* mutex_id, sys_mutex_attribute_t* attr);
S32 sys_mutex_destroy(U32 mutex_id);
S32 sys_mutex_lock(U32 mutex_id, U64 timeout);
S32 sys_mutex_trylock(U32 mutex_id);
S32 sys_mutex_unlock(U32 mutex_id);
LV2_SYSCALL(sys_mutex_create, BE<U32>* mutex_id, sys_mutex_attribute_t* attr);
LV2_SYSCALL(sys_mutex_destroy, U32 mutex_id);
LV2_SYSCALL(sys_mutex_lock, U32 mutex_id, U64 timeout);
LV2_SYSCALL(sys_mutex_trylock, U32 mutex_id);
LV2_SYSCALL(sys_mutex_unlock, U32 mutex_id);
} // namespace sys

View file

@ -4,16 +4,14 @@
*/
#include "sys_ppu_thread.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/cpu/cpu.h"
#include "nucleus/cpu/frontend/ppu/ppu_thread.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_ppu_thread_create(BE<U64>* thread_id, sys_ppu_thread_attr_t* attr, U64 arg, U64 unk0, S32 prio, U32 stacksize, U64 flags, S08* threadname) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_ppu_thread_create, BE<U64>* thread_id, sys_ppu_thread_attr_t* attr, U64 arg, U64 unk0, S32 prio, U32 stacksize, U64 flags, S08* threadname) {
const U32 entry_pc = nucleus.memory->read32(attr->entry);
const U32 entry_rtoc = nucleus.memory->read32(attr->entry + 4);
@ -31,7 +29,7 @@ S32 sys_ppu_thread_create(BE<U64>* thread_id, sys_ppu_thread_attr_t* attr, U64 a
state->r[3] = arg;
state->r[4] = state->r[1] - 0x80;
state->r[5] = state->r[4] - 0x70;
state->r[12] = lv2.proc.param.malloc_pagesize;
state->r[12] = kernel.proc.param.malloc_pagesize;
state->r[13] = nucleus.memory->getSegment(mem::SEG_USER_MEMORY).getBaseAddr() + 0x7060; // TLS
// Set other UISA registers
@ -40,13 +38,11 @@ S32 sys_ppu_thread_create(BE<U64>* thread_id, sys_ppu_thread_attr_t* attr, U64 a
state->tb.TBL = 1;
state->tb.TBU = 1;
*thread_id = lv2.objects.add(ppu_thread, SYS_PPU_THREAD_OBJECT);
*thread_id = kernel.objects.add(ppu_thread, SYS_PPU_THREAD_OBJECT);
return CELL_OK;
}
S32 sys_ppu_thread_exit(S32 errorcode) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_ppu_thread_exit, S32 errorcode) {
// TODO: Delete stack
auto* thread = nucleus.cpu->getCurrentThread();
@ -54,10 +50,8 @@ S32 sys_ppu_thread_exit(S32 errorcode) {
return CELL_OK;
}
S32 sys_ppu_thread_get_priority(U64 thread_id, BE<S32>* prio) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* ppu_thread = lv2.objects.get<sys_ppu_thread_t>(thread_id);
LV2_SYSCALL(sys_ppu_thread_get_priority, U64 thread_id, BE<S32>* prio) {
auto* ppu_thread = kernel.objects.get<sys_ppu_thread_t>(thread_id);
// Check requisites
if (prio == nucleus.memory->ptr(0)) {
@ -71,9 +65,7 @@ S32 sys_ppu_thread_get_priority(U64 thread_id, BE<S32>* prio) {
return CELL_OK;
}
S32 sys_ppu_thread_get_stack_information(sys_ppu_thread_stack_t* sp) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_ppu_thread_get_stack_information, sys_ppu_thread_stack_t* sp) {
auto* thread = nucleus.cpu->getCurrentThread();
// TODO: ?
@ -82,10 +74,8 @@ S32 sys_ppu_thread_get_stack_information(sys_ppu_thread_stack_t* sp) {
return CELL_OK;
}
S32 sys_ppu_thread_join(U64 thread_id, BE<U64>* vptr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* ppu_thread = lv2.objects.get<sys_ppu_thread_t>(thread_id);
LV2_SYSCALL(sys_ppu_thread_join, U64 thread_id, BE<U64>* vptr) {
auto* ppu_thread = kernel.objects.get<sys_ppu_thread_t>(thread_id);
// Check requisites
if (!ppu_thread) {
@ -96,10 +86,8 @@ S32 sys_ppu_thread_join(U64 thread_id, BE<U64>* vptr) {
return CELL_OK;
}
S32 sys_ppu_thread_start(U64 thread_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* ppu_thread = lv2.objects.get<sys_ppu_thread_t>(thread_id);
LV2_SYSCALL(sys_ppu_thread_start, U64 thread_id) {
auto* ppu_thread = kernel.objects.get<sys_ppu_thread_t>(thread_id);
// Check requisites
if (!ppu_thread) {

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
// Forward-declarations
namespace cpu { namespace frontend { namespace ppu { class PPUThread; }}}
@ -30,18 +31,18 @@ struct sys_ppu_thread_t {
};
// SysCalls
S32 sys_ppu_thread_create(BE<U64>* thread_id, sys_ppu_thread_attr_t* attr, U64 arg, U64 unk0, S32 prio, U32 stacksize, U64 flags, S08* threadname);
S32 sys_ppu_thread_detach(U64 thread_id);
S32 sys_ppu_thread_exit(S32 errorcode);
void sys_ppu_thread_get_join_state(BE<S32>* isjoinable);
S32 sys_ppu_thread_get_priority(U64 thread_id, BE<S32>* prio);
S32 sys_ppu_thread_get_stack_information(sys_ppu_thread_stack_t* info);
S32 sys_ppu_thread_join(U64 thread_id, BE<U64>* vptr);
S32 sys_ppu_thread_restart();
S32 sys_ppu_thread_rename(U64 thread_id, S08* name);
S32 sys_ppu_thread_set_priority(U64 thread_id, S32 prio);
S32 sys_ppu_thread_start(U64 thread_id);
S32 sys_ppu_thread_stop(U64 thread_id);
void sys_ppu_thread_yield();
LV2_SYSCALL(sys_ppu_thread_create, BE<U64>* thread_id, sys_ppu_thread_attr_t* attr, U64 arg, U64 unk0, S32 prio, U32 stacksize, U64 flags, S08* threadname);
LV2_SYSCALL(sys_ppu_thread_detach, U64 thread_id);
LV2_SYSCALL(sys_ppu_thread_exit, S32 errorcode);
LV2_SYSCALL(sys_ppu_thread_get_join_state(BE<S32>* isjoinable);
LV2_SYSCALL(sys_ppu_thread_get_priority, U64 thread_id, BE<S32>* prio);
LV2_SYSCALL(sys_ppu_thread_get_stack_information, sys_ppu_thread_stack_t* info);
LV2_SYSCALL(sys_ppu_thread_join, U64 thread_id, BE<U64>* vptr);
LV2_SYSCALL(sys_ppu_thread_restart);
LV2_SYSCALL(sys_ppu_thread_rename, U64 thread_id, S08* name);
LV2_SYSCALL(sys_ppu_thread_set_priority, U64 thread_id, S32 prio);
LV2_SYSCALL(sys_ppu_thread_start, U64 thread_id);
LV2_SYSCALL(sys_ppu_thread_stop, U64 thread_id);
LV2_SYSCALL(sys_ppu_thread_yield();
} // namespace sys

View file

@ -4,48 +4,38 @@
*/
#include "sys_process.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/logger/logger.h"
#include "nucleus/emulator.h"
namespace sys {
S32 sys_process_getpid() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_process_getpid) {
return 0x01000500; // TODO
}
S32 sys_process_getppid() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_process_getppid) {
return 0x01000300; // TODO
}
S32 sys_process_exit(S32 errorcode) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_process_exit, S32 errorcode) {
nucleus.task(NUCLEUS_EVENT_STOP);
return CELL_OK;
}
S32 sys_process_get_paramsfo(U08* buffer) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_process_get_paramsfo, U08* buffer) {
return CELL_OK;
}
S32 sys_process_get_sdk_version(U32 pid, BE<U32>* version) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_process_get_sdk_version, U32 pid, BE<U32>* version) {
if (!version) {
return CELL_EFAULT;
}
*version = lv2.proc.param.sdk_version;
*version = kernel.proc.param.sdk_version;
return CELL_OK;
}
S32 sys_process_is_spu_lock_line_reservation_address(U32 addr, U64 flags) {
LV2_SYSCALL(sys_process_is_spu_lock_line_reservation_address, U32 addr, U64 flags) {
logger.warning(LOG_HLE, "LV2 Syscall (0x00E) called: sys_process_is_spu_lock_line_reservation_address");
return CELL_OK;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -126,36 +127,36 @@ struct sys_process_t {
};
// SysCalls
S32 sys_process_getpid();
S32 sys_process_getppid();
S32 sys_process_get_number_of_object(U32 object, BE<U32>* nump);
S32 sys_process_get_id(U32 object, BE<U32>* buffer, U32 size, BE<U32>* set_size);
S32 sys_process_get_paramsfo(U08* buffer);
S32 sys_process_get_sdk_version(U32 pid, BE<U32>* version);
S32 sys_process_get_status(U64 unk);
S32 sys_process_exit(S32 errorcode);
S32 sys_process_kill(U32 pid);
S32 sys_process_wait_for_child(U32 pid, BE<U32>* status, U64 unk);
S32 sys_process_wait_for_child2(U64 unk1, U64 unk2, U64 unk3, U64 unk4, U64 unk5, U64 unk6);
S32 sys_process_detach_child(U64 unk);
S32 sys_process_is_spu_lock_line_reservation_address(U32 addr, U64 flags);
void sys_game_process_exitspawn(U32 path_addr, U32 argv_addr, U32 envp_addr, U32 data_addr, U32 data_size, U32 prio, U64 flags);
void sys_game_process_exitspawn2(U32 path_addr, U32 argv_addr, U32 envp_addr, U32 data_addr, U32 data_size, U32 prio, U64 flags);
S32 sys_process_wait_for_child(BE<U32>* child_proc_id, BE<U32>* status, U32 flag);
S32 sys_process_get_status(U32 proc_id);
S32 sys_process_detach_child(U32 child_proc_id);
S32 sys_process_get_number_of_object(U32 obj_type, BE<U32>* count);
S32 sys_process_get_id(U32 obj_type, BE<U32>* id_list, U32 id_list_size, BE<U32>* count);
S32 sys_process_kill(U32 proc_id);
S32 sys_process_spawn(BE<U32>* proc_id, S32 primary_prio, U32 flags, BE<U32>* stack, U32 stack_size, U64 intr_mask, U32 trace_id);
S32 sys_process_exit2(S32 exit_status, BE<U32>* user_data, U32 user_data_size);
S32 sys_process_wait_for_child2(BE<U32>* child_proc_id, BE<U32>* status, BE<U32>* data_out, U32 data_out_size, U32 arg_5, U32 flags);
S32 sys_process_spawns_a_self(BE<U32>* proc_id, S32 primary_prio, U32 flags, BE<U32>* stack, U32 stack_size, U64 proc_intr_mask, U32 trace_id, U32 mc_id);
S32 sys_process_exit3(S32 exit_status, BE<U32>* user_data, U32 user_data_size, U32 flags);
S32 sys_process_spawns_a_self2(BE<U32>* proc_id, S32 primary_prio, U32 flags, BE<U32>* stack, U32 stack_size, U32 mc_id, sys_param_sfo_t* param_sfo, sys_process_dbg_t* dbg_data);
S32 sys_process_get_number_of_object2(U32 obj_type);
S32 sys_process_get_id2(U32 obj_type, BE<U32>* id_list, U32 id_list_size, BE<U32>* count);
S32 sys_process_get_ppu_guid();
LV2_SYSCALL(sys_process_getpid);
LV2_SYSCALL(sys_process_getppid);
LV2_SYSCALL(sys_process_get_number_of_object, U32 object, BE<U32>* nump);
LV2_SYSCALL(sys_process_get_id, U32 object, BE<U32>* buffer, U32 size, BE<U32>* set_size);
LV2_SYSCALL(sys_process_get_paramsfo, U08* buffer);
LV2_SYSCALL(sys_process_get_sdk_version, U32 pid, BE<U32>* version);
LV2_SYSCALL(sys_process_get_status, U64 unk);
LV2_SYSCALL(sys_process_exit, S32 errorcode);
LV2_SYSCALL(sys_process_kill, U32 pid);
LV2_SYSCALL(sys_process_wait_for_child, U32 pid, BE<U32>* status, U64 unk);
LV2_SYSCALL(sys_process_wait_for_child2, U64 unk1, U64 unk2, U64 unk3, U64 unk4, U64 unk5, U64 unk6);
LV2_SYSCALL(sys_process_detach_child, U64 unk);
LV2_SYSCALL(sys_process_is_spu_lock_line_reservation_address, U32 addr, U64 flags);
LV2_SYSCALL(sys_game_process_exitspawn, U32 path_addr, U32 argv_addr, U32 envp_addr, U32 data_addr, U32 data_size, U32 prio, U64 flags);
LV2_SYSCALL(sys_game_process_exitspawn2, U32 path_addr, U32 argv_addr, U32 envp_addr, U32 data_addr, U32 data_size, U32 prio, U64 flags);
LV2_SYSCALL(sys_process_wait_for_child, BE<U32>* child_proc_id, BE<U32>* status, U32 flag);
LV2_SYSCALL(sys_process_get_status, U32 proc_id);
LV2_SYSCALL(sys_process_detach_child, U32 child_proc_id);
LV2_SYSCALL(sys_process_get_number_of_object, U32 obj_type, BE<U32>* count);
LV2_SYSCALL(sys_process_get_id, U32 obj_type, BE<U32>* id_list, U32 id_list_size, BE<U32>* count);
LV2_SYSCALL(sys_process_kill, U32 proc_id);
LV2_SYSCALL(sys_process_spawn, BE<U32>* proc_id, S32 primary_prio, U32 flags, BE<U32>* stack, U32 stack_size, U64 intr_mask, U32 trace_id);
LV2_SYSCALL(sys_process_exit2, S32 exit_status, BE<U32>* user_data, U32 user_data_size);
LV2_SYSCALL(sys_process_wait_for_child2, BE<U32>* child_proc_id, BE<U32>* status, BE<U32>* data_out, U32 data_out_size, U32 arg_5, U32 flags);
LV2_SYSCALL(sys_process_spawns_a_self, BE<U32>* proc_id, S32 primary_prio, U32 flags, BE<U32>* stack, U32 stack_size, U64 proc_intr_mask, U32 trace_id, U32 mc_id);
LV2_SYSCALL(sys_process_exit3, S32 exit_status, BE<U32>* user_data, U32 user_data_size, U32 flags);
LV2_SYSCALL(sys_process_spawns_a_self2, BE<U32>* proc_id, S32 primary_prio, U32 flags, BE<U32>* stack, U32 stack_size, U32 mc_id, sys_param_sfo_t* param_sfo, sys_process_dbg_t* dbg_data);
LV2_SYSCALL(sys_process_get_number_of_object2, U32 obj_type);
LV2_SYSCALL(sys_process_get_id2, U32 obj_type, BE<U32>* id_list, U32 id_list_size, BE<U32>* count);
LV2_SYSCALL(sys_process_get_ppu_guid);
} // namespace sys

View file

@ -9,17 +9,15 @@
#include "nucleus/cpu/frontend/ppu/ppu_decoder.h"
#include "nucleus/core/config.h"
#include "nucleus/system/scei/cellos/callback.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/system/scei/cellos/lv2/sys_process.h"
#include "nucleus/system/scei/self.h"
namespace sys {
S32 sys_prx_load_module(const S08* path, U64 flags, sys_prx_load_module_option_t* pOpt) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_load_module, const S08* path, U64 flags, sys_prx_load_module_option_t* pOpt) {
SELFLoader self;
auto file = lv2.vfs.openFile(path, fs::Read);
auto file = kernel.vfs.openFile(path, fs::Read);
if (!self.open(file)) {
return CELL_PRX_ERROR_UNKNOWN_MODULE;
}
@ -39,13 +37,11 @@ S32 sys_prx_load_module(const S08* path, U64 flags, sys_prx_load_module_option_t
prx->func_exit = metaLib.exports[0x3AB9A95E];
prx->path = path;
const S32 id = lv2.objects.add(prx, SYS_PRX_OBJECT);
const S32 id = kernel.objects.add(prx, SYS_PRX_OBJECT);
return id;
}
S32 sys_prx_load_module_list(S32 count, BE<U64>* pathList, U64 flags, void* pOpt, BE<U32>* idList) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_load_module_list, S32 count, BE<U64>* pathList, U64 flags, void* pOpt, BE<U32>* idList) {
for (S32 i = 0; i < count; i++) {
auto* path = (S08*)((U64)nucleus.memory->getBaseAddr() + pathList[i]);
auto* pOpt = nucleus.memory->ptr<sys_prx_load_module_option_t>(0);
@ -61,11 +57,9 @@ S32 sys_prx_load_module_list(S32 count, BE<U64>* pathList, U64 flags, void* pOpt
return CELL_OK;
}
S32 sys_prx_start_module(S32 id, U64 flags, sys_prx_start_module_option_t* pOpt) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* prx = lv2.objects.get<sys_prx_t>(id);
const auto& param = lv2.proc.prx_param;
LV2_SYSCALL(sys_prx_start_module, S32 id, U64 flags, sys_prx_start_module_option_t* pOpt) {
auto* prx = kernel.objects.get<sys_prx_t>(id);
const auto& param = kernel.proc.prx_param;
// Update ELF import table
U32 offset = param.libstubstart;
@ -81,7 +75,7 @@ S32 sys_prx_start_module(S32 id, U64 flags, sys_prx_start_module_option_t* pOpt)
const U32 fnid = nucleus.memory->read32(importedLibrary.fnid_addr + 4*i);
// Try to link to a native implementation (HLE)
if (lv2.modules.find(lib.name, fnid)) {
if (kernel.modules.find(lib.name, fnid)) {
if (config.ppuTranslator == CPU_TRANSLATOR_INSTRUCTION) {
U32 hookAddr = nucleus.memory->alloc(20, 8);
nucleus.memory->write32(hookAddr + 0, 0x3D600000 | ((fnid >> 16) & 0xFFFF)); // lis r11, fnid:hi
@ -123,26 +117,20 @@ S32 sys_prx_start_module(S32 id, U64 flags, sys_prx_start_module_option_t* pOpt)
return CELL_OK;
}
S32 sys_prx_0x1CE() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_0x1CE) {
return CELL_OK;
}
S32 sys_prx_get_module_list() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_get_module_list) {
return CELL_OK;
}
S32 sys_prx_get_module_id_by_name(const S08* name, U64 flags, sys_prx_get_module_id_by_name_option_t* pOpt) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_get_module_id_by_name, const S08* name, U64 flags, sys_prx_get_module_id_by_name_option_t* pOpt) {
if (name == nucleus.memory->ptr(0)) {
return 0;
}
// Find library (TODO: This is very inefficient)
for (const auto& object : lv2.objects) {
for (const auto& object : kernel.objects) {
if (object.second->getType() == sys::SYS_PRX_OBJECT) {
const auto& prx = *(sys_prx_t*)object.second->getData();
if (prx.name == name) {
@ -153,15 +141,11 @@ S32 sys_prx_get_module_id_by_name(const S08* name, U64 flags, sys_prx_get_module
return 0;
}
S32 sys_prx_register_library(U32 lib_addr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_register_library, U32 lib_addr) {
return CELL_OK;
}
S32 sys_prx_register_module() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_prx_register_module) {
return CELL_OK;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include <string>
#include <unordered_map>
@ -142,29 +143,29 @@ struct sys_prx_t
};
// SysCalls
S32 sys_prx_0x1CE();
S32 sys_prx_load_module(const S08* path, U64 flags, sys_prx_load_module_option_t* pOpt);
S32 sys_prx_load_module_by_fd();
S32 sys_prx_load_module_list(S32 count, BE<U64>* pathList, U64 flags, void* pOpt, BE<U32>* idList);
S32 sys_prx_load_module_on_memcontainer();
S32 sys_prx_load_module_on_memcontainer_by_fd();
S32 sys_prx_start_module(S32 id, U64 flags, sys_prx_start_module_option_t* pOpt);
S32 sys_prx_stop_module(S32 id, U32 args, U32 argp_addr, BE<U32>* modres, U64 flags, sys_prx_stop_module_option_t* pOpt);
S32 sys_prx_unload_module(S32 id, U64 flags, sys_prx_unload_module_option_t* pOpt);
S32 sys_prx_register_module();
S32 sys_prx_get_module_list();
S32 sys_prx_get_my_module_id();
S32 sys_prx_get_module_id_by_address();
S32 sys_prx_get_module_id_by_name(const S08* name, U64 flags, sys_prx_get_module_id_by_name_option_t* pOpt);
S32 sys_prx_get_module_info();
S32 sys_prx_register_library(U32 lib_addr);
S32 sys_prx_unregister_library();
S32 sys_prx_get_ppu_guid();
S32 sys_prx_query_module();
S32 sys_prx_link_library();
S32 sys_prx_unlink_library();
S32 sys_prx_query_library();
S32 sys_prx_start();
S32 sys_prx_stop();
LV2_SYSCALL(sys_prx_0x1CE);
LV2_SYSCALL(sys_prx_load_module, const S08* path, U64 flags, sys_prx_load_module_option_t* pOpt);
LV2_SYSCALL(sys_prx_load_module_by_fd);
LV2_SYSCALL(sys_prx_load_module_list, S32 count, BE<U64>* pathList, U64 flags, void* pOpt, BE<U32>* idList);
LV2_SYSCALL(sys_prx_load_module_on_memcontainer);
LV2_SYSCALL(sys_prx_load_module_on_memcontainer_by_fd);
LV2_SYSCALL(sys_prx_start_module, S32 id, U64 flags, sys_prx_start_module_option_t* pOpt);
LV2_SYSCALL(sys_prx_stop_module, S32 id, U32 args, U32 argp_addr, BE<U32>* modres, U64 flags, sys_prx_stop_module_option_t* pOpt);
LV2_SYSCALL(sys_prx_unload_module, S32 id, U64 flags, sys_prx_unload_module_option_t* pOpt);
LV2_SYSCALL(sys_prx_register_module);
LV2_SYSCALL(sys_prx_get_module_list);
LV2_SYSCALL(sys_prx_get_my_module_id);
LV2_SYSCALL(sys_prx_get_module_id_by_address);
LV2_SYSCALL(sys_prx_get_module_id_by_name, const S08* name, U64 flags, sys_prx_get_module_id_by_name_option_t* pOpt);
LV2_SYSCALL(sys_prx_get_module_info);
LV2_SYSCALL(sys_prx_register_library, U32 lib_addr);
LV2_SYSCALL(sys_prx_unregister_library);
LV2_SYSCALL(sys_prx_get_ppu_guid);
LV2_SYSCALL(sys_prx_query_module);
LV2_SYSCALL(sys_prx_link_library);
LV2_SYSCALL(sys_prx_unlink_library);
LV2_SYSCALL(sys_prx_query_library);
LV2_SYSCALL(sys_prx_start);
LV2_SYSCALL(sys_prx_stop);
} // namespace sys

View file

@ -4,7 +4,7 @@
*/
#include "sys_rsx.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/system/scei/cellos/lv1/lv1_gpu.h"
#include "nucleus/gpu/rsx/rsx.h"
#include "nucleus/logger/logger.h"
@ -12,15 +12,13 @@
namespace sys {
S32 sys_rsx_device_open() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_device_open)
{
return CELL_OK;
}
S32 sys_rsx_device_close() {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_device_close)
{
return CELL_OK;
}
@ -35,9 +33,8 @@ S32 sys_rsx_device_close() {
* - a6 (IN): E.g. Immediate value passed in cellGcmSys is 16.
* - a7 (IN): E.g. Immediate value passed in cellGcmSys is 8.
*/
S32 sys_rsx_memory_allocate(BE<U32>* mem_handle, BE<U64>* mem_addr, U32 size, U64 flags, U64 a5, U64 a6, U64 a7) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_memory_allocate, BE<U32>* mem_handle, BE<U64>* mem_addr, U32 size, U64 flags, U64 a5, U64 a6, U64 a7)
{
// LV1 Syscall: lv1_gpu_memory_allocate (0xD6)
const U32 addr = nucleus.memory->getSegment(mem::SEG_RSX_LOCAL_MEMORY).alloc(size);
if (!addr) {
@ -53,11 +50,10 @@ S32 sys_rsx_memory_allocate(BE<U32>* mem_handle, BE<U64>* mem_addr, U32 size, U6
* LV2 SysCall 669 (0x29D): sys_rsx_memory_free
* - mem_handle (OUT): Context / ID, for allocated local memory generated by sys_rsx_memory_allocate
*/
S32 sys_rsx_memory_free(U32 mem_handle) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_memory_free, U32 mem_handle)
{
// LV1 Syscall: lv1_gpu_memory_free (0xD8)
nucleus.memory->getSegment(mem::SEG_RSX_LOCAL_MEMORY).free(mem_handle);
kernel.memory->getSegment(mem::SEG_RSX_LOCAL_MEMORY).free(mem_handle);
return CELL_OK;
}
@ -71,9 +67,8 @@ S32 sys_rsx_memory_free(U32 mem_handle) {
* - mem_ctx (IN): mem_ctx given by sys_rsx_memory_allocate
* - system_mode (IN):
*/
S32 sys_rsx_context_allocate(BE<U32>* context_id, BE<U64>* lpar_dma_control, BE<U64>* lpar_driver_info, BE<U64>* lpar_reports, U64 mem_ctx, U64 system_mode) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_context_allocate, BE<U32>* context_id, BE<U64>* lpar_dma_control, BE<U64>* lpar_driver_info, BE<U64>* lpar_reports, U64 mem_ctx, U64 system_mode)
{
U32 ret = lv1_gpu_context_allocate(context_id, lpar_dma_control, lpar_driver_info, lpar_reports, mem_ctx, system_mode);
if (ret != LV1_SUCCESS) {
return CELL_EINVAL;
@ -86,9 +81,8 @@ S32 sys_rsx_context_allocate(BE<U32>* context_id, BE<U64>* lpar_dma_control, BE<
* LV2 SysCall 671 (0x29F): sys_rsx_context_free
* - context_id (IN): RSX context generated by sys_rsx_context_allocate to free the context.
*/
S32 sys_rsx_context_free(U32 context_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_context_free, U32 context_id)
{
return CELL_OK;
}
@ -100,9 +94,8 @@ S32 sys_rsx_context_free(U32 context_id) {
* - size (IN): Size of mapping area in bytes. E.g. 0x00200000
* - flags (IN):
*/
S32 sys_rsx_context_iomap(U32 context_id, U32 io, U32 ea, U32 size, U64 flags) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_context_iomap, U32 context_id, U32 io, U32 ea, U32 size, U64 flags)
{
gpu::rsx::rsx_iomap_t iomap;
iomap.io = io;
iomap.ea = ea;
@ -120,17 +113,15 @@ S32 sys_rsx_context_iomap(U32 context_id, U32 io, U32 ea, U32 size, U64 flags) {
* - io_addr (IN): IO address. E.g. 0x00600000 (Start page 6)
* - size (IN): Size to unmap in byte. E.g. 0x00200000
*/
S32 sys_rsx_context_iounmap(U32 context_id, U32 a2, U32 io_addr, U32 size) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_context_iounmap, U32 context_id, U32 a2, U32 io_addr, U32 size)
{
logger.warning(LOG_HLE, "LV2 Syscall (0x2A1) called: sys_rsx_context_iounmap");
return CELL_OK;
}
// LV2 Syscall 674 (0x2A2): sys_rsx_context_attribute
S32 sys_rsx_context_attribute(S32 context_id, U32 operation_code, U64 p1, U64 p2, U64 p3, U64 p4) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_context_attribute, S32 context_id, U32 operation_code, U64 p1, U64 p2, U64 p3, U64 p4)
{
U32 ret = lv1_gpu_context_attribute(context_id, operation_code, p1, p2, p3, p4);
if (ret != LV1_SUCCESS) {
return CELL_EINVAL;
@ -145,9 +136,8 @@ S32 sys_rsx_context_attribute(S32 context_id, U32 operation_code, U64 p1, U64 p2
* - a2 (OUT): Unused?
* - dev_id (IN): An immediate value and always 8. (cellGcmInitPerfMon uses 11, 10, 9, 7, 12 successively).
*/
S32 sys_rsx_device_map(BE<U32>* mapped_addr, BE<U32>* a2, U32 dev_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_device_map, BE<U32>* mapped_addr, BE<U32>* a2, U32 dev_id)
{
if (dev_id > 15) {
return CELL_EINVAL;
}
@ -171,18 +161,16 @@ S32 sys_rsx_device_map(BE<U32>* mapped_addr, BE<U32>* a2, U32 dev_id) {
* LV2 SysCall 676 (0x2A4): sys_rsx_device_unmap
* - dev_id (IN): An immediate value and always 8.
*/
S32 sys_rsx_device_unmap(U32 dev_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_device_unmap, U32 dev_id)
{
return CELL_OK;
}
/**
* LV2 SysCall 677 (0x2A5): sys_rsx_attribute
*/
S32 sys_rsx_attribute(U32 a1, U32 a2, U32 a3, U32 a4, U32 a5) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_rsx_attribute, U32 a1, U32 a2, U32 a3, U32 a4, U32 a5)
{
// LV1 Syscall: lv1_gpu_attribute (0xE4)
switch (a1) {
case L1GPU_ATTRIBUTE_UNK002:

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -44,17 +45,17 @@ struct sys_rsx_context_t {
};
// SysCalls
S32 sys_rsx_device_open();
S32 sys_rsx_device_close();
S32 sys_rsx_memory_allocate(BE<U32>* mem_handle, BE<U64>* mem_addr, U32 size, U64 flags, U64 a5, U64 a6, U64 a7);
S32 sys_rsx_memory_free(U32 mem_handle);
S32 sys_rsx_context_allocate(BE<U32>* context_id, BE<U64>* lpar_dma_control, BE<U64>* lpar_driver_info, BE<U64>* lpar_reports, U64 mem_ctx, U64 system_mode);
S32 sys_rsx_context_free(U32 context_id);
S32 sys_rsx_context_iomap(U32 context_id, U32 io, U32 ea, U32 size, U64 flags);
S32 sys_rsx_context_iounmap(U32 context_id, U32 a2, U32 io_addr, U32 size);
S32 sys_rsx_context_attribute(S32 context_id, U32 operation_code, U64 p1, U64 p2, U64 p3, U64 p4);
S32 sys_rsx_device_map(BE<U32>* a1, BE<U32>* a2, U32 dev_id);
S32 sys_rsx_device_unmap(U32 dev_id);
S32 sys_rsx_attribute(U32 a1, U32 a2, U32 a3, U32 a4, U32 a5);
LV2_SYSCALL(sys_rsx_device_open);
LV2_SYSCALL(sys_rsx_device_close);
LV2_SYSCALL(sys_rsx_memory_allocate, BE<U32>* mem_handle, BE<U64>* mem_addr, U32 size, U64 flags, U64 a5, U64 a6, U64 a7);
LV2_SYSCALL(sys_rsx_memory_free, U32 mem_handle);
LV2_SYSCALL(sys_rsx_context_allocate, BE<U32>* context_id, BE<U64>* lpar_dma_control, BE<U64>* lpar_driver_info, BE<U64>* lpar_reports, U64 mem_ctx, U64 system_mode);
LV2_SYSCALL(sys_rsx_context_free, U32 context_id);
LV2_SYSCALL(sys_rsx_context_iomap, U32 context_id, U32 io, U32 ea, U32 size, U64 flags);
LV2_SYSCALL(sys_rsx_context_iounmap, U32 context_id, U32 a2, U32 io_addr, U32 size);
LV2_SYSCALL(sys_rsx_context_attribute, S32 context_id, U32 operation_code, U64 p1, U64 p2, U64 p3, U64 p4);
LV2_SYSCALL(sys_rsx_device_map, BE<U32>* a1, BE<U32>* a2, U32 dev_id);
LV2_SYSCALL(sys_rsx_device_unmap, U32 dev_id);
LV2_SYSCALL(sys_rsx_attribute, U32 a1, U32 a2, U32 a3, U32 a4, U32 a5);
} // namespace sys

View file

@ -7,13 +7,11 @@
#include "sys_mutex.h"
#include "nucleus/emulator.h"
#include "nucleus/logger/logger.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
namespace sys {
S32 sys_semaphore_create(BE<U32>* sem_id, sys_semaphore_attribute_t* attr, S32 initial_count, S32 max_count) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_semaphore_create, BE<U32>* sem_id, sys_semaphore_attribute_t* attr, S32 initial_count, S32 max_count) {
// Check requisites
if (sem_id == nucleus.memory->ptr(0) || attr == nucleus.memory->ptr(0)) {
return CELL_EFAULT;
@ -36,23 +34,19 @@ S32 sys_semaphore_create(BE<U32>* sem_id, sys_semaphore_attribute_t* attr, S32 i
semaphore->count = initial_count;
semaphore->attr = *attr;
*sem_id = lv2.objects.add(semaphore, SYS_SEMAPHORE_OBJECT);
*sem_id = kernel.objects.add(semaphore, SYS_SEMAPHORE_OBJECT);
return CELL_OK;
}
S32 sys_semaphore_destroy(U32 sem_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
if (!lv2.objects.remove(sem_id)) {
LV2_SYSCALL(sys_semaphore_destroy, U32 sem_id) {
if (!kernel.objects.remove(sem_id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_semaphore_get_value(U32 sem_id, BE<S32>* val) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* semaphore = lv2.objects.get<sys_semaphore_t>(sem_id);
LV2_SYSCALL(sys_semaphore_get_value, U32 sem_id, BE<S32>* val) {
auto* semaphore = kernel.objects.get<sys_semaphore_t>(sem_id);
// Check requisites
if (!semaphore) {
@ -66,10 +60,8 @@ S32 sys_semaphore_get_value(U32 sem_id, BE<S32>* val) {
return CELL_OK;
}
S32 sys_semaphore_post(U32 sem_id, S32 val) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* semaphore = lv2.objects.get<sys_semaphore_t>(sem_id);
LV2_SYSCALL(sys_semaphore_post, U32 sem_id, S32 val) {
auto* semaphore = kernel.objects.get<sys_semaphore_t>(sem_id);
// Check requisites
if (!semaphore) {
@ -92,10 +84,8 @@ S32 sys_semaphore_post(U32 sem_id, S32 val) {
return CELL_OK;
}
S32 sys_semaphore_trywait(U32 sem_id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* semaphore = lv2.objects.get<sys_semaphore_t>(sem_id);
LV2_SYSCALL(sys_semaphore_trywait, U32 sem_id) {
auto* semaphore = kernel.objects.get<sys_semaphore_t>(sem_id);
// Check requisites
if (!semaphore) {
@ -111,10 +101,8 @@ S32 sys_semaphore_trywait(U32 sem_id) {
return CELL_EBUSY;
}
S32 sys_semaphore_wait(U32 sem_id, U64 timeout) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* semaphore = lv2.objects.get<sys_semaphore_t>(sem_id);
LV2_SYSCALL(sys_semaphore_wait, U32 sem_id, U64 timeout) {
auto* semaphore = kernel.objects.get<sys_semaphore_t>(sem_id);
// Check requisites
if (!semaphore) {

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include <condition_variable>
#include <mutex>
@ -33,11 +34,11 @@ struct sys_semaphore_t
};
// SysCalls
S32 sys_semaphore_create(BE<U32>* sem_id, sys_semaphore_attribute_t* attr, S32 initial_count, S32 max_count);
S32 sys_semaphore_destroy(U32 sem_id);
S32 sys_semaphore_get_value(U32 sem_id, BE<S32>* val);
S32 sys_semaphore_post(U32 sem_id, S32 val);
S32 sys_semaphore_trywait(U32 sem_id);
S32 sys_semaphore_wait(U32 sem_id, U64 timeout);
LV2_SYSCALL(sys_semaphore_create, BE<U32>* sem_id, sys_semaphore_attribute_t* attr, S32 initial_count, S32 max_count);
LV2_SYSCALL(sys_semaphore_destroy, U32 sem_id);
LV2_SYSCALL(sys_semaphore_get_value, U32 sem_id, BE<S32>* val);
LV2_SYSCALL(sys_semaphore_post, U32 sem_id, S32 val);
LV2_SYSCALL(sys_semaphore_trywait, U32 sem_id);
LV2_SYSCALL(sys_semaphore_wait, U32 sem_id, U64 timeout);
} // namespace sys

View file

@ -4,7 +4,7 @@
*/
#include "sys_spu.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
#include "nucleus/system/scei/cellos/lv2/sys_event.h"
#include "nucleus/cpu/cpu.h"
#include "nucleus/cpu/cell.h"
@ -26,9 +26,7 @@ namespace sys {
#define SPU_SNR2_OFFSET(spuNum) \
(SYS_SPU_THREAD_OFFSET * (spuNum) + SYS_SPU_THREAD_BASE_LOW + SYS_SPU_THREAD_SNR2)
S32 sys_spu_initialize(U32 max_usable_spu, U32 max_raw_spu) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_spu_initialize, U32 max_usable_spu, U32 max_raw_spu) {
if (max_usable_spu < max_raw_spu) {
return CELL_EINVAL;
}
@ -36,9 +34,7 @@ S32 sys_spu_initialize(U32 max_usable_spu, U32 max_raw_spu) {
return CELL_OK;
}
S32 sys_spu_thread_group_create(BE<U32>* id, U32 num, S32 prio, sys_spu_thread_group_attribute_t* attr) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_spu_thread_group_create, BE<U32>* id, U32 num, S32 prio, sys_spu_thread_group_attribute_t* attr) {
// TODO: Check if num is in range specified [1, N] with N := value specified on sys_spu_initialize
if (num < 1) {
return CELL_EINVAL;
@ -61,25 +57,21 @@ S32 sys_spu_thread_group_create(BE<U32>* id, U32 num, S32 prio, sys_spu_thread_g
spuThreadGroup->name = attr->name;
}
*id = lv2.objects.add(spuThreadGroup, SYS_SPU_THREAD_GROUP_OBJECT);
*id = kernel.objects.add(spuThreadGroup, SYS_SPU_THREAD_GROUP_OBJECT);
return CELL_OK;
}
S32 sys_spu_thread_group_destroy(U32 id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_spu_thread_group_destroy, U32 id) {
// TODO: Check if SPU thread group is busy, if so return CELL_EBUSY.
if (!lv2.objects.remove(id)) {
if (!kernel.objects.remove(id)) {
return CELL_ESRCH;
}
return CELL_OK;
}
S32 sys_spu_thread_initialize(BE<U32>* thread, U32 group, U32 spu_num, sys_spu_image_t* img, sys_spu_thread_attribute_t* attr, sys_spu_thread_argument_t* arg) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
LV2_SYSCALL(sys_spu_thread_initialize, BE<U32>* thread, U32 group, U32 spu_num, sys_spu_image_t* img, sys_spu_thread_attribute_t* attr, sys_spu_thread_argument_t* arg) {
// Load SPU thread group and perform checks
auto* spuThreadGroup = lv2.objects.get<SPUThreadGroup>(group);
auto* spuThreadGroup = kernel.objects.get<SPUThreadGroup>(group);
if (!spuThreadGroup) {
return CELL_ESRCH;
}
@ -125,15 +117,13 @@ S32 sys_spu_thread_initialize(BE<U32>* thread, U32 group, U32 spu_num, sys_spu_i
}
}
*thread = lv2.objects.add(spuThread, SYS_SPU_THREAD_OBJECT);
*thread = kernel.objects.add(spuThread, SYS_SPU_THREAD_OBJECT);
return CELL_OK;
}
S32 sys_spu_thread_group_connect_event(U32 id, U32 eq, U32 et) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* spuThreadGroup = lv2.objects.get<SPUThreadGroup>(id);
auto* eventQueue = lv2.objects.get<sys_event_queue_t>(eq);
LV2_SYSCALL(sys_spu_thread_group_connect_event, U32 id, U32 eq, U32 et) {
auto* spuThreadGroup = kernel.objects.get<SPUThreadGroup>(id);
auto* eventQueue = kernel.objects.get<sys_event_queue_t>(eq);
if (!spuThreadGroup || !eventQueue) {
return CELL_ESRCH;
}
@ -152,10 +142,8 @@ S32 sys_spu_thread_group_connect_event(U32 id, U32 eq, U32 et) {
return CELL_OK;
}
S32 sys_spu_thread_group_start(U32 id) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* spuThreadGroup = lv2.objects.get<SPUThreadGroup>(id);
LV2_SYSCALL(sys_spu_thread_group_start, U32 id) {
auto* spuThreadGroup = kernel.objects.get<SPUThreadGroup>(id);
if (!spuThreadGroup) {
return CELL_ESRCH;
}
@ -168,10 +156,8 @@ S32 sys_spu_thread_group_start(U32 id) {
return CELL_OK;
}
S32 sys_spu_thread_group_join(U32 gid, BE<S32>* cause, BE<S32>* status) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* spuThreadGroup = lv2.objects.get<SPUThreadGroup>(gid);
LV2_SYSCALL(sys_spu_thread_group_join, U32 gid, BE<S32>* cause, BE<S32>* status) {
auto* spuThreadGroup = kernel.objects.get<SPUThreadGroup>(gid);
if (!spuThreadGroup) {
return CELL_ESRCH;
}
@ -185,10 +171,8 @@ S32 sys_spu_thread_group_join(U32 gid, BE<S32>* cause, BE<S32>* status) {
return CELL_OK;
}
S32 sys_spu_thread_read_ls(U32 id, U32 address, BE<U64>* value, U32 type) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* spuThread = lv2.objects.get<SPUThread>(id);
LV2_SYSCALL(sys_spu_thread_read_ls, U32 id, U32 address, BE<U64>* value, U32 type) {
auto* spuThread = kernel.objects.get<SPUThread>(id);
if (!spuThread) {
return CELL_ESRCH;
}
@ -207,11 +191,9 @@ S32 sys_spu_thread_read_ls(U32 id, U32 address, BE<U64>* value, U32 type) {
return CELL_OK;
}
S32 sys_spu_thread_group_connect_event_all_threads(S32 group_id, U32 equeue_id, U64 req, U08* spup) {
LV2& lv2 = static_cast<LV2&>(*nucleus.sys.get());
auto* spuThreadGroup = lv2.objects.get<SPUThreadGroup>(group_id);
auto* eventQueue = lv2.objects.get<sys_event_queue_t>(equeue_id);
LV2_SYSCALL(sys_spu_thread_group_connect_event_all_threads, S32 group_id, U32 equeue_id, U64 req, U08* spup) {
auto* spuThreadGroup = kernel.objects.get<SPUThreadGroup>(group_id);
auto* eventQueue = kernel.objects.get<sys_event_queue_t>(equeue_id);
if (!spuThreadGroup || !eventQueue) {
return CELL_ESRCH;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
#include <vector>
#include <string>
@ -126,49 +127,49 @@ struct SPUThreadGroup {
};
// SysCalls
S32 sys_raw_spu_create_interrupt_tag(S32 id, U32 class_id, U32 hwthread, BE<U32>* intrtag);
S32 sys_raw_spu_set_int_mask(S32 id, U32 class_id, U64 mask);
S32 sys_raw_spu_get_int_mask(S32 id, U32 class_id, BE<U64>* mask);
S32 sys_raw_spu_set_int_stat(S32 id, U32 class_id, U64 stat);
S32 sys_raw_spu_get_int_stat(S32 id, U32 class_id, BE<U64>* stat);
S32 sys_spu_image_get_information(sys_spu_image_t* img/*, TODO */);
S32 sys_spu_image_open(sys_spu_image_t* img, const S08* path);
S32 sys_spu_image_import(sys_spu_image_t* img, const void* src, U32 type);
S32 sys_spu_image_close(sys_spu_image_t* img);
S32 sys_raw_spu_create(BE<S32>* id, sys_raw_spu_attribute_t* attr);
S32 sys_raw_spu_destroy(S32 id);
S32 sys_raw_spu_read_puint_mb(S32 id, BE<U32>* value);
S32 sys_spu_thread_get_exit_status(U32 id, BE<S32>* status);
S32 sys_spu_thread_set_argument(U32 id, sys_spu_thread_argument_t* arg);
S32 sys_spu_initialize(U32 max_usable_spu, U32 max_raw_spu);
S32 sys_spu_thread_group_create(BE<U32>* id, U32 num, S32 prio, sys_spu_thread_group_attribute_t* attr);
S32 sys_spu_thread_group_destroy(U32 id);
S32 sys_spu_thread_initialize(BE<U32>* thread, U32 group, U32 spu_num, sys_spu_image_t* img, sys_spu_thread_attribute_t* attr, sys_spu_thread_argument_t* arg);
S32 sys_spu_thread_group_start(U32 id);
S32 sys_spu_thread_group_suspend(U32 id);
S32 sys_spu_thread_group_resume(U32 id);
S32 sys_spu_thread_group_yield(U32 id);
S32 sys_spu_thread_group_terminate(U32 id, S32 value);
S32 sys_spu_thread_group_join(U32 gid, BE<S32>* cause, BE<S32>* status);
S32 sys_spu_thread_group_set_priority(U32 id, S32 priority);
S32 sys_spu_thread_group_get_priority(U32 id, BE<S32>* priority);
S32 sys_spu_thread_write_ls(U32 id, U32 address, U64 value, U32 type);
S32 sys_spu_thread_read_ls(U32 id, U32 address, BE<U64>* value, U32 type);
S32 sys_spu_thread_write_snr(U32 id, S32 number, U32 value);
S32 sys_spu_thread_group_connect_event(U32 id, U32 eq, U32 et);
S32 sys_spu_thread_group_disconnect_event(U32 id, U32 et);
S32 sys_spu_thread_set_spu_cfg(U32 id, U64 value);
S32 sys_spu_thread_get_spu_cfg(U32 id, BE<U64>* value);
S32 sys_spu_thread_write_spu_mb(U32 id, U32 value);
S32 sys_spu_thread_connect_event(U32 id, U32 eq, U32 et, U08 spup);
S32 sys_spu_thread_disconnect_event(U32 id, U32 et, U08 spup);
S32 sys_spu_thread_bind_queue(U32 id, U32 spuq, U32 spuq_num);
S32 sys_spu_thread_unbind_queue(U32 id, U32 spuq_num);
S32 sys_raw_spu_set_spu_cfg(S32 id, U32 value);
S32 sys_raw_spu_get_spu_cfg(S32 id, BE<U32>* value);
S32 sys_spu_thread_recover_page_fault(U32 id);
S32 sys_raw_spu_recover_page_fault(S32 id);
S32 sys_spu_thread_group_connect_event_all_threads(S32 group_id, U32 equeue_id, U64 req, U08* spup);
S32 sys_spu_thread_group_disconnect_event_all_threads(S32 group_id, U08 spup);
LV2_SYSCALL(sys_raw_spu_create_interrupt_tag, S32 id, U32 class_id, U32 hwthread, BE<U32>* intrtag);
LV2_SYSCALL(sys_raw_spu_set_int_mask, S32 id, U32 class_id, U64 mask);
LV2_SYSCALL(sys_raw_spu_get_int_mask, S32 id, U32 class_id, BE<U64>* mask);
LV2_SYSCALL(sys_raw_spu_set_int_stat, S32 id, U32 class_id, U64 stat);
LV2_SYSCALL(sys_raw_spu_get_int_stat, S32 id, U32 class_id, BE<U64>* stat);
LV2_SYSCALL(sys_spu_image_get_information, sys_spu_image_t* img/*, TODO */);
LV2_SYSCALL(sys_spu_image_open, sys_spu_image_t* img, const S08* path);
LV2_SYSCALL(sys_spu_image_import, sys_spu_image_t* img, const void* src, U32 type);
LV2_SYSCALL(sys_spu_image_close, sys_spu_image_t* img);
LV2_SYSCALL(sys_raw_spu_create, BE<S32>* id, sys_raw_spu_attribute_t* attr);
LV2_SYSCALL(sys_raw_spu_destroy, S32 id);
LV2_SYSCALL(sys_raw_spu_read_puint_mb, S32 id, BE<U32>* value);
LV2_SYSCALL(sys_spu_thread_get_exit_status, U32 id, BE<S32>* status);
LV2_SYSCALL(sys_spu_thread_set_argument, U32 id, sys_spu_thread_argument_t* arg);
LV2_SYSCALL(sys_spu_initialize, U32 max_usable_spu, U32 max_raw_spu);
LV2_SYSCALL(sys_spu_thread_group_create, BE<U32>* id, U32 num, S32 prio, sys_spu_thread_group_attribute_t* attr);
LV2_SYSCALL(sys_spu_thread_group_destroy, U32 id);
LV2_SYSCALL(sys_spu_thread_initialize, BE<U32>* thread, U32 group, U32 spu_num, sys_spu_image_t* img, sys_spu_thread_attribute_t* attr, sys_spu_thread_argument_t* arg);
LV2_SYSCALL(sys_spu_thread_group_start, U32 id);
LV2_SYSCALL(sys_spu_thread_group_suspend, U32 id);
LV2_SYSCALL(sys_spu_thread_group_resume, U32 id);
LV2_SYSCALL(sys_spu_thread_group_yield, U32 id);
LV2_SYSCALL(sys_spu_thread_group_terminate, U32 id, S32 value);
LV2_SYSCALL(sys_spu_thread_group_join, U32 gid, BE<S32>* cause, BE<S32>* status);
LV2_SYSCALL(sys_spu_thread_group_set_priority, U32 id, S32 priority);
LV2_SYSCALL(sys_spu_thread_group_get_priority, U32 id, BE<S32>* priority);
LV2_SYSCALL(sys_spu_thread_write_ls, U32 id, U32 address, U64 value, U32 type);
LV2_SYSCALL(sys_spu_thread_read_ls, U32 id, U32 address, BE<U64>* value, U32 type);
LV2_SYSCALL(sys_spu_thread_write_snr, U32 id, S32 number, U32 value);
LV2_SYSCALL(sys_spu_thread_group_connect_event, U32 id, U32 eq, U32 et);
LV2_SYSCALL(sys_spu_thread_group_disconnect_event, U32 id, U32 et);
LV2_SYSCALL(sys_spu_thread_set_spu_cfg, U32 id, U64 value);
LV2_SYSCALL(sys_spu_thread_get_spu_cfg, U32 id, BE<U64>* value);
LV2_SYSCALL(sys_spu_thread_write_spu_mb, U32 id, U32 value);
LV2_SYSCALL(sys_spu_thread_connect_event, U32 id, U32 eq, U32 et, U08 spup);
LV2_SYSCALL(sys_spu_thread_disconnect_event, U32 id, U32 et, U08 spup);
LV2_SYSCALL(sys_spu_thread_bind_queue, U32 id, U32 spuq, U32 spuq_num);
LV2_SYSCALL(sys_spu_thread_unbind_queue, U32 id, U32 spuq_num);
LV2_SYSCALL(sys_raw_spu_set_spu_cfg, S32 id, U32 value);
LV2_SYSCALL(sys_raw_spu_get_spu_cfg, S32 id, BE<U32>* value);
LV2_SYSCALL(sys_spu_thread_recover_page_fault, U32 id);
LV2_SYSCALL(sys_raw_spu_recover_page_fault, S32 id);
LV2_SYSCALL(sys_spu_thread_group_connect_event_all_threads, S32 group_id, U32 equeue_id, U64 req, U08* spup);
LV2_SYSCALL(sys_spu_thread_group_disconnect_event_all_threads, S32 group_id, U08 spup);
} // namespace sys

View file

@ -8,7 +8,7 @@
namespace sys {
S32 sys_ss_access_control_engine(U32 pid, U64 arg2, U64 arg3) {
LV2_SYSCALL(sys_ss_access_control_engine, U32 pid, U64 arg2, U64 arg3) {
return CELL_OK;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -13,8 +14,8 @@ struct sys_ss_psid_t {
};
// SysCalls
S32 sys_ss_get_console_id();
S32 sys_ss_access_control_engine(U32 pid, U64 arg2, U64 arg3);
S32 sys_ss_get_open_psid();
LV2_SYSCALL(sys_ss_get_console_id);
LV2_SYSCALL(sys_ss_access_control_engine, U32 pid, U64 arg2, U64 arg3);
LV2_SYSCALL(sys_ss_get_open_psid);
} // namespace sys

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
// Constants
enum {

View file

@ -4,23 +4,23 @@
*/
#include "sys_time.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include "nucleus/system/scei/cellos/kernel.h"
namespace sys {
S32 sys_time_get_timezone(BE<U32>* timezone, BE<U32>* summertime) {
LV2_SYSCALL(sys_time_get_timezone, BE<U32>* timezone, BE<U32>* summertime) {
*timezone = 1;
*summertime = 1;
return CELL_OK;
}
S32 sys_time_get_current_time(BE<U64>* sec, BE<U64>* nsec) {
LV2_SYSCALL(sys_time_get_current_time, BE<U64>* sec, BE<U64>* nsec) {
*sec = 1;
*nsec = 1;
return CELL_OK;
}
U64 sys_time_get_timebase_frequency() {
LV2_SYSCALL(sys_time_get_timebase_frequency) {
return 79800000;
}

View file

@ -6,12 +6,13 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
// SysCalls
S32 sys_time_get_timezone(BE<U32>* timezone, BE<U32>* summertime);
S32 sys_time_get_current_time(BE<U64>* sec, BE<U64>* nsec);
U64 sys_time_get_timebase_frequency();
LV2_SYSCALL(sys_time_get_timezone, BE<U32>* timezone, BE<U32>* summertime);
LV2_SYSCALL(sys_time_get_current_time, BE<U64>* sec, BE<U64>* nsec);
LV2_SYSCALL(sys_time_get_timebase_frequency);
} // namespace sys

View file

@ -4,17 +4,16 @@
*/
#include "sys_timer.h"
#include "nucleus/system/scei/cellos/lv2.h"
namespace sys {
S32 sys_timer_sleep(U32 sleep_time) {
LV2_SYSCALL(sys_timer_sleep, U32 sleep_time) {
// TODO: Use a condition variable to kill the thread while it sleeps
std::this_thread::sleep_for(std::chrono::seconds(sleep_time));
return CELL_OK;
}
S32 sys_timer_usleep(U64 sleep_time) {
LV2_SYSCALL(sys_timer_usleep, U64 sleep_time) {
// Maximum value is: 2^48-1
if (sleep_time > 0xFFFFFFFFFFFFULL) {
sleep_time = 0xFFFFFFFFFFFFULL;

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -18,14 +19,14 @@ struct sys_timer_information_t {
};
// SysCalls
S32 sys_timer_create(BE<U32>* timer_id);
S32 sys_timer_destroy(U32 timer_id);
S32 sys_timer_get_information(U32 timer_id, sys_timer_information_t* info);
S32 sys_timer_start(U32 timer_id, S64 basetime, U64 period);
S32 sys_timer_stop(U32 timer_id);
S32 sys_timer_connect_event_queue(U32 timer_id, U32 queue_id, U64 name, U64 data1, U64 data2);
S32 sys_timer_disconnect_event_queue(U32 timer_id);
S32 sys_timer_usleep(U64 sleep_time);
S32 sys_timer_sleep(U32 sleep_time);
LV2_SYSCALL(sys_timer_create, BE<U32>* timer_id);
LV2_SYSCALL(sys_timer_destroy, U32 timer_id);
LV2_SYSCALL(sys_timer_get_information, U32 timer_id, sys_timer_information_t* info);
LV2_SYSCALL(sys_timer_start, U32 timer_id, S64 basetime, U64 period);
LV2_SYSCALL(sys_timer_stop, U32 timer_id);
LV2_SYSCALL(sys_timer_connect_event_queue, U32 timer_id, U32 queue_id, U64 name, U64 data1, U64 data2);
LV2_SYSCALL(sys_timer_disconnect_event_queue, U32 timer_id);
LV2_SYSCALL(sys_timer_usleep, U64 sleep_time);
LV2_SYSCALL(sys_timer_sleep, U32 sleep_time);
} // namespace sys

View file

@ -4,17 +4,16 @@
*/
#include "sys_tty.h"
#include "nucleus/system/scei/cellos/lv2.h"
#include <iostream>
namespace sys {
S32 sys_tty_read(S32 ch, S08* buf, S32 len, U32* preadlen) {
LV2_SYSCALL(sys_tty_read, S32 ch, S08* buf, S32 len, U32* preadlen) {
return CELL_OK;
}
S32 sys_tty_write(S32 ch, S08* buf, S32 len, U32* pwritelen) {
LV2_SYSCALL(sys_tty_write, S32 ch, S08* buf, S32 len, U32* pwritelen) {
if (ch > 15 || len <= 0) {
return CELL_EINVAL;
}

View file

@ -6,6 +6,7 @@
#pragma once
#include "nucleus/common.h"
#include "../lv2_macro.h"
namespace sys {
@ -31,7 +32,7 @@ enum {
};
// SysCalls
S32 sys_tty_read(S32 ch, S08* buf, S32 len, U32* preadlen);
S32 sys_tty_write(S32 ch, S08* buf, S32 len, U32* pwritelen);
LV2_SYSCALL(sys_tty_read, S32 ch, S08* buf, S32 len, U32* preadlen);
LV2_SYSCALL(sys_tty_write, S32 ch, S08* buf, S32 len, U32* pwritelen);
} // namespace sys

View file

@ -0,0 +1,16 @@
/**
* (c) 2014-2016 Alexandro Sanchez Bach. All rights reserved.
* Released under GPL v2 license. Read LICENSE for more details.
*/
#pragma once
#define LV2_SYSCALL(name, ...) \
U64 name(LV2& kernel, __VA_ARGS__)
namespace sys {
// Forward declarations
class LV2;
} // namespace sys

View file

@ -8,6 +8,9 @@
#include "nucleus/common.h"
#include "nucleus/cpu/frontend/ppu/ppu_state.h"
// Forward declaration
class LV2;
// Syscall arguments
#define ARG_GPR(T,n) (T)(std::is_pointer<T>::value ? (U64)memoryBase + state.r[3+n] : state.r[3+n])
@ -15,7 +18,7 @@
class Syscall
{
public:
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase)=0;
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase)=0;
virtual ~Syscall(){};
};
@ -31,8 +34,8 @@ class SyscallBinder<TR> : public Syscall
public:
SyscallBinder(TR(*func)()) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func();
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel);
}
};
@ -43,8 +46,8 @@ class SyscallBinder<TR, T1> : public Syscall {
public:
SyscallBinder(TR(*func)(T1)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0));
}
};
@ -55,8 +58,8 @@ class SyscallBinder<TR, T1, T2> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1));
}
};
@ -67,8 +70,8 @@ class SyscallBinder<TR, T1, T2, T3> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2, T3)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2));
}
};
@ -79,8 +82,8 @@ class SyscallBinder<TR, T1, T2, T3, T4> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2, T3, T4)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3));
}
};
@ -91,8 +94,8 @@ class SyscallBinder<TR, T1, T2, T3, T4, T5> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2, T3, T4, T5)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4));
}
};
@ -103,8 +106,8 @@ class SyscallBinder<TR, T1, T2, T3, T4, T5, T6> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2, T3, T4, T5, T6)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4), ARG_GPR(T6,5));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4), ARG_GPR(T6,5));
}
};
@ -115,8 +118,8 @@ class SyscallBinder<TR, T1, T2, T3, T4, T5, T6, T7> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2, T3, T4, T5, T6, T7)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4), ARG_GPR(T6,5), ARG_GPR(T7,6));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4), ARG_GPR(T6,5), ARG_GPR(T7,6));
}
};
@ -127,12 +130,18 @@ class SyscallBinder<TR, T1, T2, T3, T4, T5, T6, T7, T8> : public Syscall {
public:
SyscallBinder(TR(*func)(T1, T2, T3, T4, T5, T6, T7, T8)) : m_func(func) {}
virtual void call(cpu::frontend::ppu::PPUState& state, void* memoryBase) {
state.r[3] = m_func(ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4), ARG_GPR(T6,5), ARG_GPR(T7,6), ARG_GPR(T8,7));
virtual void call(cpu::frontend::ppu::PPUState& state, LV2* kernel, void* memoryBase) {
state.r[3] = m_func(kernel, ARG_GPR(T1,0), ARG_GPR(T2,1), ARG_GPR(T3,2), ARG_GPR(T4,3), ARG_GPR(T5,4), ARG_GPR(T6,5), ARG_GPR(T7,6), ARG_GPR(T8,7));
}
};
template <typename TR, typename... TA>
Syscall* wrap(TR(*func)(TA...)) {
/**
* Wraps a syscall.
* @tparam TR Type of return value
* @tparam TK Type of kernel pointer
* @tparam TA Type of arguments
*/
template <typename TR, typename TK, typename... TA>
Syscall* wrap(TR(*func)(TK, TA...)) {
return new SyscallBinder<TR, TA...>(func);
}

View file

@ -49,6 +49,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\lv2\sys_time.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\lv2\sys_timer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\lv2\sys_tty.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\lv2_macro.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\module.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\modules\libsysutil.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\modules\libsysutil_avconf_ext.h" />

View file

@ -151,6 +151,9 @@
<ClInclude Include="$(MSBuildThisFileDirectory)scei\cellos\lv2\sys_lwcond.h">
<Filter>scei\cellos\lv2</Filter>
</ClInclude>
<ClInclude Include="C:\Users\Alex\Documents\GitHub\nucleus\nucleus\system\scei\cellos\lv2_macro.h">
<Filter>scei\cellos</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)scei\cellos\modules\libsysutil.cpp">