Deleted Added
full compact
scvesactl.c (39287) scvesactl.c (39591)
1/*-
2 * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
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 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior written
15 * permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
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 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior written
15 * permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $Id$
29 * $Id: scvesactl.c,v 1.1 1998/09/15 18:16:37 sos Exp $
30 */
31
32#include "sc.h"
33#include "opt_vesa.h"
34#include "opt_vm86.h"
35
36#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE)
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/tty.h>
41#include <sys/kernel.h>
42
43#include <machine/apm_bios.h>
44#include <machine/console.h>
45#include <machine/pc/vesa.h>
46
47#include <i386/isa/videoio.h>
48#include <i386/isa/syscons.h>
49
50static int (*prev_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
51 struct proc *p);
52
30 */
31
32#include "sc.h"
33#include "opt_vesa.h"
34#include "opt_vm86.h"
35
36#if (NSC > 0 && defined(VESA) && defined(VM86)) || defined(VESA_MODULE)
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/tty.h>
41#include <sys/kernel.h>
42
43#include <machine/apm_bios.h>
44#include <machine/console.h>
45#include <machine/pc/vesa.h>
46
47#include <i386/isa/videoio.h>
48#include <i386/isa/syscons.h>
49
50static int (*prev_user_ioctl)(dev_t dev, int cmd, caddr_t data, int flag,
51 struct proc *p);
52
53extern struct tty *scdevtotty(dev_t dev);
53/* external functions */
54struct tty *scdevtotty(dev_t dev);
54
55
56/* functions in this module */
57int vesa_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
58
55int
56vesa_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
57{
58 scr_stat *scp;
59 struct tty *tp;
60 video_info_t info;
61 video_adapter_t *adp;
62 int mode;
63 int error;
64 int s;
65
66 tp = scdevtotty(dev);
67 if (!tp)
68 return ENXIO;
69 scp = sc_get_scr_stat(tp->t_dev);
70
71 switch (cmd) {
72 case SW_VESA_USER:
73
74 mode = (int)data;
75 if ((*biosvidsw.get_info)(scp->adp, mode, &info))
76 return ENODEV;
77 if (info.vi_flags & V_INFO_GRAPHICS)
78 goto vesa_graphics;
79 else
80 goto vesa_text;
81
59int
60vesa_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
61{
62 scr_stat *scp;
63 struct tty *tp;
64 video_info_t info;
65 video_adapter_t *adp;
66 int mode;
67 int error;
68 int s;
69
70 tp = scdevtotty(dev);
71 if (!tp)
72 return ENXIO;
73 scp = sc_get_scr_stat(tp->t_dev);
74
75 switch (cmd) {
76 case SW_VESA_USER:
77
78 mode = (int)data;
79 if ((*biosvidsw.get_info)(scp->adp, mode, &info))
80 return ENODEV;
81 if (info.vi_flags & V_INFO_GRAPHICS)
82 goto vesa_graphics;
83 else
84 goto vesa_text;
85
86 /* generic text modes */
87 case SW_TEXT_132x25: case SW_TEXT_132x30:
88 case SW_TEXT_132x43: case SW_TEXT_132x50:
89 case SW_TEXT_132x60:
90 adp = get_adapter(scp);
91 if (!(adp->va_flags & V_ADP_MODECHANGE))
92 return ENODEV;
93 return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0);
94
82 /* text modes */
83 case SW_VESA_C80x60:
84 case SW_VESA_C132x25:
85 case SW_VESA_C132x43:
86 case SW_VESA_C132x50:
87 case SW_VESA_C132x60:
88 adp = get_adapter(scp);
89 if (!(adp->va_flags & V_ADP_MODECHANGE))
90 return ENODEV;
91 mode = (cmd & 0xff) + M_VESA_BASE;
92vesa_text:
93 return sc_set_text_mode(scp, tp, mode, 0, 0, 0);
94
95 /* graphics modes */
96 case SW_VESA_32K_320: case SW_VESA_64K_320:
97 case SW_VESA_FULL_320:
98
99 case SW_VESA_CG640x400:
100
101 case SW_VESA_CG640x480:
102 case SW_VESA_32K_640: case SW_VESA_64K_640:
103 case SW_VESA_FULL_640:
104
105 case SW_VESA_800x600: case SW_VESA_CG800x600:
106 case SW_VESA_32K_800: case SW_VESA_64K_800:
107 case SW_VESA_FULL_800:
108
109 case SW_VESA_1024x768: case SW_VESA_CG1024x768:
110 case SW_VESA_32K_1024: case SW_VESA_64K_1024:
111 case SW_VESA_FULL_1024:
112
113 case SW_VESA_1280x1024: case SW_VESA_CG1280x1024:
114 case SW_VESA_32K_1280: case SW_VESA_64K_1280:
115 case SW_VESA_FULL_1280:
116 adp = get_adapter(scp);
117 if (!(adp->va_flags & V_ADP_MODECHANGE))
118 return ENODEV;
119 mode = (cmd & 0xff) + M_VESA_BASE;
120vesa_graphics:
121 return sc_set_graphics_mode(scp, tp, mode);
122 }
123
124 if (prev_user_ioctl)
125 return (*prev_user_ioctl)(dev, cmd, data, flag, p);
126 else
127 return ENOIOCTL;
128}
129
130int
131vesa_load_ioctl(void)
132{
133 if (prev_user_ioctl)
134 return EBUSY;
135 prev_user_ioctl = sc_user_ioctl;
136 sc_user_ioctl = vesa_ioctl;
137 return 0;
138}
139
140int
141vesa_unload_ioctl(void)
142{
143 if (sc_user_ioctl != vesa_ioctl)
144 return EBUSY;
145 sc_user_ioctl = prev_user_ioctl;
146 prev_user_ioctl = NULL;
147 return 0;
148}
149
150#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */
95 /* text modes */
96 case SW_VESA_C80x60:
97 case SW_VESA_C132x25:
98 case SW_VESA_C132x43:
99 case SW_VESA_C132x50:
100 case SW_VESA_C132x60:
101 adp = get_adapter(scp);
102 if (!(adp->va_flags & V_ADP_MODECHANGE))
103 return ENODEV;
104 mode = (cmd & 0xff) + M_VESA_BASE;
105vesa_text:
106 return sc_set_text_mode(scp, tp, mode, 0, 0, 0);
107
108 /* graphics modes */
109 case SW_VESA_32K_320: case SW_VESA_64K_320:
110 case SW_VESA_FULL_320:
111
112 case SW_VESA_CG640x400:
113
114 case SW_VESA_CG640x480:
115 case SW_VESA_32K_640: case SW_VESA_64K_640:
116 case SW_VESA_FULL_640:
117
118 case SW_VESA_800x600: case SW_VESA_CG800x600:
119 case SW_VESA_32K_800: case SW_VESA_64K_800:
120 case SW_VESA_FULL_800:
121
122 case SW_VESA_1024x768: case SW_VESA_CG1024x768:
123 case SW_VESA_32K_1024: case SW_VESA_64K_1024:
124 case SW_VESA_FULL_1024:
125
126 case SW_VESA_1280x1024: case SW_VESA_CG1280x1024:
127 case SW_VESA_32K_1280: case SW_VESA_64K_1280:
128 case SW_VESA_FULL_1280:
129 adp = get_adapter(scp);
130 if (!(adp->va_flags & V_ADP_MODECHANGE))
131 return ENODEV;
132 mode = (cmd & 0xff) + M_VESA_BASE;
133vesa_graphics:
134 return sc_set_graphics_mode(scp, tp, mode);
135 }
136
137 if (prev_user_ioctl)
138 return (*prev_user_ioctl)(dev, cmd, data, flag, p);
139 else
140 return ENOIOCTL;
141}
142
143int
144vesa_load_ioctl(void)
145{
146 if (prev_user_ioctl)
147 return EBUSY;
148 prev_user_ioctl = sc_user_ioctl;
149 sc_user_ioctl = vesa_ioctl;
150 return 0;
151}
152
153int
154vesa_unload_ioctl(void)
155{
156 if (sc_user_ioctl != vesa_ioctl)
157 return EBUSY;
158 sc_user_ioctl = prev_user_ioctl;
159 prev_user_ioctl = NULL;
160 return 0;
161}
162
163#endif /* (NSC > 0 && VESA && VM86) || VESA_MODULE */