vxKernel/vxgos/kernel/include/vhex/device.h
Yann MAGNIN 597b25682a vxkernel - v0.7.0-1 : architecture overhaul + bootloader KASLR resolve
---

The objective of this early rework of the kernel architecture is to prepare the
project to run on other hardware than the Casio calculator (like Raspberry Pi
devices). This is why I switched the kernel workflow to integrate a custom
bootloader for the particular kernel image we generate.

The v0.7.0 of the kernel is not released since the USB driver is not stable
yet. But the need to deeply rework the architecture is prioritized. So, as this
is a critical update, I update the minor version (which is a major indicator
here since I don't have the mature version yet (v1.x.x)).

Also, I work on a brand-new micro-kernel (for the Raspberry Pi 3b and Google
Pixels), so, the name of this project, Vhex, has migrated to a temporary
name(?): VxGOS (for Vhex Gaming Operating System), which will be changed as
soon as the v0.8.0 is released. (I choose this name only because the word
"gaming" make me laugh. Take showers folks).

The objective of version 0.8.0 is to support:

    - architecture rework
    - internal bootloader
    - proper KASLR support
    - stack protection (libSSP)

---

*update*
> [common]
  | [kernel] move kernel source file in the new "vxgos" root directory
  | [boards] move board-related files / scripts in the new "vxgos"
  | [bootloader] support fxcg50 self-translation from ROM to RAM
  | [bootloader] support fxcg50 KASLR patching
  | [scripts] move `vxdev` tool in the new "scripts" root directory
  | [scripts] move norm related files to "checker" directory
  | [vxsdk] update the vxSDK indication file
2023-04-13 13:59:46 +02:00

69 lines
1.9 KiB
C

#ifndef __VHEX_DEVICE__
# define __VHEX_DEVICE__
#include <vhex/defs/attributes.h>
#include <vhex/defs/types.h>
struct vhex_device
{
/* device name */
const char * const name;
/* device flags */
byte_union(flags,
uint8_t :1;
uint8_t :1;
uint8_t :1;
uint8_t :1;
uint8_t :1;
uint8_t :1;
uint8_t :1;
uint8_t FS :1;
);
/* device primitives */
struct {
int (*init)(void);
int (*open)(void **data, const char *pathname, int flags, int mode);
ssize_t (*write)(void *data, const void *buf, size_t size);
ssize_t (*read)(void *data, void *buf, size_t size);
off_t (*lseek)(void *data, off_t offset, int whence);
int (*close)(void *data);
int (*quit)(void);
} primitives;
};
/* VHEX_DECLARE_DEVICE(): Declare a device for the kernel
Use this macro to declare a device by passing it the name of a
vhex_device structure. This macro moves the structure to the
`.vhex.device` sections, which are automatically traversed at startup. */
#define VHEX_DECLARE_DEVICE(name) \
VSECTION(".vhex.device") extern struct vhex_device name;
//---
// Internal driver control
//
// The following data is exposed for introspection and debugging purposes; it
// is not part of the vhex API. There is *no stability guarantee* that the
// following types and functions will remain unchanged in future minor and
// patch versions.
//---
/* Number of drivers in the (vhex_drivers) array */
#define vhex_device_count() \
((struct vhex_device *)&vhex_devices_end \
- (struct vhex_device *)&vhex_devices_start)
/* driver table */
#define vhex_device_table() \
((struct vhex_device *)&vhex_devices_start)
/* provided by the linker script */
extern uintptr_t vhex_devices_start;
extern uintptr_t vhex_devices_end;
#endif /* __VHEX_DEVICE__ */