Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/ipc/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,16 @@ int pipe_mknod(char *path, uint16_t mode);
/* Copy up to len bytes between two pipe endpoints without consuming the input. */
int64_t pipe_tee(void *in_private, void *out_private, size_t len, uint64_t flags);

/* Create an anonymous in-kernel pipe with one reader and one writer. */
void *pipe_kernel_create(void);

/* Blocking read from an in-kernel pipe. */
int64_t pipe_kernel_read(void *pipe, void *addr, size_t size);

/* Blocking write to an in-kernel pipe. */
int64_t pipe_kernel_write(void *pipe, const void *addr, size_t size);

/* Free an in-kernel pipe once neither end is in use. */
void pipe_kernel_destroy(void *pipe);

#endif // INCLUDE_PIPE_H_
17 changes: 17 additions & 0 deletions include/kernel/debug/kbench.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
*
* kbench.h
* In-kernel micro-benchmarks
*
* 2026/10/21 By JiTianYu391
* Copyright (C) 2020 ViudiraTech, based on the Apache 2.0 license.
*
*/

#ifndef INCLUDE_KBENCH_H_
#define INCLUDE_KBENCH_H_

/* Register the benchmark worker when the command line carries kbench[=rounds]. */
void kbench_init(void);

#endif // INCLUDE_KBENCH_H_
2 changes: 2 additions & 0 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include <ipc/sysv_ipc.h>
#include <kernel/cmdline/cmdline.h>
#include <kernel/debug/debug.h>
#include <kernel/debug/kbench.h>
#include <kernel/interrupt/interrupt.h>
#include <kernel/module/module.h>
#include <kernel/timer/timer.h>
Expand Down Expand Up @@ -422,6 +423,7 @@ __attribute__((noreturn)) void kernel_entry(void)
usb_host_start_workers(); // Register USB host workers
video_start_refresh_worker(); // Register display refresh worker
timer_deferred_init(); // Register timer bottom-half processing
kbench_init(); // Register the kbench worker when requested
kernel_workers_start(); // Create every registered kernel worker
swapper_enqueue_init(); // Finally make init runnable
//
Expand Down
28 changes: 28 additions & 0 deletions ipc/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,34 @@ static size_t pipe_vfs_write(void *file, const void *addr, size_t offset, size_t
return result < 0 ? (size_t)-1 : (size_t)result;
}

/* Create an anonymous in-kernel pipe with one reader and one writer. */
void *pipe_kernel_create(void)
{
pipe_ring_t *ring = pipe_ring_alloc();
if (!ring) return NULL;
ring->readers = 1;
ring->writers = 1;
return ring;
}

/* Blocking read from an in-kernel pipe. */
int64_t pipe_kernel_read(void *pipe, void *addr, size_t size)
{
return pipe_read_common(NULL, pipe, 0, addr, size);
}

/* Blocking write to an in-kernel pipe. */
int64_t pipe_kernel_write(void *pipe, const void *addr, size_t size)
{
return pipe_write_common(NULL, pipe, 0, addr, size);
}

/* Free an in-kernel pipe once neither end is in use. */
void pipe_kernel_destroy(void *pipe)
{
pipe_ring_free(pipe);
}

/* Copy up to len bytes between two pipe endpoints without consuming the input, for tee(2). */
int64_t pipe_tee(void *in_private, void *out_private, size_t len, uint64_t flags)
{
Expand Down
Loading
Loading