source: mainline/kernel/arch/sparc64/include/drivers/sgcn.h@ 86018c1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 86018c1 was a71c158, checked in by Martin Decky <martin@…>, 16 years ago

kernel output devices now suport multiple instances (except ski and sgcn, which respect the same interface, but behave as singletons)
if more than one output device gets initialized, the output is cloned to all of them
get rid of arch_grab_console() and arch_release_console() (output devices can implement a generic "redraw" method, input devices respect the "silent" global variable)
related cleanups and modifications

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 * Copyright (c) 2008 Pavel Rimsky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup sparc64
30 * @{
31 */
32/** @file
33 */
34
35#ifndef KERN_sparc64_SGCN_H_
36#define KERN_sparc64_SGCN_H_
37
38#include <arch/types.h>
39#include <console/chardev.h>
40#include <proc/thread.h>
41#include <synch/spinlock.h>
42
43/* number of bytes in the TOC magic, including the NULL-terminator */
44#define TOC_MAGIC_BYTES 8
45
46/* number of bytes in the TOC key, including the NULL-terminator */
47#define TOC_KEY_SIZE 8
48
49/* maximum number of entries in the SRAM table of contents */
50#define MAX_TOC_ENTRIES 32
51
52/* number of bytes in the SGCN buffer magic, including the NULL-terminator */
53#define SGCN_MAGIC_BYTES 4
54
55/**
56 * Entry in the SRAM table of contents. Describes one segment of the SRAM
57 * which serves a particular purpose (e.g. OBP serial console, Solaris serial
58 * console, Solaris mailbox,...).
59 */
60typedef struct {
61 /** key (e.g. "OBPCONS", "SOLCONS", "SOLMBOX",...) */
62 char key[TOC_KEY_SIZE];
63
64 /** size of the segment in bytes */
65 uint32_t size;
66
67 /** offset of the segment within SRAM */
68 uint32_t offset;
69} __attribute ((packed)) toc_entry_t;
70
71/**
72 * SRAM table of contents. Describes all segments within the SRAM.
73 */
74typedef struct {
75 /** hard-wired to "TOCSRAM" */
76 char magic[TOC_MAGIC_BYTES];
77
78 /** we don't need this */
79 char unused[8];
80
81 /** TOC entries */
82 toc_entry_t keys[MAX_TOC_ENTRIES];
83} __attribute__ ((packed)) iosram_toc_t;
84
85/**
86 * SGCN buffer header. It is placed at the very beginning of the SGCN
87 * buffer.
88 */
89typedef struct {
90 /** hard-wired to "CON" */
91 char magic[SGCN_MAGIC_BYTES];
92
93 /** we don't need this */
94 char unused[8];
95
96 /** offset within the SGCN buffer of the input buffer start */
97 uint32_t in_begin;
98
99 /** offset within the SGCN buffer of the input buffer end */
100 uint32_t in_end;
101
102 /** offset within the SGCN buffer of the input buffer read pointer */
103 uint32_t in_rdptr;
104
105 /** offset within the SGCN buffer of the input buffer write pointer */
106 uint32_t in_wrptr;
107
108 /** offset within the SGCN buffer of the output buffer start */
109 uint32_t out_begin;
110
111 /** offset within the SGCN buffer of the output buffer end */
112 uint32_t out_end;
113
114 /** offset within the SGCN buffer of the output buffer read pointer */
115 uint32_t out_rdptr;
116
117 /** offset within the SGCN buffer of the output buffer write pointer */
118 uint32_t out_wrptr;
119} __attribute__ ((packed)) sgcn_buffer_header_t;
120
121typedef struct {
122 /** Starting address of SRAM */
123 uintptr_t sram_begin;
124
125 /** Starting address of the SGCN buffer */
126 uintptr_t buffer_begin;
127
128 /**
129 * Ensure that writing to the buffer and consequent
130 * update of the write pointer are one atomic operation.
131 */
132 SPINLOCK_DECLARE(output_lock);
133
134 /**
135 * Prevent the input buffer read/write pointers from
136 * getting to inconsistent state.
137 */
138 SPINLOCK_DECLARE(input_lock);
139
140 thread_t *thread;
141 indev_t *srlnin;
142} sgcn_instance_t;
143
144extern sgcn_instance_t *sgcnin_init(void);
145extern void sgcnin_wire(sgcn_instance_t *, indev_t *);
146extern outdev_t *sgcnout_init(void);
147
148#endif
149
150/** @}
151 */
Note: See TracBrowser for help on using the repository browser.