OpenCores
URL https://opencores.org/ocsvn/s6soc/s6soc/trunk

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [zipos/] [taskp.c] - Blame information for rev 22

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    taskp.c
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7
// Purpose:     Implements the new_task function to create a new task, as well
8
//              as the idle_task's entry function and body.
9
//
10
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12
//
13
////////////////////////////////////////////////////////////////////////////////
14
//
15
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
16
//
17
// This program is free software (firmware): you can redistribute it and/or
18
// modify it under the terms of  the GNU General Public License as published
19
// by the Free Software Foundation, either version 3 of the License, or (at
20
// your option) any later version.
21
//
22
// This program is distributed in the hope that it will be useful, but WITHOUT
23
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
// for more details.
26
//
27
// You should have received a copy of the GNU General Public License along
28
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
29
// target there if the PDF file isn't present.)  If not, see
30
// <http://www.gnu.org/licenses/> for a copy.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
//
38
//
39
#include "ksched.h"
40
#include "kfildes.h"
41
#include "taskp.h"
42
 
43
extern  void *sys_malloc(int sz);
44
TASKP   new_task(unsigned ln, VENTRYP entry) {
45
        int     i;
46
        TASKP   tsk = (TASKP)sys_malloc(sizeof(struct TASK_S)+ln);
47
 
48
        for(i=0; (unsigned)i<sizeof(struct TASK_S)+ln; i++)
49
                ((unsigned int *)tsk)[i] = 0;
50
        tsk->context[ 0] = (int)((long)(int *)idle_task);
51
        tsk->context[12] = (int)&tsk->user_data[ln]; // Set the stack pointer
52
        tsk->context[13] = (int)&tsk->user_data[ln]; // Set the stack pointer
53
        tsk->context[14] = 0x20; // GIE bit only
54
        tsk->context[15] = (int)((long)(int *)entry);
55
        tsk->user_heap   = &tsk->user_data[0];
56
        tsk->state = SCHED_READY;
57
 
58
        return tsk;
59
}
60
 
61
// 
62
// zip_idle is really an assembly language builtin.  It translates into the
63
// WAIT (i.e. for interrupt) instruction.  Even this, though, is a derived
64
// instruction.  More specifically, the WAIT instruction OR's a constant
65
// to the CC register.
66
//
67
extern void zip_idle(void);
68
void    idle_task(void) {
69
        do {
70
                zip_idle();
71
        } while(1);
72
}
73
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.