[CORE] Don't include vmm_chardev.h in vmm_heap.h

The vmm_heap.h is included at large number of places. Any header
included in vmm_heap.h will be indirectly included at number of
places.

To force explicit include of vmm_chardev.h we remove it from
vmm_heap.h

Also, we do minor consmetic changes in vmm_heap_print_state().

Signed-off-by: Anup Patel <anup@brainfault.org>
[EMULATORS] Fix compile error in PCI emulation framework

The PCI emulation framework header does not include appropriate
header which are required by structures and function prototypes
defined in this header.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Use buddy allocator to manage VAPOOL

Currently, we use bitmap to manage VAPOOl hence we have following
runtime complexities:
VAPOOL alloc: O(n)
VAPOOL reserve: O(1)
VAPOOL free: O(1)

From above it is clear the VAPOOL allocations are slower because
of bitmap usage.

This patch introduces use of buddy allocator to manage VAPOOL
and updated runtime complexities are:
VAPOOL alloc: O(log n)
VAPOOL reserve: O(log n)
VAPOOL free: O(log n)

The patch also does few simplifications to vmm_host_aspace_init().

Signed-off-by: Anup Patel <anup@brainfault.org>
[COMMANDS] Add "host vapool state" command

We use buddy allocator to manage VAPOOL hence this patch introduce
"host vapool state" command to dump state of VAPOOL buddy allocator.

We also do few other cosmetic changes to host command such as:
1. Rename "host vapool stats" to "host vapool info"
2. Rename "host ram stats" to "host ram info"

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Add dma_mask to vmm_device

This patch adds the dma_mask to device structure which will help
driver porting, as most of the devices have inbuild dma.

Signed-off-by: Ankit Jindal <thatsjindal@gmail.com>
[DRIVERS] Add linux/dma_mapping.h for driver porting

Signed-off-by: Ankit Jindal <thatsjindal@gmail.com>
[CORE] Very crucial bug fix in vmm_host_memory_read()

We should be only reading one page at a time in vmm_host_memory_read().

Currently, if arch provides arch_cpu_aspace_memory_read() then function
vmm_host_memory_read() passes complete "len" of data to be read to
arch_cpu_aspace_memory_read() which is totally wrong instead we should
only read "page_read" bytes in each call to arch_cpu_aspace_memory_read().

This patch fixes above described issue in vmm_host_memory_read().

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_devemu: Add more debug prints for read/write emulation

We should more verbose about failure cases in memory read/write and io
read/write emulation hence this patch adds few debug prints for failure
in vmm_devemu_emulate_read/write() and vmm_devemu_emulate_ioread/iowrite().

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] vmm_devdrv: Remove few redundant APIs

This patch does minor simplification to vmm_devdrv API by removing
few API such as vmm_devdrv_class_register/unregister_device() and
and vmm_devdrv_bus_register/unregister_device() from vmm_devdrv.h

This means that now we use vmm_devdrv_register/unregister_device()
APIs to support bus/class level device registration.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Add vmm_host_vapool_find() API

This patch adds vmm_host_vapool_find() API.

This new API can be used to findout alloced/reserved
virtual space under which given virtual address falls.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Distinguish behaviour of vmm_host_memunmap() and vmm_host_free_pages()

The vmm_host_memunmap() as-per semantics should free entire alloced/reserved
virtual space whereas vmm_host_free_pages() should only free selected portion
of virtual space.

This patch does minor cosmetic changes to both this APIs so that this meaning
or semantics can be easily inferred from code.

Signed-off-by: Anup Patel <anup@brainfault.org>
[CORE] Simplify vmm_host_memunmap() and vmm_host_iounmap() APIs

Generally in unix-like OSes (such as Linux, Free BSD, Net BSD, etc.)
the memory/io unmap functions don't require size parameter. It is
also a bit odd/non-standard to expect size parameter in these functions.

This patch removes the need of size parameter in vmm_host_memunmap()
and vmm_host_iounmap() APIs.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] arm32: Setup 4KB pages at boot-time instead of 1MB pages

Currently, we create section entries (1MB pages) at boot-time. This
puts constraint that exection start/end (i.e. code start/end) address
have to be 1MB aligned causing waste of memory. Further, arch reserved
area (i.e. L1/L2 ttbl pools) is also 1MB aligned to simplify the
arch_cpu_aspace_primary_init() function but this also leads to waste
of memory in arch reserved area.

This patch updates boot-time code to create 4KB pages instead of 1MB
pages and also removes 1MB alignment restriction in execution start/end
and arch reserved area.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] Allow defterm early prints for arm32 port

The updated boot-time page table setup is capable of mapping
defterm early base hence allow defterm early prints for arm32.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] PSCI: Add PSCI support for SMP operations

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
[CORE] Add __noinline attribute for functions

An attribute to avoid GCC inlining static functions can be very
handy for arch specific code hence this patch adds __noinline
fuction attribute for this purpose.

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] PSCI: improve inline assembly code for smc #0 service call.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
[ARM] Enabled PSCI SMP operations in defconfigs

All ARMv7, ARMv7ve and ARMv8 boards can potentially use PSCI based
SMP operations hence enable it in appropriate defconfigs.

Signed-off-by: Anup Patel <anup@brainfault.org>
[LIBS] Support more types of MEMPOOLs

This patch makes MEMPOOL APIs more flexible to support three
types of MEMPOOLs:
1. RAW  - Pool of fixed sized entities over RAW/Device memory such as SRAM
2. RAM  - Pool of fixed sized entities over RAM pages
3. HEAP - Pool of fixed sized entities over Heap

The patch also adds following new MEMPOOL APIs:
mempool_raw_create()
mempool_ram_create()
mempool_heap_create()
mempool_check_ptr()
mempool_get_type()
mempool_total_entities()
mempool_free_entities()

Signed-off-by: Anup Patel <anup@brainfault.org>
[ARM] Add Cortex A7 support

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>