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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [zipos/] [syspipe.h] - Blame information for rev 33

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

Line No. Rev Author Line
1 22 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    syspipe.h
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7
// Purpose:     This "device" handles the primary device level interaction of
8
//              almost all devices on the ZipOS: the pipe.  A pipe, as defined
9
//      here, is an O/S supported FIFO.  Information written to the FIFO will
10
//      be read from the FIFO in the order it was received.  Attempts to read
11
//      from an empty FIFO, or equivalently to write to a full FIFO, will block
12
//      the reading (writing) process until memory is available.
13
//
14
//      In general, each PIPE has three interface functions for reading and
15
//      another three for writing, together with one for creating an empty pipe.
16
//      The read functions are:
17
//
18
//              kpop_syspipe
19
//                      Attempts to read one value from the pipe in an interrupt
20
//                      context.  It is not allowed to fail.  An empty pipe
21
//                      simply becomes a return value of '1'.
22
//
23
//              kread_syspipe
24
//                      This is where the user trap read() ends up.  When a user
25
//                      tries to read from a pipe, kread_syspipe checks that the
26
//                      users request is valid, then transfers control to a
27
//                      user task level (interrupts enabled) read function.
28
//
29
//              uread_syspipe
30
//                      The user read task.  This task is invoked from the user
31
//                      trap, calling kread_syspipe at the kernel mode, which
32
//                      then transitions the read to user mode using
33
//                      uread_syspipe.
34
//
35
//      Writing has it's analogous functions:
36
//              kpush_syspipe
37
//                      Attempts to write a value from an interrupt context
38
//                      to the pipe.  Primarily used when reading from a 
39
//                      UART driven device.
40
//              kwrite_syspipe
41
//              uwrite_syspipie
42
//
43
//
44
// Creator:     Dan Gisselquist, Ph.D.
45
//              Gisselquist Technology, LLC
46
//
47
////////////////////////////////////////////////////////////////////////////////
48
//
49
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
50
//
51
// This program is free software (firmware): you can redistribute it and/or
52
// modify it under the terms of  the GNU General Public License as published
53
// by the Free Software Foundation, either version 3 of the License, or (at
54
// your option) any later version.
55
//
56
// This program is distributed in the hope that it will be useful, but WITHOUT
57
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
58
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
59
// for more details.
60
//
61
// You should have received a copy of the GNU General Public License along
62
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
63
// target there if the PDF file isn't present.)  If not, see
64
// <http://www.gnu.org/licenses/> for a copy.
65
//
66
// License:     GPL, v3, as defined and found on www.gnu.org,
67
//              http://www.gnu.org/licenses/gpl.html
68
//
69
//
70
////////////////////////////////////////////////////////////////////////////////
71
//
72
//
73
#ifndef SYSPIPE_H
74
#define SYSPIPE_H
75
 
76
extern  void *sys_malloc(int sz);
77
 
78
typedef struct {
79
        unsigned int    m_mask;
80
        int             m_head, m_tail;
81
volatile TASKP          m_rdtask, m_wrtask;
82
        unsigned int    m_nread, m_nwritten;
83 27 dgisselq
        int     dummy;
84 22 dgisselq
        int             m_error;
85
 
86
        int             m_buf[1];
87
} SYSPIPE;
88
 
89
SYSPIPE *new_syspipe(const unsigned int len);
90
extern  void    kread_syspipe( TASKP tsk, int dev, int *dst, int len);
91
extern  void    kwrite_syspipe(TASKP tsk, int dev, int *src, int len);
92
void    kpush_syspipe(SYSPIPE *p, int val);
93
int     kpop_syspipe(SYSPIPE *p, int *val);
94
extern  int     num_avail_syspipe(SYSPIPE *p);
95
extern  int     len_syspipe(SYSPIPE *p);
96
 
97
#define INTERRUPT_READ_TASK     ((TASKP)((unsigned)-1))
98
// #define      INTERRUPT_WRITE_TASK    ((TASKP)((unsigned)-1))
99
 
100
#endif

powered by: WebSVN 2.1.0

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