A little more progress toward the implementation of per-window framebuffers. Still missing:

- Logic that generates the low lever framebuffer renderers for the per-window framebuffers,
- The logic that picks off the per-window framebuffer updates from normal graphics device updates.  This logic must update both the per-window framebuffer and the graphics device (from the framebuffer).

Squashed commit of the following:

    graphics:  Add logic to allocate the per-window framebuffer.

    graphics:  A few fragmentary thoughts on how a per-window framebuffer could be represented and allocated.
This commit is contained in:
Gregory Nutt
2019-03-14 11:20:14 -06:00
parent 2f257cfd0a
commit 419c4cb6be
7 changed files with 216 additions and 32 deletions

View File

@@ -1,7 +1,7 @@
/****************************************************************************
* fs/mmap/fs_mmap.c
*
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2009, 2011, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,8 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include "inode/inode.h"
#include "fs_rammap.h"
@@ -92,7 +94,7 @@
* MAP_PRIVATE - Will cause an error
* MAP_FIXED - Will cause an error
* MAP_FILE - Ignored
* MAP_ANONYMOUS - Will cause an error
* MAP_ANONYMOUS - Optional
* MAP_ANON - Will cause an error
* MAP_GROWSDOWN - Ignored
* MAP_DENYWRITE - Will cause an error
@@ -125,6 +127,7 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
int fd, off_t offset)
{
FAR void *addr;
int errcode;
int ret;
/* Since only a tiny subset of mmap() functionality, we have to verify many
@@ -132,24 +135,60 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
*/
#ifdef CONFIG_DEBUG_FEATURES
/* Private mappings and protections are not currently supported. These
* options could be supported in the KERNEL build with an MMU, but that
* logic is not in place.
*/
if (prot == PROT_NONE ||
(flags & (MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS | MAP_DENYWRITE)) != 0)
(flags & (MAP_PRIVATE | MAP_FIXED | MAP_DENYWRITE)) != 0)
{
ferr("ERROR: Unsupported options, prot=%x flags=%04x\n", prot, flags);
set_errno(ENOSYS);
return MAP_FAILED;
errcode = ENOSYS;
goto errout;
}
/* A length of 0 is invalid. Currently only shared mappings are supported.
* Non-shared could be implemented in the KERNEL build with an MMU.
*/
if (length == 0 || (flags & MAP_SHARED) == 0)
{
ferr("ERROR: Invalid options, lengt=%d flags=%04x\n", length, flags);
set_errno(EINVAL);
return MAP_FAILED;
ferr("ERROR: Invalid options, length=%d flags=%04x\n", length, flags);
errcode = EINVAL;
goto errout;
}
#endif
/* Check if we are just be asked to allocate memory, i.e., MAP_ANONYMOUS
* set meaning that the memory is not backed up from a file. The file
* descriptor should be -1 (or refer to opened /dev/zero) in this case.
* The file descriptor is ignored in either case.
*/
if ((flags & MAP_ANONYMOUS) != 0)
{
FAR void *alloc;
/* REVISIT: Should reside outside of the heap. That is really the
* only purpose of MAP_ANONYMOUS: To get non-heap memory. In KERNEL
* build, this could be accomplished using pgalloc(), provided that
* you had logic in place to assign a virtual address to the mapping.
*/
alloc = kumm_zalloc(length);
if (alloc == NULL)
{
ferr("ERROR: kumm_alloc() failed: %d\n", ret);
errcode = ENOMEM;
goto errout;
}
return alloc;
}
/* Okay now we can assume a shared mapping from a file. This is the
* only option supported
* only other option supported
*
* Perform the ioctl to get the base address of the file in 'mapped'
* in memory. (casting to uintptr_t first eliminates complaints on some
@@ -160,9 +199,19 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
ret = ioctl(fd, FIOC_MMAP, (unsigned long)((uintptr_t)&addr));
if (ret < 0)
{
/* Not directly mappable, probably because the underlying media does
* not support random access.
*/
#ifdef CONFIG_FS_RAMMAP
/* Allocate memory and copy the file into memory. We would, of course,
* do much better in the KERNEL build using the MMU.
*/
return rammap(fd, length, offset);
#else
/* Error out. The errno value was already set by ioctl() */
ferr("ERROR: ioctl(FIOC_MMAP) failed: %d\n", get_errno());
return MAP_FAILED;
#endif
@@ -171,4 +220,8 @@ FAR void *mmap(FAR void *start, size_t length, int prot, int flags,
/* Return the offset address */
return (FAR void *)(((FAR uint8_t *)addr) + offset);
errout:
set_errno(errcode);
return MAP_FAILED;
}