gwsystems / gwsystems/composite

New user-level library design for embedded MCUs

Open
#369 0 comments 0 reactions 1 assignee View on GitHub

@hungry-foolish is already working on this.

Since Aug 13, 2018.

P-medium
Dominant language
C
Stars
202
Forks
72
Avg merge
2h 54m
Merged PRs (30d)
1

Description

We need a new user-level library design for embedded MCUs. We probably need a custom header as well, for the following reasons:

  • Most MCU applications are statically compiled and statically linked.
  • Most MCU applications require a small size and thus prohibits complex abstraction levels. This may require a new cos_kernel_api without serious abstractions, preferably only inline functions.
  • Most MCU applications do not share the same library with PC-based applications, or require their own versions.
  • Some MCUs have their own libraries that are possibly not compatible with our current system setup.

A suggested header for the MCU applications(especially RTOS VM images):
The structure to pass hypercall parameters to/from the VMM if we use shared memory to pass parameters. We can use synchronous invocation to pass parameters as well.

struct vmm_param
{
    unsigned long number;
    unsigned long param[4];
};

The page table layout is statically decided, the first one being the top-level. This is architecture-specific.

struct pgtbl_hdr
{
    /* Its parent's position in the page table array */
    unsigned long parent;
    /* The start address of the mapping <also contains where to cons it into> */
    unsigned long addr;
    /* The size order and number order, combined into one word */
    unsigned long order;
    /* The initially mapped pages' data. The only thing stored here is the Composite standard flags */
    unsigned char flags[8];
};

The VM image header structure

struct vm_image
{
    /* The magic number;always equal to VIRT(0x56495254) */
    const unsigned long magic;
    /* Name of the VM */
    char name[16];

    /* The entry, stack and stack size of the virtual machines */
    void* user_entry;
    /* The stack of this VM */
    void* user_stack;
    /* The size of the user stack */
    unsigned long user_size;
    /* The entry of the interrupt processing thread */
    void* int_entry;
    /* The stack of the interrupt processing thread */
    void* int_stack;
    unsigned long int_size;
    
    /* SHARED:The parameter space <if we use shared memory to pass parameters> */
    struct vm_param* param;
    
    /* The priority and timeslices of the VM - used in prioity RR scheduling */
    unsigned long prio;
    unsigned long slices;
    
    /* SHARED:The console space and size - if you wish to print something */
    unsigned long console_size;
    void* console_buf;
    
    /* SHARED:The interrupt flag space  - To mark an interrupt so that the VM can process it */
    unsigned long int_num;
    unsigned long* int_flags;

    /* The number of page tables in this image, and where are they stored */
    unsigned long pgtbl_num;
    const struct pgtbl_hdr* pgtbl;
    
    /* The number of kernel capabilities in this image, and their list, which depicts what hardware this VM have access to */
    unsigned long hwcap_num;
    const unsigned long* hwcap;

    /* Is there any other images? If there is, here is a pointer to the start
     * of the next one. This is a constant pointer to a constant pointer to a 
     * constant structure. The VMM will load the next image from here, if it wants to. */
    const struct vm_image* const * const next_image;
};

@gparmer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.