1*58a2b000SEvgeniy Ivanov/* $NetBSD: pvcopy.S,v 1.2 2008/04/28 20:23:25 martin Exp $ */ 2*58a2b000SEvgeniy Ivanov 3*58a2b000SEvgeniy Ivanov/*- 4*58a2b000SEvgeniy Ivanov * Copyright (c) 2003 The NetBSD Foundation, Inc. 5*58a2b000SEvgeniy Ivanov * All rights reserved. 6*58a2b000SEvgeniy Ivanov * 7*58a2b000SEvgeniy Ivanov * This code is derived from software contributed to The NetBSD Foundation 8*58a2b000SEvgeniy Ivanov * by David Laight. 9*58a2b000SEvgeniy Ivanov * 10*58a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without 11*58a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions 12*58a2b000SEvgeniy Ivanov * are met: 13*58a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright 14*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer. 15*58a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright 16*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer in the 17*58a2b000SEvgeniy Ivanov * documentation and/or other materials provided with the distribution. 18*58a2b000SEvgeniy Ivanov * 19*58a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*58a2b000SEvgeniy Ivanov * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*58a2b000SEvgeniy Ivanov * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*58a2b000SEvgeniy Ivanov * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*58a2b000SEvgeniy Ivanov * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*58a2b000SEvgeniy Ivanov * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*58a2b000SEvgeniy Ivanov * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*58a2b000SEvgeniy Ivanov * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*58a2b000SEvgeniy Ivanov * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*58a2b000SEvgeniy Ivanov * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*58a2b000SEvgeniy Ivanov * POSSIBILITY OF SUCH DAMAGE. 30*58a2b000SEvgeniy Ivanov */ 31*58a2b000SEvgeniy Ivanov 32*58a2b000SEvgeniy Ivanov#include <machine/asm.h> 33*58a2b000SEvgeniy Ivanov 34*58a2b000SEvgeniy Ivanov/* 35*58a2b000SEvgeniy Ivanov * Routines to copy to/from absolute virtual addresses. 36*58a2b000SEvgeniy Ivanov * Needed because the boot code runs with %ds having a 64k offset 37*58a2b000SEvgeniy Ivanov * whereas Unix runs with a zero offset. 38*58a2b000SEvgeniy Ivanov * 39*58a2b000SEvgeniy Ivanov * These routines are optimised for code space, not execution speed. 40*58a2b000SEvgeniy Ivanov */ 41*58a2b000SEvgeniy Ivanov 42*58a2b000SEvgeniy Ivanov/* 43*58a2b000SEvgeniy Ivanov * pbzero(void *dst, int cnt) 44*58a2b000SEvgeniy Ivanov * zero absolute virtual memory 45*58a2b000SEvgeniy Ivanov */ 46*58a2b000SEvgeniy IvanovENTRY(pbzero) 47*58a2b000SEvgeniy Ivanov .code32 48*58a2b000SEvgeniy Ivanov push %edi 49*58a2b000SEvgeniy Ivanov push %es 50*58a2b000SEvgeniy Ivanov mov 12(%esp),%edi 51*58a2b000SEvgeniy Ivanov mov 16(%esp),%ecx 52*58a2b000SEvgeniy Ivanov 53*58a2b000SEvgeniy Ivanov mov $flatdataseg, %ax /* selector with offset == 0 */ 54*58a2b000SEvgeniy Ivanov mov %ax, %es 55*58a2b000SEvgeniy Ivanov xor %eax,%eax 56*58a2b000SEvgeniy Ivanov 57*58a2b000SEvgeniy Ivanov cld 58*58a2b000SEvgeniy Ivanov rep 59*58a2b000SEvgeniy Ivanov stosb 60*58a2b000SEvgeniy Ivanov 61*58a2b000SEvgeniy Ivanov pop %es 62*58a2b000SEvgeniy Ivanov pop %edi 63*58a2b000SEvgeniy Ivanov ret 64*58a2b000SEvgeniy Ivanov 65*58a2b000SEvgeniy Ivanov/* 66*58a2b000SEvgeniy Ivanov * vpbcopy(const void *src, void *dst, int cnt) 67*58a2b000SEvgeniy Ivanov * Copy to absolute virtual address 68*58a2b000SEvgeniy Ivanov */ 69*58a2b000SEvgeniy IvanovENTRY(vpbcopy) 70*58a2b000SEvgeniy Ivanov .code32 71*58a2b000SEvgeniy Ivanov push %esi 72*58a2b000SEvgeniy Ivanov push %edi 73*58a2b000SEvgeniy Ivanov push %es 74*58a2b000SEvgeniy Ivanov mov 16(%esp),%esi 75*58a2b000SEvgeniy Ivanov mov 20(%esp),%edi 76*58a2b000SEvgeniy Ivanov mov 24(%esp),%ecx 77*58a2b000SEvgeniy Ivanov 78*58a2b000SEvgeniy Ivanov mov $flatdataseg, %ax /* selector with offset == 0 */ 79*58a2b000SEvgeniy Ivanov mov %ax, %es 80*58a2b000SEvgeniy Ivanov xor %eax,%eax 81*58a2b000SEvgeniy Ivanov 82*58a2b000SEvgeniy Ivanov cld 83*58a2b000SEvgeniy Ivanov rep 84*58a2b000SEvgeniy Ivanov movsb 85*58a2b000SEvgeniy Ivanov 86*58a2b000SEvgeniy Ivanov popl %es 87*58a2b000SEvgeniy Ivanov popl %edi 88*58a2b000SEvgeniy Ivanov popl %esi 89*58a2b000SEvgeniy Ivanov ret 90*58a2b000SEvgeniy Ivanov 91*58a2b000SEvgeniy Ivanov/* 92*58a2b000SEvgeniy Ivanov * pvbcopy(const void *src, void *dst, int cnt) 93*58a2b000SEvgeniy Ivanov * Copy from absolute virtual address 94*58a2b000SEvgeniy Ivanov */ 95*58a2b000SEvgeniy IvanovENTRY(pvbcopy) 96*58a2b000SEvgeniy Ivanov .code32 97*58a2b000SEvgeniy Ivanov push %esi 98*58a2b000SEvgeniy Ivanov push %edi 99*58a2b000SEvgeniy Ivanov push %ds 100*58a2b000SEvgeniy Ivanov mov 16(%esp),%esi 101*58a2b000SEvgeniy Ivanov mov 20(%esp),%edi 102*58a2b000SEvgeniy Ivanov mov 24(%esp),%ecx 103*58a2b000SEvgeniy Ivanov 104*58a2b000SEvgeniy Ivanov mov $flatdataseg, %ax /* selector with offset == 0 */ 105*58a2b000SEvgeniy Ivanov mov %ax, %ds 106*58a2b000SEvgeniy Ivanov xor %eax,%eax 107*58a2b000SEvgeniy Ivanov 108*58a2b000SEvgeniy Ivanov cld 109*58a2b000SEvgeniy Ivanov rep 110*58a2b000SEvgeniy Ivanov movsb 111*58a2b000SEvgeniy Ivanov 112*58a2b000SEvgeniy Ivanov popl %ds 113*58a2b000SEvgeniy Ivanov popl %edi 114*58a2b000SEvgeniy Ivanov popl %esi 115*58a2b000SEvgeniy Ivanov ret 116