Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msg API changes #351

Merged
merged 2 commits into from
Mar 21, 2024
Merged
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ include misc/Makefile
include net/Makefile
include netinet/Makefile
include posix/Makefile
include phoenix/Makefile
include pthread/Makefile
include regex/Makefile
include signal/Makefile
Expand Down
26 changes: 26 additions & 0 deletions include/phoenix/attribute.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* phoenix/attribute.h
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _LIBPHOENIX_PHOENIX_ATTRIBUTE_H_
#define _LIBPHOENIX_PHOENIX_ATTRIBUTE_H_


#include <sys/msg.h>

/* Initializes `struct _attrAll` errors to `err` */
void _phoenix_initAttrsStruct(struct _attrAll *attrs, int err);

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m4-stm32l4x6-nucleo)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt105x-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-spike)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zturn)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt117x-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-pc)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 23 in include/phoenix/attribute.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration


#endif
2 changes: 0 additions & 2 deletions include/sys/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ enum { mtMount = 0xf50, mtUmount, mtSync, mtStat, mtMountPoint };


typedef struct {
oid_t dev;
oid_t mnt;
unsigned long mode;
char fstype[16];
} mount_i_msg_t;


typedef struct {
int err;
oid_t oid;
} mount_o_msg_t;

Expand Down
13 changes: 8 additions & 5 deletions include/sys/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,19 @@ extern "C" {
int ioctl(int fd, unsigned long cmd, ...);


const void *ioctl_unpack(const msg_t *msg, unsigned long *request, id_t *id);
const void *ioctl_unpack(msg_t *msg, unsigned long *request, id_t *id);

const void *ioctl_unpackEx(const msg_t *msg, unsigned long *request, id_t *id, void **response_buf);

pid_t ioctl_getSenderPid(const msg_t *msg);
const void *ioctl_unpackEx(msg_t *msg, unsigned long *request, id_t *id, void **response_buf);


void ioctl_setResponse(msg_t *msg, unsigned long request, int err, const void *data);
static inline pid_t ioctl_getSenderPid(const msg_t *msg)
{
return (pid_t)msg->pid;
}

void ioctl_setResponseErr(msg_t *msg, unsigned long request, int err);

void ioctl_setResponse(msg_t *msg, unsigned long request, int err, const void *data);


#ifdef __cplusplus
Expand Down
9 changes: 9 additions & 0 deletions phoenix/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Makefile for libphoenix/phoenix
#
# Copyright 2024 Phoenix Systems
#
# %LICENSE%
#

OBJS += $(addprefix $(PREFIX_O)phoenix/, attribute.o)
37 changes: 37 additions & 0 deletions phoenix/attribute.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* phoenix/attribute
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include <phoenix/attribute.h>


void _phoenix_initAttrsStruct(struct _attrAll *attrs, int err)

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m4-stm32l4x6-nucleo)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m4-stm32l4x6-nucleo)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt105x-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt105x-evk)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-spike)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-spike)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-qemu)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zturn)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zturn)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt117x-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt117x-evk)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-pc)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-pc)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-qemu)

conflicting types for '_phoenix_initAttrsStruct'

Check warning on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check failure on line 19 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

conflicting types for '_phoenix_initAttrsStruct'
{
attrs->mode.err = err;

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m4-stm32l4x6-nucleo)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt105x-evk)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-spike)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (riscv64-generic-qemu)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zturn)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt117x-evk)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-pc)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (ia32-generic-qemu)

dereferencing pointer to incomplete type 'struct _attrAll'

Check failure on line 21 in phoenix/attribute.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

dereferencing pointer to incomplete type 'struct _attrAll'
attrs->uid.err = err;
attrs->gid.err = err;
attrs->size.err = err;
attrs->blocks.err = err;
attrs->blocks.err = err;
attrs->ioblock.err = err;
attrs->type.err = err;
attrs->port.err = err;
attrs->pollStatus.err = err;
attrs->eventMask.err = err;
attrs->cTime.err = err;
attrs->mTime.err = err;
attrs->aTime.err = err;
attrs->links.err = err;
attrs->dev.err = err;
}
16 changes: 8 additions & 8 deletions sys/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ static struct {

int eventsSend(event_t *event, int count)
{
msg_t msg;
int err = -ENOSYS;

if (event_common.sink_open || (event_common.sink_open = (lookup("/dev/event/sink", NULL, &event_common.sink) == EOK))) {
msg.type = mtWrite;

msg.i.io.oid = event_common.sink;
msg.i.data = event;
msg.i.size = count * sizeof(event_t);
msg.o.data = NULL;
msg.o.size = 0;
msg_t msg = {
.type = mtWrite,
.oid = event_common.sink,
.i.data = event,
.i.size = count * sizeof(event_t),
.o.data = NULL,
.o.size = 0
};

err = msgSend(event_common.sink.port, &msg);
}
Expand Down
35 changes: 8 additions & 27 deletions sys/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
#include <stdlib.h>


const void *ioctl_unpack(const msg_t *msg, unsigned long *request, id_t *id)
const void *ioctl_unpack(msg_t *msg, unsigned long *request, id_t *id)
{
return ioctl_unpackEx(msg, request, id, NULL);
}


const void *ioctl_unpackEx(const msg_t *msg, unsigned long *request, id_t *id, void **response_buf)
const void *ioctl_unpackEx(msg_t *msg, unsigned long *request, id_t *id, void **response_buf)
{
size_t size;
const void *data = NULL;
Expand All @@ -44,7 +44,7 @@ const void *ioctl_unpackEx(const msg_t *msg, unsigned long *request, id_t *id, v
}

if (id != NULL) {
*id = ioctl->id;
*id = msg->oid.id;
}

size = IOCPARM_LEN(ioctl->request);
Expand Down Expand Up @@ -91,9 +91,8 @@ const void *ioctl_unpackEx(const msg_t *msg, unsigned long *request, id_t *id, v
}

if ((response_buf != NULL) && ((ioctl->request & IOC_OUT) != 0)) {
ioctl_out_t *ioctl_out = (ioctl_out_t *)msg->o.raw;
if (size <= (sizeof(msg->o.raw) - sizeof(ioctl_out_t))) {
*response_buf = ioctl_out->data;
if (size <= sizeof(msg->o.raw)) {
*response_buf = msg->o.raw;
}
else {
*response_buf = msg->o.data;
Expand All @@ -108,24 +107,16 @@ const void *ioctl_unpackEx(const msg_t *msg, unsigned long *request, id_t *id, v
}


pid_t ioctl_getSenderPid(const msg_t *msg)
{
const ioctl_in_t *ioctl = (const ioctl_in_t *)msg->i.raw;
return (pid_t)ioctl->pid;
}


void ioctl_setResponse(msg_t *msg, unsigned long request, int err, const void *data)
{
size_t size = IOCPARM_LEN(request);
void *dst;
ioctl_out_t *ioctl = (ioctl_out_t *)msg->o.raw;

ioctl->err = err;
msg->o.err = err;

if (((request & IOC_OUT) != 0) && (data != NULL)) {
if (size <= (sizeof(msg->o.raw) - sizeof(ioctl_out_t))) {
dst = ioctl->data;
if (size <= sizeof(msg->o.raw)) {
dst = msg->o.raw;
}
else {
dst = msg->o.data;
Expand All @@ -134,13 +125,3 @@ void ioctl_setResponse(msg_t *msg, unsigned long request, int err, const void *d
(void)memcpy(dst, data, size);
}
}


void ioctl_setResponseErr(msg_t *msg, unsigned long request, int err)
{
ioctl_out_t *ioctl = (ioctl_out_t *)msg->o.raw;

(void)request;

ioctl->err = err;
}
Loading
Loading