Support blocking server.

This commit is contained in:
TXuian
2024-04-30 18:17:31 +08:00
parent 9f9e25a98e
commit 3a985252d9
13 changed files with 174 additions and 59 deletions
+5 -1
View File
@@ -24,7 +24,7 @@ INC_DIR = -I$(KERNEL_ROOT)/services/shell/letter-shell \
-I$(KERNEL_ROOT)/services/app
ifeq ($(BOARD), imx6q-sabrelite)
all: init test_fs simple_client simple_server shell fs_server test_irq_hdlr test_irq_send readme.txt | bin
all: init test_fs simple_client simple_server shell fs_server test_irq_hdlr test_irq_block test_irq_send readme.txt | bin
else
all: init test_fs simple_client simple_server shell fs_server test_irq_hdlr readme.txt | bin
endif
@@ -42,6 +42,10 @@ test_irq_send: test_irq_sender.o usyscall.o libserial.o
@${objdump} -S $@ > $@.asm
endif
test_irq_block: test_irq_block.o libserial.o libipc.o session.o usyscall.o libmem.o
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
@${objdump} -S $@ > $@.asm
test_irq_hdlr: test_irq_handler.o libserial.o libipc.o session.o usyscall.o libmem.o
@${ld} ${user_ldflags} -e main -o $@ $^ ${board_specs}
@${objdump} -S $@ > $@.asm
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#include "libipc.h"
#include "libserial.h"
#include "usyscall.h"
IPC_SERVICES(IpcSwIntrHandler, Ipc_intr_3, Ipc_wait_intr_3);
enum {
SW_INTERRUPT_3 = 3,
};
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#include "test_irq.h"
IPC_INTERFACE(Ipc_wait_intr_3, 1, ignore, 0);
int wait_intr(struct Session* session, void* ignore_param)
{
return IPC_CALL(Ipc_wait_intr_3)(session, NULL);
}
static char prog_name[] = "TEST_IRQ_BLOCK";
int main(int argc, char* argv[])
{
struct Session session;
if (connect_session(&session, "TestIRQ", 4096) < 0) {
printf("connect session failed\n");
exit();
}
printf("%s start waiting for IRQ.\n", prog_name);
wait_intr(&session, NULL);
printf("%s return from waiting for IRQ.\n", prog_name);
exit();
}
@@ -10,35 +10,45 @@
* See the Mulan PSL v2 for more details.
*/
#include "libipc.h"
#include "libserial.h"
#include "usyscall.h"
#include "test_irq.h"
IPC_SERVICES(IpcSwIntrHandler, Ipc_intr_3);
enum {
SW_INTERRUPT_3 = 3,
};
void sgi_test_handler(void)
static bool has_one_interrupt = false;
int IPC_DO_SERVE_FUNC(Ipc_intr_3)(void* ignore)
{
printf("TEST_SW_HDLR: In %s()\n", __func__);
has_one_interrupt = true;
return 0;
}
int IPC_DO_SERVE_FUNC(Ipc_intr_3)(void* useless)
int IPC_DO_SERVE_FUNC(Ipc_wait_intr_3)(void* ignore)
{
sgi_test_handler();
// delay the this handle
if (!has_one_interrupt) {
delay_session();
return -1;
}
// serve can be done by now
has_one_interrupt = false;
return 0;
}
IPC_SERVER_INTERFACE(Ipc_intr_3, 1);
IPC_SERVER_REGISTER_INTERFACES(IpcSwIntrHandler, 1, Ipc_intr_3);
IPC_SERVER_INTERFACE(Ipc_wait_intr_3, 1);
IPC_SERVER_REGISTER_INTERFACES(IpcSwIntrHandler, 2, Ipc_intr_3, Ipc_wait_intr_3);
int main()
{
if (register_irq(SW_INTERRUPT_3, Ipc_intr_3) == -1) {
if (register_irq(SW_INTERRUPT_3, Ipc_intr_3) < 0) {
printf("TEST_SW_HDLR: bind failed");
exit();
}
static char prog_name[] = "TestIRQ";
if (register_server("TestIRQ") < 0) {
printf("register server name: %s failed.\n", prog_name);
exit();
}
ipc_server_loop(&IpcSwIntrHandler);
exit();