vxKernel/include/vhex/driver.h

105 lines
3.0 KiB
C
Raw Normal View History

#ifndef __VHEX_DRIVER__
# define __VHEX_DRIVER__
#include <vhex/defs/attributes.h>
#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
installs interrupt handlers and configures registers. Cannot be
NULL */
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 */
byte_union(flags,
VxKernel 0.6.0-17 : Add RTC driver + prepare FS support @add <> include/vhex/display/draw/rect | add filled rectangle API <> src/display/draw/drect | add filled rectangle drawing API <> board/fxcg50/ | add devices special section (WIP) <> include/vhex/device | add device structure (WIP) <> include/vhex/driver/mpu/sh/sh7305/ | [intc] add primitive which allow dummy default interrupt handler | [rtc] add complete RTC hardware structure | [rtc] add hardware-level kernel API <> include/vhex/fs | add file system abstraction API (WIP) | add Fugue FAT file system abstraction API (WIP) <> include/vhex/rtc | add RTC user-level API | add driver-level interface | add kernel-level types <> src/fs | add base Fugue abstraction (WIP) | add libc functions (WIP) @update <> include/vhex/display/draw/text | merge halign and valign argument | add special alignment flags <> include/vhex/driver | add RTC driver flags <> include/vhex/driver/mpu/sh/sh7305/cpg | rename weird field | add Spread Spectrum emulator field | properly expand LSTATS register <> src/driver/mpu/sh/sh7305 | [intc] allow user-level interrupt handler installation | [intc] expose common interrupt handler | [rtc] add RTC entire driver <> src/driver/scree/r61524 | use complete VRAM instead of fragmented render @fix <> src/display | [text] fix height for text display geometry | [text] fix alignment calculation | [dclear] fix geometry support <> src/driver/mpu/sh/sh7305 | [cpg] fix driver installation | [cpg] fix driver spread spectrum | [cpg] fix driver declaration | [tmu] fix exception with the profiling primitives
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;
uint8_t :1;
uint8_t :1;
uint8_t SHARED :1;
uint8_t UNUSED :1;
);
/* module related-internal data */
void *module_data;
};
/* 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__ */