| 765 | } |
| 766 | |
| 767 | error_code cellSyncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::cptr<void> buffer, u32 size, u32 depth, u32 direction, vm::ptr<void> eaSignal) |
| 768 | { |
| 769 | cellSync.warning("cellSyncLFQueueInitialize(queue=*0x%x, buffer=*0x%x, size=0x%x, depth=0x%x, direction=%d, eaSignal=*0x%x)", queue, buffer, size, depth, direction, eaSignal); |
| 770 | |
| 771 | if (!queue) [[unlikely]] |
| 772 | { |
| 773 | return CELL_SYNC_ERROR_NULL_POINTER; |
| 774 | } |
| 775 | |
| 776 | if (size) |
| 777 | { |
| 778 | if (!buffer) [[unlikely]] |
| 779 | { |
| 780 | return CELL_SYNC_ERROR_NULL_POINTER; |
| 781 | } |
| 782 | |
| 783 | if (size > 0x4000 || size % 16) [[unlikely]] |
| 784 | { |
| 785 | return CELL_SYNC_ERROR_INVAL; |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | if (!depth || depth > 0x7fff || direction > 3) [[unlikely]] |
| 790 | { |
| 791 | return CELL_SYNC_ERROR_INVAL; |
| 792 | } |
| 793 | |
| 794 | if (!queue.aligned() || !buffer.aligned(16)) [[unlikely]] |
| 795 | { |
| 796 | return CELL_SYNC_ERROR_ALIGN; |
| 797 | } |
| 798 | |
| 799 | // get sdk version of current process |
| 800 | s32 sdk_ver; |
| 801 | |
| 802 | if (s32 ret = process_get_sdk_version(process_getpid(), sdk_ver)) |
| 803 | { |
| 804 | return not_an_error(ret); |
| 805 | } |
| 806 | |
| 807 | if (sdk_ver == -1) |
| 808 | { |
| 809 | sdk_ver = 0x460000; |
| 810 | } |
| 811 | |
| 812 | // reserve `init` |
| 813 | u32 old_value; |
| 814 | |
| 815 | while (true) |
| 816 | { |
| 817 | const auto old = queue->init.load(); |
| 818 | auto init = old; |
| 819 | |
| 820 | if (old) |
| 821 | { |
| 822 | if (sdk_ver > 0x17ffff && old != 2) [[unlikely]] |
| 823 | { |
| 824 | return CELL_SYNC_ERROR_STAT; |
no test coverage detected