summaryrefslogtreecommitdiff
path: root/src/drv/ps1/bios
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-07-07 13:22:53 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-07-25 14:16:41 +0200
commit14f60e4fd65c42f126eaee7e09cb4251c167c6ed (patch)
tree313b5e16d7d99cf1518c953e2efe5e5fc920dfbf /src/drv/ps1/bios
parent48a61c16eaa6dcfc75d00dba302537ce1492db98 (diff)
downloadwnix-tty.tar.gz
wiptty
Diffstat (limited to 'src/drv/ps1/bios')
-rw-r--r--src/drv/ps1/bios/CMakeLists.txt19
-rw-r--r--src/drv/ps1/bios/include/drv/ps1/bios.h112
-rw-r--r--src/drv/ps1/bios/src/CMakeLists.txt29
-rw-r--r--src/drv/ps1/bios/src/CdAsyncGetStatus.s21
-rw-r--r--src/drv/ps1/bios/src/CdAsyncReadSector.s21
-rw-r--r--src/drv/ps1/bios/src/CdAsyncSeekL.s21
-rw-r--r--src/drv/ps1/bios/src/CloseEvent.s21
-rw-r--r--src/drv/ps1/bios/src/DisableEvent.s21
-rw-r--r--src/drv/ps1/bios/src/EnableEvent.s23
-rw-r--r--src/drv/ps1/bios/src/EnterCriticalSection.s25
-rw-r--r--src/drv/ps1/bios/src/ExitCriticalSection.s23
-rw-r--r--src/drv/ps1/bios/src/OpenEvent.s21
-rw-r--r--src/drv/ps1/bios/src/TestEvent.s23
-rw-r--r--src/drv/ps1/bios/src/WaitEvent.s23
14 files changed, 403 insertions, 0 deletions
diff --git a/src/drv/ps1/bios/CMakeLists.txt b/src/drv/ps1/bios/CMakeLists.txt
new file mode 100644
index 0000000..255a27d
--- /dev/null
+++ b/src/drv/ps1/bios/CMakeLists.txt
@@ -0,0 +1,19 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+add_library(drv_ps1_bios)
+add_subdirectory(src)
+target_include_directories(drv_ps1_bios INTERFACE include)
diff --git a/src/drv/ps1/bios/include/drv/ps1/bios.h b/src/drv/ps1/bios/include/drv/ps1/bios.h
new file mode 100644
index 0000000..2686f12
--- /dev/null
+++ b/src/drv/ps1/bios/include/drv/ps1/bios.h
@@ -0,0 +1,112 @@
+/*
+ * wanix, a Unix-like operating system for WebAssembly applications.
+ * Copyright (C) 2025 Xavier Del Campo Romero
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef PS1_BIOS_H
+#define PS1_BIOS_H
+
+#include <stdint.h>
+
+enum
+{
+ CLASS_IRQ0 = (long)0xf0000001,
+ CLASS_GPU,
+ CLASS_CDROM,
+ CLASS_DMA,
+ CLASS_RTC0 = (long)0xf2000000,
+ CLASS_RTC1,
+ CLASS_RTC2,
+ CLASS_VBLANK,
+ CLASS_CONTROLLER = (long)0xf0000008,
+ CLASS_SPU,
+ CLASS_PIO,
+ CLASS_SIO
+};
+
+enum
+{
+ MODE_EXECUTE = 0x1000,
+ MODE_READY = 0x2000
+};
+
+enum
+{
+ SPEC_COUNTER_ZERO = 1,
+ SPEC_INTERRUPTED = 1 << 1,
+ SPEC_EOF = 1 << 2,
+ SPEC_FILE_CLOSED = 1 << 3,
+ SPEC_COMMAND_ACK = 1 << 4,
+ SPEC_COMMAND_COMPLETE = 1 << 5,
+ SPEC_DATA_READY = 1 << 6,
+ SPEC_DATA_END = 1 << 7,
+ SPEC_TIMEOUT = 1 << 8,
+ SPEC_UNKNOWN_CMD = 1 << 9,
+ SPEC_END_READ_BUF = 1 << 10,
+ SPEC_END_WRITE_BUF = 1 << 11,
+ SPEC_GENERAL_INTERRUPT = 1 << 12,
+ SPEC_NEW_DEVICE = 1 << 13,
+ SPEC_SYSCALL = 1 << 14,
+ SPEC_ERROR = 1 << 15,
+ SPEC_WRITE_ERROR,
+ SPEC_DOMAIN_ERROR = 0x301,
+ SPEC_RANGE_RNG
+};
+
+struct CdAsyncSeekL
+{
+ uint8_t minutes, seconds, frames;
+};
+
+union SetMode
+{
+ struct
+ {
+ uint8_t cdda :1, autopause :1, report :1, xa_filter :1, ignore :1,
+ whole_sector :1, xa_adpcm :1, speed :1;
+ } bits;
+
+ uint8_t mask;
+};
+
+struct CdAsyncReadSector_mode
+{
+ union SetMode mode;
+ union
+ {
+ struct
+ {
+ uint8_t reads :1, :7;
+ } bits;
+ } read;
+
+ uint16_t reserved;
+};
+
+void EnterCriticalSection(void);
+void ExitCriticalSection(void);
+int OpenEvent(int class, int spec, int mode, int (*f)(void));
+int EnableEvent(int event);
+int DisableEvent(int event);
+int CloseEvent(int event);
+int TestEvent(int event);
+int WaitEvent(int event);
+int CdAsyncGetStatus(uint8_t *response);
+int CdAsyncReadSector(unsigned count, void *dst,
+ struct CdAsyncReadSector_mode mode);
+int CdAsyncSeekL(const struct CdAsyncSeekL *seekl);
+
+#endif
diff --git a/src/drv/ps1/bios/src/CMakeLists.txt b/src/drv/ps1/bios/src/CMakeLists.txt
new file mode 100644
index 0000000..b1ea9cd
--- /dev/null
+++ b/src/drv/ps1/bios/src/CMakeLists.txt
@@ -0,0 +1,29 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+target_sources(drv_ps1_bios PRIVATE
+ CdAsyncGetStatus.s
+ CdAsyncReadSector.s
+ CdAsyncSeekL.s
+ CloseEvent.s
+ DisableEvent.s
+ EnableEvent.s
+ EnterCriticalSection.s
+ ExitCriticalSection.s
+ OpenEvent.s
+ TestEvent.s
+ WaitEvent.s
+)
diff --git a/src/drv/ps1/bios/src/CdAsyncGetStatus.s b/src/drv/ps1/bios/src/CdAsyncGetStatus.s
new file mode 100644
index 0000000..77464ea
--- /dev/null
+++ b/src/drv/ps1/bios/src/CdAsyncGetStatus.s
@@ -0,0 +1,21 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global CdAsyncGetStatus
+
+CdAsyncGetStatus:
+ li $9, 0x7c
+ j 0xa0
+ nop
diff --git a/src/drv/ps1/bios/src/CdAsyncReadSector.s b/src/drv/ps1/bios/src/CdAsyncReadSector.s
new file mode 100644
index 0000000..c68b54a
--- /dev/null
+++ b/src/drv/ps1/bios/src/CdAsyncReadSector.s
@@ -0,0 +1,21 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global CdAsyncReadSector
+
+CdAsyncReadSector:
+ li $9, 0x7e
+ j 0xa0
+ nop
diff --git a/src/drv/ps1/bios/src/CdAsyncSeekL.s b/src/drv/ps1/bios/src/CdAsyncSeekL.s
new file mode 100644
index 0000000..cc20a32
--- /dev/null
+++ b/src/drv/ps1/bios/src/CdAsyncSeekL.s
@@ -0,0 +1,21 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global CdAsyncSeekL
+
+CdAsyncSeekL:
+ li $9, 0x78
+ j 0xa0
+ nop
diff --git a/src/drv/ps1/bios/src/CloseEvent.s b/src/drv/ps1/bios/src/CloseEvent.s
new file mode 100644
index 0000000..0ade6fa
--- /dev/null
+++ b/src/drv/ps1/bios/src/CloseEvent.s
@@ -0,0 +1,21 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global CloseEvent
+
+CloseEvent:
+ li $9, 0x9
+ j 0xb0
+ nop
diff --git a/src/drv/ps1/bios/src/DisableEvent.s b/src/drv/ps1/bios/src/DisableEvent.s
new file mode 100644
index 0000000..b2d96ca
--- /dev/null
+++ b/src/drv/ps1/bios/src/DisableEvent.s
@@ -0,0 +1,21 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global DisableEvent
+
+DisableEvent:
+ li $9, 0xd
+ j 0xb0
+ nop
diff --git a/src/drv/ps1/bios/src/EnableEvent.s b/src/drv/ps1/bios/src/EnableEvent.s
new file mode 100644
index 0000000..bbff315
--- /dev/null
+++ b/src/drv/ps1/bios/src/EnableEvent.s
@@ -0,0 +1,23 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.text
+
+.global EnableEvent
+
+EnableEvent:
+ li $9, 0xc
+ j 0xb0
+ nop
diff --git a/src/drv/ps1/bios/src/EnterCriticalSection.s b/src/drv/ps1/bios/src/EnterCriticalSection.s
new file mode 100644
index 0000000..ebf2de9
--- /dev/null
+++ b/src/drv/ps1/bios/src/EnterCriticalSection.s
@@ -0,0 +1,25 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.text
+
+.global EnterCriticalSection
+
+EnterCriticalSection:
+ li $a0, 1
+ syscall
+ nop
+ jr $ra
+ nop
diff --git a/src/drv/ps1/bios/src/ExitCriticalSection.s b/src/drv/ps1/bios/src/ExitCriticalSection.s
new file mode 100644
index 0000000..53f307a
--- /dev/null
+++ b/src/drv/ps1/bios/src/ExitCriticalSection.s
@@ -0,0 +1,23 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global ExitCriticalSection
+
+ExitCriticalSection:
+ li $a0, 2
+ syscall
+ nop
+ jr $ra
+ nop
diff --git a/src/drv/ps1/bios/src/OpenEvent.s b/src/drv/ps1/bios/src/OpenEvent.s
new file mode 100644
index 0000000..89cc7d4
--- /dev/null
+++ b/src/drv/ps1/bios/src/OpenEvent.s
@@ -0,0 +1,21 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.global OpenEvent
+
+OpenEvent:
+ li $9, 0x8
+ j 0xb0
+ nop
diff --git a/src/drv/ps1/bios/src/TestEvent.s b/src/drv/ps1/bios/src/TestEvent.s
new file mode 100644
index 0000000..4afe273
--- /dev/null
+++ b/src/drv/ps1/bios/src/TestEvent.s
@@ -0,0 +1,23 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.text
+
+.global TestEvent
+
+TestEvent:
+ li $9, 0xb
+ j 0xb0
+ nop
diff --git a/src/drv/ps1/bios/src/WaitEvent.s b/src/drv/ps1/bios/src/WaitEvent.s
new file mode 100644
index 0000000..1f2ca97
--- /dev/null
+++ b/src/drv/ps1/bios/src/WaitEvent.s
@@ -0,0 +1,23 @@
+# wanix, a Unix-like operating system for WebAssembly applications.
+# Copyright (C) 2025 Xavier Del Campo Romero
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+.text
+
+.global WaitEvent
+
+WaitEvent:
+ li $9, 0xa
+ j 0xb0
+ nop