Skip to content
Draft
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
16 changes: 9 additions & 7 deletions Makefile.host
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Makefile for minimal libphoenix prepared for host
#
# Copyright 2018-2021 Phoenix Systems
# Copyright 2018-2025 Phoenix Systems
#
# %LICENSE%
#
Expand All @@ -12,13 +12,13 @@ MAKEFLAGS += --no-print-directory
include ../phoenix-rtos-build/Makefile.common

# establish sysroot
INCLUDE_HOST := include_host
LIBNAME := libphoenix.a

CFLAGS += -Iinclude -fno-builtin-malloc
CFLAGS := -I$(INCLUDE_HOST) -fno-builtin-malloc $(CFLAGS)

HEADERS := sys/rb.h
HEADERS := $(patsubst %,$(PREFIX_H)%,$(HEADERS))
OBJS := sys/rb.o
HEADERS := $(patsubst $(INCLUDE_HOST)%,$(PREFIX_H)%,$(shell find $(INCLUDE_HOST) -name '*.h' 2>/dev/null))
OBJS := sys/rb.o sys/list.o posix/idtree.o src_host/sys/msg.o
OBJS := $(patsubst %,$(PREFIX_O)%,$(OBJS))


Expand All @@ -27,8 +27,10 @@ all: $(PREFIX_A)$(LIBNAME) $(HEADERS)
$(PREFIX_A)$(LIBNAME): $(OBJS)
$(ARCH)

$(PREFIX_H)%.h: include/%.h
$(HEADER)
$(PREFIX_H)%.h: $(INCLUDE_HOST)/%.h
$(SIL)mkdir -p $(@D); \
printf "HEADER %-24s\n" "$<"; \
cp -pRL "$<" "$@"

.PHONY: clean
clean:
Expand Down
170 changes: 170 additions & 0 deletions include_host/phoenix/msg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Phoenix-RTOS
*
* Host implementation of messages
*
* Copyright 2017, 2025 Phoenix Systems
* Author: Pawel Pisarczyk, Jakub Sejdak, Mateusz Piasecki
*
* %LICENSE%
*/

#include <stdint.h>

#include <sys/types.h>
#include <unistd.h>

#ifndef _LIBPHOENIX_HOST_MSG_H_
#define _LIBPHOENIX_HOST_MSG_H_


/* Based on phoenix-rtos-kernel/include/types.h */


typedef struct _oid_t {
uint32_t port;
uint64_t id;
} oid_t;


/* Based on phoenix-rtos-kernel/include/msg.h */


/* Return id, allocated in msgReceive, used in msgRespond */
typedef int msg_rid_t;

/*
* Message types
*/

/* clang-format off */

enum {
/* File operations */
mtOpen = 0, mtClose, mtRead, mtWrite, mtTruncate, mtDevCtl,

/* Object operations */
mtCreate, mtDestroy, mtSetAttr, mtGetAttr, mtGetAttrAll,

/* Directory operations */
mtLookup, mtLink, mtUnlink, mtReaddir,

mtCount,

mtStat = 0xf53
};

/* clang-format on */


#pragma pack(push, 8)


struct _attr {
long long val;
int err;
};


struct _attrAll {
struct _attr mode;
struct _attr uid;
struct _attr gid;
struct _attr size;
struct _attr blocks;
struct _attr ioblock;
struct _attr type;
struct _attr port;
struct _attr pollStatus;
struct _attr eventMask;
struct _attr cTime;
struct _attr mTime;
struct _attr aTime;
struct _attr links;
struct _attr dev;
};


typedef struct _msg_t {
int type;
unsigned int pid;
unsigned int priority;
oid_t oid;

struct {
union {
/* OPEN/CLOSE */
struct {
int flags;
} openclose;

/* READ/WRITE/TRUNCATE */
struct {
off_t offs;
size_t len;
unsigned mode;
} io;

/* CREATE */
struct {
int type;
unsigned mode;
oid_t dev;
} create;

/* SETATTR/GETATTR */
struct {
long long val;
int type;
} attr;

/* LINK/UNLINK */
struct {
oid_t oid;
} ln;

/* READDIR */
struct {
off_t offs;
} readdir;

unsigned char raw[64];
};

size_t size;
const void *data;
} i;

struct {
union {
/* ATTR */
struct {
long long val;
} attr;

/* CREATE */
struct {
oid_t oid;
} create;

/* LOOKUP */
struct {
oid_t fil;
oid_t dev;
} lookup;

unsigned char raw[64];
};

int err;
size_t size;
void *data;
} o;

} msg_t;


#pragma pack(pop)


#endif
1 change: 1 addition & 0 deletions include_host/posix/idtree.h
1 change: 1 addition & 0 deletions include_host/sys/list.h
1 change: 1 addition & 0 deletions include_host/sys/minmax.h
1 change: 1 addition & 0 deletions include_host/sys/msg.h
1 change: 1 addition & 0 deletions include_host/sys/rb.h
Loading
Loading