xref: /freebsd/lib/libsys/i386/i386_clr_watch.c (revision 4bc66c0f9f2c349af86cbf4e77f000b49d819fea)
1*4bc66c0fSBrooks Davis /*-
2*4bc66c0fSBrooks Davis  * SPDX-License-Identifier: BSD-2-Clause
3*4bc66c0fSBrooks Davis  *
4*4bc66c0fSBrooks Davis  * Copyright 2000  Brian S. Dean <bsd@bsdhome.com>
5*4bc66c0fSBrooks Davis  * All Rights Reserved.
6*4bc66c0fSBrooks Davis  *
7*4bc66c0fSBrooks Davis  * Redistribution and use in source and binary forms, with or without
8*4bc66c0fSBrooks Davis  * modification, are permitted provided that the following conditions
9*4bc66c0fSBrooks Davis  * are met:
10*4bc66c0fSBrooks Davis  *
11*4bc66c0fSBrooks Davis  * 1. Redistributions of source code must retain the above copyright
12*4bc66c0fSBrooks Davis  *    notice, this list of conditions and the following disclaimer.
13*4bc66c0fSBrooks Davis  * 2. Redistributions in binary form must reproduce the above copyright
14*4bc66c0fSBrooks Davis  *    notice, this list of conditions and the following disclaimer in the
15*4bc66c0fSBrooks Davis  *    documentation and/or other materials provided with the distribution.
16*4bc66c0fSBrooks Davis  *
17*4bc66c0fSBrooks Davis  * THIS SOFTWARE IS PROVIDED BY BRIAN S. DEAN ``AS IS'' AND ANY
18*4bc66c0fSBrooks Davis  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*4bc66c0fSBrooks Davis  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20*4bc66c0fSBrooks Davis  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL BRIAN S. DEAN BE LIABLE
21*4bc66c0fSBrooks Davis  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*4bc66c0fSBrooks Davis  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
23*4bc66c0fSBrooks Davis  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24*4bc66c0fSBrooks Davis  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25*4bc66c0fSBrooks Davis  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*4bc66c0fSBrooks Davis  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27*4bc66c0fSBrooks Davis  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28*4bc66c0fSBrooks Davis  * DAMAGE.
29*4bc66c0fSBrooks Davis  */
30*4bc66c0fSBrooks Davis 
31*4bc66c0fSBrooks Davis #include <machine/reg.h>
32*4bc66c0fSBrooks Davis #include <machine/sysarch.h>
33*4bc66c0fSBrooks Davis 
34*4bc66c0fSBrooks Davis int
i386_clr_watch(int watchnum,struct dbreg * d)35*4bc66c0fSBrooks Davis i386_clr_watch(int watchnum, struct dbreg * d)
36*4bc66c0fSBrooks Davis {
37*4bc66c0fSBrooks Davis 
38*4bc66c0fSBrooks Davis 	if (watchnum < 0 || watchnum >= 4)
39*4bc66c0fSBrooks Davis 		return -1;
40*4bc66c0fSBrooks Davis 
41*4bc66c0fSBrooks Davis 	DBREG_DRX(d,7) = DBREG_DRX(d,7) & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
42*4bc66c0fSBrooks Davis         DBREG_DRX(d,watchnum) = 0;
43*4bc66c0fSBrooks Davis 
44*4bc66c0fSBrooks Davis 	return 0;
45*4bc66c0fSBrooks Davis }
46