2022-02-13 15:01:01 +01:00
|
|
|
#ifndef __VHEX_DRIVER__
|
|
|
|
# define __VHEX_DRIVER__
|
|
|
|
|
2022-05-27 11:57:55 +02:00
|
|
|
#include <vhex/defs/attributes.h>
|
2022-02-13 15:01:01 +01:00
|
|
|
#include <vhex/defs/types.h>
|
|
|
|
|
|
|
|
/* Device drivers */
|
|
|
|
struct vhex_driver
|
|
|
|
{
|
|
|
|
/* Driver name */
|
|
|
|
char const *name;
|
|
|
|
|
|
|
|
// "Hypervisor" calls
|
|
|
|
|
|
|
|
/* Determine whether the device is powered. If NULL, the device is
|
|
|
|
assumed to be permanently powered. */
|
|
|
|
bool (*hpowered)(void);
|
|
|
|
/* Power on the device; this should allow register access to save the
|
|
|
|
peripheral state, with minimal state changes. Cannot be NULL if
|
|
|
|
hpowered() can return false. */
|
|
|
|
void (*hpoweron)(void);
|
|
|
|
/* Power off the device; Cannot be NULL if hpowered() can return
|
|
|
|
false. */
|
|
|
|
void (*hpoweroff)(void);
|
|
|
|
|
|
|
|
/* Save the hardware state; the (state) pointer points to a 4-aligned
|
|
|
|
region of (state_size) bytes. */
|
|
|
|
void (*hsave)(void *state);
|
|
|
|
/* Restore a hardware state previously saved by hsave(). */
|
|
|
|
void (*hrestore)(void const *state);
|
|
|
|
|
|
|
|
// Standard calls
|
|
|
|
|
|
|
|
/* Initialize the hardware for the driver to work in vhex. Usually
|
2022-05-27 11:57:55 +02:00
|
|
|
installs interrupt handlers and configures registers. Cannot be
|
|
|
|
NULL */
|
2022-02-13 15:01:01 +01:00
|
|
|
void (*configure)(void *state);
|
|
|
|
|
|
|
|
// Internal information
|
|
|
|
|
|
|
|
/* Size of the peripheral's hardware state (assumed 4-aligned) */
|
|
|
|
uint16_t state_size;
|
|
|
|
|
|
|
|
/* default flags for the driver */
|
2022-05-27 11:57:55 +02:00
|
|
|
byte_union(flags,
|
2022-08-08 20:19:00 +02:00
|
|
|
uint8_t RTC :1;
|
VxKernel 0.6.0-13 : Add keyboard API + update timer API
@add
<> include/vhex/driver/mpu/sh/sh7305/keysc
| add internal driver primitives
<> include/vhex/driver/mpu/sh/sh7305/tmu
| add internal driver primitives
<> include/vhex/keyboard
| add getkey* (high-level) API
| add key event API
| add key status API
| add keycode information
| add keyboard driver interface
@update
<> include/vhex/driver
| add KEYBOARD driver flags
<> include/vhex/keyboard
| isolate each part of the keyboard module
| link the keycache part with the driver-provided keycache information
<> src/drivers/mpu/sh/sh7305/keysc
| use the new keycache API (high-level interrupt handler)
| update keycache API
| link the new API in the driver device
<> src/drivers/mpu/sh/sh7305/tmu
| add timer reservation (WIP)
| use a "reservation" cache to known which timer is free instead of hardware
| rename internal functions
<> src/module/display
| Now, by default, DSTACK_CALL() create a pointer on a dstack_call_t
| use dsubimage dstack primitive in dimage()
@fix
<> board/fxcg50/fxcg50.ld
| remove the IL-memory and allow only the X-memory area. This because the
bootloader uses the IL-memory for DMA transfer and other "low-level"
routine used by Gint.
Moreover, I originally try to move each "display-driver" in this place,
but after some profiling and tests, the dclear()/dupdate() combo went from
9155us up to 33250us (for many reason). So, I keep this area free, but I
moved-back from RAM display routines.
<> board/fxcg50/initialize
| remove "section" copy. This role has been delegated to the bootload (vxBoot)
because, in the final ELF file generated by GCC, many relocalization
information for the IL/X memory has been set and the bootloader cannot
performs general relocalization.
So, all "special section/memory" displacement has been moved in the
bootloader and we don't have to worrying about the section copy.
<> src/drivers/mpu/sh/sh7305/tmu
| fix delay calculation in timer reload primitive
| disable interruption for profiling timer
<> src/module/dislay/
| fix shader index used during the dstack_render()
| fix many errors in dimage() shadow render (WIP)
2022-06-24 15:33:36 +02:00
|
|
|
uint8_t KEYBOARD :1;
|
|
|
|
uint8_t TIMER :1;
|
|
|
|
uint8_t DISPLAY :1;
|
|
|
|
|
2022-08-17 13:23:28 +02:00
|
|
|
uint8_t DMA :1;
|
VxKernel 0.6.0-13 : Add keyboard API + update timer API
@add
<> include/vhex/driver/mpu/sh/sh7305/keysc
| add internal driver primitives
<> include/vhex/driver/mpu/sh/sh7305/tmu
| add internal driver primitives
<> include/vhex/keyboard
| add getkey* (high-level) API
| add key event API
| add key status API
| add keycode information
| add keyboard driver interface
@update
<> include/vhex/driver
| add KEYBOARD driver flags
<> include/vhex/keyboard
| isolate each part of the keyboard module
| link the keycache part with the driver-provided keycache information
<> src/drivers/mpu/sh/sh7305/keysc
| use the new keycache API (high-level interrupt handler)
| update keycache API
| link the new API in the driver device
<> src/drivers/mpu/sh/sh7305/tmu
| add timer reservation (WIP)
| use a "reservation" cache to known which timer is free instead of hardware
| rename internal functions
<> src/module/display
| Now, by default, DSTACK_CALL() create a pointer on a dstack_call_t
| use dsubimage dstack primitive in dimage()
@fix
<> board/fxcg50/fxcg50.ld
| remove the IL-memory and allow only the X-memory area. This because the
bootloader uses the IL-memory for DMA transfer and other "low-level"
routine used by Gint.
Moreover, I originally try to move each "display-driver" in this place,
but after some profiling and tests, the dclear()/dupdate() combo went from
9155us up to 33250us (for many reason). So, I keep this area free, but I
moved-back from RAM display routines.
<> board/fxcg50/initialize
| remove "section" copy. This role has been delegated to the bootload (vxBoot)
because, in the final ELF file generated by GCC, many relocalization
information for the IL/X memory has been set and the bootloader cannot
performs general relocalization.
So, all "special section/memory" displacement has been moved in the
bootloader and we don't have to worrying about the section copy.
<> src/drivers/mpu/sh/sh7305/tmu
| fix delay calculation in timer reload primitive
| disable interruption for profiling timer
<> src/module/dislay/
| fix shader index used during the dstack_render()
| fix many errors in dimage() shadow render (WIP)
2022-06-24 15:33:36 +02:00
|
|
|
uint8_t :1;
|
|
|
|
uint8_t SHARED :1;
|
|
|
|
uint8_t UNUSED :1;
|
2022-05-27 11:57:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
/* module related-internal data */
|
|
|
|
void *module_data;
|
2022-02-13 15:01:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* VHEX_DECLARE_DRIVER(): Declare a driver to the kernel
|
|
|
|
|
|
|
|
Use this macro to declare a driver by passing it the name of a
|
|
|
|
vhex_world_core structure. This macro moves the structure to the
|
|
|
|
.vhex.drivers.* sections, which are automatically traversed at startup.
|
|
|
|
|
|
|
|
The level argument represents the priority level: lower numbers mean that
|
|
|
|
drivers will be loaded sooner. This numbering allows a primitive form of
|
|
|
|
dependency for drivers. You need to specify a level which is strictly
|
|
|
|
higher than the level of all the drivers you depend on.
|
|
|
|
|
|
|
|
The level number *MUST HAVE EXACTLY 2 DIGITS*, as it is used as a string in
|
|
|
|
the section name and the linker then sorts by name. If your driver has a
|
|
|
|
level lower than 10, you must add a leading 0. */
|
|
|
|
#define VHEX_DECLARE_DRIVER(level, name) \
|
|
|
|
VSECTION(".vhex.drivers." #level) extern struct vhex_driver 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_driver_count() \
|
|
|
|
((struct vhex_driver *)&vhex_drivers_end \
|
|
|
|
- (struct vhex_driver *)&vhex_drivers_start)
|
|
|
|
|
|
|
|
/* driver table */
|
|
|
|
#define vhex_driver_table() \
|
|
|
|
((struct vhex_driver *)&vhex_drivers_start)
|
|
|
|
|
|
|
|
/* provided by the linker script */
|
|
|
|
extern uintptr_t vhex_drivers_start;
|
|
|
|
extern uintptr_t vhex_drivers_end;
|
|
|
|
|
|
|
|
#endif /* __VHEX_DRIVER__ */
|