2 * Copyright (c) 1993 The Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
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
32 #include <machine/asmacros.h>
33 #include <machine/cputypes.h>
34 #include <machine/pmap.h>
35 #include <machine/specialreg.h>
45 * void bzero(void *buf, u_int len)
71 * The loop takes 14 bytes. Ensure that it doesn't cross a 16-byte
136 /* fillw(pat, base, cnt) */
149 * bcopy(src, dst, cnt)
150 * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
163 cmpl %ecx,%eax /* overlapping && src < dst? */
166 shrl $2,%ecx /* copy by 32-bit words */
170 andl $3,%ecx /* any bytes left? */
180 addl %ecx,%edi /* copy backwards */
184 andl $3,%ecx /* any fractional bytes? */
188 movl 16(%ebp),%ecx /* copy remainder by 32-bit words */
202 * Note: memcpy does not support overlapping copies
211 shrl $2,%ecx /* copy by 32-bit words */
215 andl $3,%ecx /* any bytes left? */
224 * copystr(from, to, maxlen, int *lencopied) - MP SAFE
230 movl 12(%esp),%esi /* %esi = from */
231 movl 16(%esp),%edi /* %edi = to */
232 movl 20(%esp),%edx /* %edx = maxlen */
242 /* Success -- 0 byte reached */
247 /* edx is zero -- return ENAMETOOLONG */
248 movl $ENAMETOOLONG,%eax
251 /* set *lencopied and return %eax */
290 * Handling of special 386 registers and descriptor tables etc
292 /* void lgdt(struct region_descriptor *rdp); */
294 /* reload the descriptor table */
298 /* flush the prefetch q */
302 /* reload "stale" selectors */
311 /* reload code selector by turning return into intersegmental return */
319 /* ssdtosd(*ssdp,*sdp) */
341 /* void reset_dbregs() */
344 movl %eax,%dr7 /* disable all breakpoints first */
353 /*****************************************************************************/
354 /* setjump, longjump */
355 /*****************************************************************************/
359 movl %ebx,(%eax) /* save ebx */
360 movl %esp,4(%eax) /* save esp */
361 movl %ebp,8(%eax) /* save ebp */
362 movl %esi,12(%eax) /* save esi */
363 movl %edi,16(%eax) /* save edi */
364 movl (%esp),%edx /* get rta */
365 movl %edx,20(%eax) /* save eip */
366 xorl %eax,%eax /* return(0); */
372 movl (%eax),%ebx /* restore ebx */
373 movl 4(%eax),%esp /* restore esp */
374 movl 8(%eax),%ebp /* restore ebp */
375 movl 12(%eax),%esi /* restore esi */
376 movl 16(%eax),%edi /* restore edi */
377 movl 20(%eax),%edx /* get rta */
378 movl %edx,(%esp) /* put in return frame */
379 xorl %eax,%eax /* return(1); */
385 * Support for reading MSRs in the safe manner. (Instead of panic on #gp,
389 /* int rdmsr_safe(u_int msr, uint64_t *data) */
390 movl PCPU(CURPCB),%ecx
391 movl $msr_onfault,PCB_ONFAULT(%ecx)
400 movl PCPU(CURPCB),%ecx
401 movl %eax,PCB_ONFAULT(%ecx)
406 * Support for writing MSRs in the safe manner. (Instead of panic on #gp,
410 /* int wrmsr_safe(u_int msr, uint64_t data) */
411 movl PCPU(CURPCB),%ecx
412 movl $msr_onfault,PCB_ONFAULT(%ecx)
420 movl PCPU(CURPCB),%ecx
421 movl %eax,PCB_ONFAULT(%ecx)
426 * MSR operations fault handler
430 movl PCPU(CURPCB),%ecx
431 movl $0,PCB_ONFAULT(%ecx)
435 ENTRY(handle_ibrs_entry)
437 END(handle_ibrs_entry)
439 ENTRY(handle_ibrs_exit)
441 END(handle_ibrs_exit)