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) */
156 cmpl %ecx,%eax /* overlapping && src < dst? */
166 addl %ecx,%edi /* copy backwards. */
180 * bcopy(src, dst, cnt)
181 * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
194 cmpl %ecx,%eax /* overlapping && src < dst? */
197 shrl $2,%ecx /* copy by 32-bit words */
201 andl $3,%ecx /* any bytes left? */
211 addl %ecx,%edi /* copy backwards */
215 andl $3,%ecx /* any fractional bytes? */
219 movl 16(%ebp),%ecx /* copy remainder by 32-bit words */
233 * Note: memcpy does not support overlapping copies
242 shrl $2,%ecx /* copy by 32-bit words */
246 andl $3,%ecx /* any bytes left? */
255 * copystr(from, to, maxlen, int *lencopied) - MP SAFE
261 movl 12(%esp),%esi /* %esi = from */
262 movl 16(%esp),%edi /* %edi = to */
263 movl 20(%esp),%edx /* %edx = maxlen */
273 /* Success -- 0 byte reached */
278 /* edx is zero -- return ENAMETOOLONG */
279 movl $ENAMETOOLONG,%eax
282 /* set *lencopied and return %eax */
321 * Handling of special 386 registers and descriptor tables etc
323 /* void lgdt(struct region_descriptor *rdp); */
325 /* reload the descriptor table */
329 /* flush the prefetch q */
333 /* reload "stale" selectors */
342 /* reload code selector by turning return into intersegmental return */
350 /* ssdtosd(*ssdp,*sdp) */
372 /* void reset_dbregs() */
375 movl %eax,%dr7 /* disable all breakpoints first */
384 /*****************************************************************************/
385 /* setjump, longjump */
386 /*****************************************************************************/
390 movl %ebx,(%eax) /* save ebx */
391 movl %esp,4(%eax) /* save esp */
392 movl %ebp,8(%eax) /* save ebp */
393 movl %esi,12(%eax) /* save esi */
394 movl %edi,16(%eax) /* save edi */
395 movl (%esp),%edx /* get rta */
396 movl %edx,20(%eax) /* save eip */
397 xorl %eax,%eax /* return(0); */
403 movl (%eax),%ebx /* restore ebx */
404 movl 4(%eax),%esp /* restore esp */
405 movl 8(%eax),%ebp /* restore ebp */
406 movl 12(%eax),%esi /* restore esi */
407 movl 16(%eax),%edi /* restore edi */
408 movl 20(%eax),%edx /* get rta */
409 movl %edx,(%esp) /* put in return frame */
410 xorl %eax,%eax /* return(1); */
416 * Support for reading MSRs in the safe manner. (Instead of panic on #gp,
420 /* int rdmsr_safe(u_int msr, uint64_t *data) */
421 movl PCPU(CURPCB),%ecx
422 movl $msr_onfault,PCB_ONFAULT(%ecx)
431 movl PCPU(CURPCB),%ecx
432 movl %eax,PCB_ONFAULT(%ecx)
437 * Support for writing MSRs in the safe manner. (Instead of panic on #gp,
441 /* int wrmsr_safe(u_int msr, uint64_t data) */
442 movl PCPU(CURPCB),%ecx
443 movl $msr_onfault,PCB_ONFAULT(%ecx)
451 movl PCPU(CURPCB),%ecx
452 movl %eax,PCB_ONFAULT(%ecx)
457 * MSR operations fault handler
461 movl PCPU(CURPCB),%ecx
462 movl $0,PCB_ONFAULT(%ecx)
466 ENTRY(handle_ibrs_entry)
468 END(handle_ibrs_entry)
470 ENTRY(handle_ibrs_exit)
472 END(handle_ibrs_exit)