Prepare main structure for managing message queues.
This commit is contained in:
+8
-10
@@ -27,8 +27,6 @@ struct msgbuf {
|
||||
|
||||
/// Keeps track of a stored message.
|
||||
struct msg {
|
||||
/// Pointer to the next message on queue.
|
||||
struct msg *msg_next;
|
||||
/// The type of message.
|
||||
long msg_type;
|
||||
/// Pointer to the beginning of the message.
|
||||
@@ -38,13 +36,9 @@ struct msg {
|
||||
};
|
||||
|
||||
/// @brief Message queue data structure.
|
||||
typedef struct msqid_ds {
|
||||
struct msqid_ds {
|
||||
/// Ownership and permissions.
|
||||
struct ipc_perm msg_perm;
|
||||
/// First message on queue
|
||||
struct msg *msg_first;
|
||||
/// Last message in queue
|
||||
struct msg *msg_last;
|
||||
/// Time of last msgsnd(2).
|
||||
time_t msg_stime;
|
||||
/// Time of last msgrcv(2).
|
||||
@@ -61,10 +55,14 @@ typedef struct msqid_ds {
|
||||
pid_t msg_lspid;
|
||||
/// PID of last msgrcv(2).
|
||||
pid_t msg_lrpid;
|
||||
} msqid_ds_t;
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/// @brief Initializes the message queue system.
|
||||
/// @return 0 on success, 1 on failure.
|
||||
int msq_init();
|
||||
|
||||
/// @brief Get a System V message queue identifier.
|
||||
/// @param key can be used either to obtain the identifier of a previously
|
||||
/// created message queue, or to create a new set.
|
||||
@@ -99,7 +97,7 @@ long sys_msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int m
|
||||
/// @param cmd The command to perform.
|
||||
/// @param buf used with IPC_STAT and IPC_SET.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long sys_msgctl(int msqid, int cmd, msqid_ds_t *buf);
|
||||
long sys_msgctl(int msqid, int cmd, struct msqid_ds *buf);
|
||||
|
||||
#else
|
||||
|
||||
@@ -137,6 +135,6 @@ long msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgfl
|
||||
/// @param cmd The command to perform.
|
||||
/// @param buf used with IPC_STAT and IPC_SET.
|
||||
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||
long msgctl(int msqid, int cmd, msqid_ds_t *buf);
|
||||
long msgctl(int msqid, int cmd, struct msqid_ds *buf);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ struct sembuf {
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/// @brief Initializes the semaphore system.
|
||||
/// @return int
|
||||
/// @return 0 on success, 1 on failure.
|
||||
int sem_init();
|
||||
|
||||
/// @brief Get a System V semaphore set identifier.
|
||||
|
||||
+24
-3
@@ -2,7 +2,6 @@
|
||||
/// @brief
|
||||
/// @copyright (c) 2014-2023 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
///! @cond Doxygen_Suppress
|
||||
|
||||
// ============================================================================
|
||||
// Setup the logging for this file (do this before any other include).
|
||||
@@ -29,6 +28,8 @@ typedef struct {
|
||||
int id;
|
||||
/// @brief The message queue data strcutre.
|
||||
struct msqid_ds msqid;
|
||||
/// Pointer to the first message in the queue.
|
||||
struct msg *msg_base;
|
||||
/// Reference inside the list of message queue management structures.
|
||||
list_head list;
|
||||
} msq_info_t;
|
||||
@@ -36,6 +37,24 @@ typedef struct {
|
||||
/// @brief List of all current active Message queues.
|
||||
list_head msq_list;
|
||||
|
||||
// ============================================================================
|
||||
// MEMORY MANAGEMENT (Private)
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// SEARCH FUNCTIONS (Private)
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// SYSTEM FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
int msq_init()
|
||||
{
|
||||
list_head_init(&msq_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
long sys_msgget(key_t key, int msgflg)
|
||||
{
|
||||
TODO("Not implemented");
|
||||
@@ -60,6 +79,10 @@ long sys_msgctl(int msqid, int cmd, struct msqid_ds *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PROCFS FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
ssize_t procipc_msg_read(vfs_file_t *file, char *buf, off_t offset, size_t nbyte)
|
||||
{
|
||||
if (!file) {
|
||||
@@ -90,5 +113,3 @@ ssize_t procipc_msg_read(vfs_file_t *file, char *buf, off_t offset, size_t nbyte
|
||||
}
|
||||
return write_count;
|
||||
}
|
||||
|
||||
///! @endcond
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "system/syscall.h"
|
||||
#include "sys/module.h"
|
||||
#include "sys/sem.h"
|
||||
#include "sys/msg.h"
|
||||
#include "io/proc_modules.h"
|
||||
#include "io/vga/vga.h"
|
||||
#include "io/video.h"
|
||||
@@ -312,6 +313,16 @@ int kmain(boot_info_t *boot_informations)
|
||||
}
|
||||
print_ok();
|
||||
|
||||
//==========================================================================
|
||||
pr_notice("Initialize IPC/MSQ system...\n");
|
||||
printf("Initialize IPC/MSQ system...");
|
||||
if (msq_init()) {
|
||||
print_fail();
|
||||
pr_emerg("Failed to initialize the IPC/MSQ system!\n");
|
||||
return 1;
|
||||
}
|
||||
print_ok();
|
||||
|
||||
//==========================================================================
|
||||
pr_notice("Setting up PS/2 driver...\n");
|
||||
printf("Setting up PS/2 driver...");
|
||||
|
||||
Reference in New Issue
Block a user