]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/octeon-sdk/octeon-pci-console.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / octeon-sdk / octeon-pci-console.h
1 /***********************license start***************
2  * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights
3  * reserved.
4  *
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *   * Redistributions of source code must retain the above copyright
11  *     notice, this list of conditions and the following disclaimer.
12  *
13  *   * Redistributions in binary form must reproduce the above
14  *     copyright notice, this list of conditions and the following
15  *     disclaimer in the documentation and/or other materials provided
16  *     with the distribution.
17
18  *   * Neither the name of Cavium Inc. nor the names of
19  *     its contributors may be used to endorse or promote products
20  *     derived from this software without specific prior written
21  *     permission.
22
23  * This Software, including technical data, may be subject to U.S. export  control
24  * laws, including the U.S. Export Administration Act and its  associated
25  * regulations, and may be subject to export or import  regulations in other
26  * countries.
27
28  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38  ***********************license end**************************************/
39
40
41
42
43
44
45
46
47 #ifndef __OCTEON_PCI_CONSOLE_H__
48 #define __OCTEON_PCI_CONSOLE_H__
49
50 #ifndef CVMX_BUILD_FOR_LINUX_KERNEL
51 #include "cvmx-platform.h"
52 #endif
53
54 /* Current versions */
55 #define OCTEON_PCI_CONSOLE_MAJOR_VERSION    1
56 #define OCTEON_PCI_CONSOLE_MINOR_VERSION    0
57
58 #define OCTEON_PCI_CONSOLE_BLOCK_NAME   "__pci_console"
59
60
61 /* Structure that defines a single console.
62
63
64 * Note: when read_index == write_index, the buffer is empty.  The actual usable size
65 *       of each console is console_buf_size -1;
66 */
67 typedef struct {
68     uint64_t input_base_addr;
69     uint32_t input_read_index;
70     uint32_t input_write_index;
71     uint64_t output_base_addr;
72     uint32_t output_read_index;
73     uint32_t output_write_index;
74     uint32_t lock;
75     uint32_t buf_size;
76 } octeon_pci_console_t;
77
78
79 /* This is the main container structure that contains all the information
80 about all PCI consoles.  The address of this structure is passed to various
81 routines that operation on PCI consoles.
82 */
83 typedef struct {
84     uint32_t major_version;
85     uint32_t minor_version;
86     uint32_t lock;
87     uint32_t flags;
88     uint32_t num_consoles;
89     uint32_t pad;
90     /* must be 64 bit aligned here... */
91     uint64_t console_addr_array[0];  /* Array of addresses of octeon_pci_console_t structures */
92     /* Implicit storage for console_addr_array */
93 } octeon_pci_console_desc_t;
94
95
96 /* Flag definitions for octeon_pci_console_desc_t */
97 enum {
98     OCT_PCI_CON_DESC_FLAG_PERCPU = 1 << 0,  /* If set, output from core N will be sent to console N */
99 };
100
101 #if defined(OCTEON_TARGET) && !defined(__linux__)
102 /**
103  * This is an internal-only function that is called from within the simple executive
104  * C library, and is not intended for any other use.
105  *
106  * @param fd
107  * @param buf
108  * @param nbytes
109  *
110  * @return
111  */
112 int  __cvmx_pci_console_write (int fd, char *buf, int nbytes);
113 #endif
114
115
116 #ifdef CVMX_BUILD_FOR_UBOOT
117 uint64_t octeon_pci_console_init(int num_consoles, int buffer_size);
118 #endif
119
120 /* Flag definitions for read/write functions */
121 enum {
122     OCT_PCI_CON_FLAG_NONBLOCK = 1 << 0,  /* If set, read/write functions won't block waiting for space or data.
123                                           * For reads, 0 bytes may be read, and for writes not all of the
124                                           * supplied data may be written.*/
125 };
126
127 #if !defined(__linux__) || defined(__KERNEL__)
128 int octeon_pci_console_write(uint64_t console_desc_addr, unsigned int console_num, const char * buffer, int bytes_to_write, uint32_t flags);
129 int octeon_pci_console_write_avail(uint64_t console_desc_addr, unsigned int console_num);
130
131 int octeon_pci_console_read(uint64_t console_desc_addr, unsigned int console_num, char * buffer, int buffer_size, uint32_t flags);
132 int octeon_pci_console_read_avail(uint64_t console_desc_addr, unsigned int console_num);
133 #endif
134
135 #if !defined(OCTEON_TARGET) && defined(__linux__) && !defined(__KERNEL__)
136 int octeon_pci_console_host_write(uint64_t console_desc_addr, unsigned int console_num, const char * buffer, int write_reqest_size, uint32_t flags);
137 int octeon_pci_console_host_write_avail(uint64_t console_desc_addr, unsigned int console_num);
138
139 int octeon_pci_console_host_read(uint64_t console_desc_addr, unsigned int console_num, char * buffer, int buf_size, uint32_t flags);
140 int octeon_pci_console_host_read_avail(uint64_t console_desc_addr, unsigned int console_num);
141 #endif
142 #endif