Specifications

Chapter 1: Using the NicheStack TCP/IP Stack 1–23
Important NicheStack TCP/IP Stack Concepts
June 2011 Altera Corporation Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial
In the Nios II Simple Socket Server design example, only the minimum required
NicheStack TCP/IP Stack tasks have been configured to run. These tasks are as
follows:
tk_netmain
—Initializes the stack, including networking interfaces
tk_nettick
—A time management task that the networking stack uses
For more information about these NicheStack TCP/IP Stack tasks, refer to “Task
Priorities in the Nios II Simple Socket Server Design” on page 1–25.
Creating Tasks that Use the NicheStack TCP/IP Stack Sockets Interface
You must use the function call
TK_NEWTASK
to create any tasks that use the NicheStack
networking services. You must create tasks that do not use networking services with
the MicroC/OS-II function
OSTaskCreate()
.
The NicheStack Networking Stack uses the
TK_NEWTASK
(defined in osportco.c)
function to launch MicroC/OS-II tasks that use the networking services.
TK_NEWTASK
accepts a single argument,
struct inet_taskinfo * nettask
(defined in osport.h),
which specifies the task name, the MicroC/OS-II thread priority, and the stack size.
You can locate these files in the <Nios II EDS install path>/components/
altera_iniche/UCOSII/src/nios2 directory. The
struct inet_taskinfo
structure is
defined as follows:
struct inet_taskinfo {
TK_OBJECT_PTR(tk_ptr)
;/* pointer to static task object */
char * name;
/* name of task */
TK_ENTRY_PTR(entry);
/* pointer to code that starts task*/
int priority;
/* MicroC/OS-II priority of the task */
int stacksize;
/* size (bytes) of task’s stack */
char* stackbase;
/* base of task’s stack */
};
For every networking task you create in your application, you must declare a local
struct inet_taskinfo
structure with the elements defined. These elements are listed
in the following bullets, along with a brief explanation of their function:
TK_OBJECT_PTR(tk_ptr)
—A pointer to a static task object, defined for a given task
via the
TK_OBJECT
macro. The NicheStack Networking Stack makes use of the
tk_ptr
element during the operation. After declaring the variable name via the
TK_OBJECT
and populating the
TK_OBJECT_PTR(tk_ptr)
, you do not need to do
anything more.
char * name
—This element contains a character string that corresponds to the
name of the task. You can set it with any character string you choose.
TK_ENTRY_PTR(entry)
—This element corresponds to the entry point or defined
function name of the task that you want to run.
int priority
—The MicroC/OS-II priority level for the task.
int stacksize
—The MicroC/OS-II stack size for the task.
char* stackbase
—This element in the structure is used by the NicheStack
software. You must not change the element in the structure.