From 8b082a167b3c3f9961294d6ee7a9951270b13bfa Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 2 Sep 2014 08:29:44 -0600 Subject: [PATCH] Add SYSCALL support for pgalloc() --- include/nuttx/arch.h | 3 ++- include/sys/syscall.h | 27 +++++++++++++++++++-------- syscall/syscall.csv | 1 + syscall/syscall_lookup.h | 2 ++ syscall/syscall_stublookup.c | 1 + 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 2a27bf6d8d..aa70d81693 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -695,7 +695,8 @@ void up_allocate_pgheap(FAR void **heap_start, size_t *heap_size); * ****************************************************************************/ -#ifdef CONFIG_ARCH_ADDRENV +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && \ + defined(CONFIG_ARCH_USE_MMU) uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages); #endif diff --git a/include/sys/syscall.h b/include/sys/syscall.h index ffa50e4d25..13b1930454 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -90,19 +90,30 @@ #define SYS_sem_wait (CONFIG_SYS_RESERVED+20) #define SYS_set_errno (CONFIG_SYS_RESERVED+21) +/* Task creation APIs based on global entry points cannot be use with + * address environments. + */ + #ifndef CONFIG_ARCH_ADDRENV # define SYS_task_create (CONFIG_SYS_RESERVED+22) -# define SYS_task_delete (CONFIG_SYS_RESERVED+23) -# define SYS_task_restart (CONFIG_SYS_RESERVED+24) -# define SYS_up_assert (CONFIG_SYS_RESERVED+25) -# define __SYS_vfork (CONFIG_SYS_RESERVED+26) +# define __SYS_task_delete (CONFIG_SYS_RESERVED+23) + +/* pgalloc() is only available with address environments with the page + * allocator selected. MMU support from the CPU is also required. + */ + +#elif defined(CONFIG_MM_PGALLOC) && defined(CONFIG_ARCH_USE_MMU) +# define SYS_pgalloc (CONFIG_SYS_RESERVED+22) +# define __SYS_task_delete (CONFIG_SYS_RESERVED+23) #else -# define SYS_task_delete (CONFIG_SYS_RESERVED+22) -# define SYS_task_restart (CONFIG_SYS_RESERVED+23) -# define SYS_up_assert (CONFIG_SYS_RESERVED+24) -# define __SYS_vfork (CONFIG_SYS_RESERVED+25) +# define __SYS_task_delete (CONFIG_SYS_RESERVED+22) #endif +# define SYS_task_delete __SYS_task_delete +# define SYS_task_restart (__SYS_task_delete+1) +# define SYS_up_assert (__SYS_task_delete+2) +# define __SYS_vfork (__SYS_task_delete+3) + /* The following can be individually enabled */ #ifdef CONFIG_ARCH_HAVE_VFORK diff --git a/syscall/syscall.csv b/syscall/syscall.csv index 3c734d2d74..823a8ac75d 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -43,6 +43,7 @@ "nanosleep","time.h","!defined(CONFIG_DISABLE_SIGNALS)","int","FAR const struct timespec *", "FAR struct timespec*" "open","fcntl.h","CONFIG_NFILE_DESCRIPTORS > 0","int","const char*","int","..." "opendir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR DIR*","FAR const char*" +"pgalloc", "nuttx/arch.h", "defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && defined(CONFIG_ARCH_USE_MMU)", "uintptr_t", "uintptr_t", "unsigned int" "pipe","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0","int","int [2]|int*" "poll","poll.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","FAR struct pollfd*","nfds_t","int" "prctl","sys/prctl.h", "CONFIG_TASK_NAME_SIZE > 0","int","int","..." diff --git a/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index c3284187c5..cdf177b307 100644 --- a/syscall/syscall_lookup.h +++ b/syscall/syscall_lookup.h @@ -67,6 +67,8 @@ SYSCALL_LOOKUP(sem_wait, 1, STUB_sem_wait) SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno) #ifndef CONFIG_ARCH_ADDRENV SYSCALL_LOOKUP(task_create, 5, STUB_task_create) +#elif defined(CONFIG_MM_PGALLOC) && defined(CONFIG_ARCH_USE_MMU) +SYSCALL_LOOKUP(pgalloc, 2, STUB_pgalloc) #endif SYSCALL_LOOKUP(task_delete, 1, STUB_task_delete) SYSCALL_LOOKUP(task_restart, 1, STUB_task_restart) diff --git a/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index e8ea0782e0..bcd1772f72 100644 --- a/syscall/syscall_stublookup.c +++ b/syscall/syscall_stublookup.c @@ -85,6 +85,7 @@ uintptr_t STUB_sem_trywait(int nbr, uintptr_t parm1); uintptr_t STUB_sem_unlink(int nbr, uintptr_t parm1); uintptr_t STUB_sem_wait(int nbr, uintptr_t parm1); uintptr_t STUB_set_errno(int nbr, uintptr_t parm1); +uintptr_t STUB_pgalloc(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_task_create(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, uintptr_t parm4, uintptr_t parm5); uintptr_t STUB_task_delete(int nbr, uintptr_t parm1);