pussuw commented on a change in pull request #5831: URL: https://github.com/apache/incubator-nuttx/pull/5831#discussion_r833218044
########## File path: arch/risc-v/src/common/riscv_addrenv_kstack.c ########## @@ -0,0 +1,109 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_addrenv_kstack.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <errno.h> +#include <assert.h> +#include <debug.h> + +#include <nuttx/sched.h> +#include <nuttx/kmalloc.h> +#include <nuttx/addrenv.h> +#include <nuttx/arch.h> + +#include "addrenv.h" + +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_addrenv_kstackalloc + * + * Description: + * This function is called when a new thread is created to allocate + * the new thread's kernel stack. This function may be called for certain + * terminating threads which have no kernel stack. It must be tolerant of + * that case. + * + * Input Parameters: + * tcb - The TCB of the thread that requires the kernel stack. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_kstackalloc(FAR struct tcb_s *tcb) +{ + DEBUGASSERT(tcb && tcb->xcp.kstack == 0); + + /* Allocate the kernel stack */ + + tcb->xcp.kstack = (uintptr_t *)kmm_memalign(8, ARCH_KERNEL_STACKSIZE); Review comment: Yes I'll change 8->STACK_ALIGNMENT. The 8B alignment is wrong anyway. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
