1: /* 2: * Copyright (c) 1988 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)net_mbuf.s 2.0 (2.11BSD GTE) 3/13/93 7: */ 8: 9: #include "DEFS.h" 10: #include "../machine/mch_iopage.h" 11: 12: /* 13: * mbcopyin(click, off, ptr, len) 14: * u_short click; / address of external DMA buffer 15: * u_short off; / offset into click of start of buffer 16: * caddr_t ptr; / address of internal buffer 17: * short len; / bytes to copy from click/off to ptr 18: * 19: * mbcopyout(ptr, click, off, len) 20: * caddr_t ptr; / address of internal buffer 21: * u_short click; / address of external DMA buffer 22: * u_short off; / offset into click of start of buffer 23: * short len; / bytes to copy from ptr to click/off 24: * 25: * Used for copying data from/to the UNIBUS DMA pages to/from the 26: * in-address-space mbufs. Cannot copy data to or from the stack. Len 27: * cannot exceed 8Kbytes. 28: * 29: * We remap SDSA6 to do the copy and run at SPL7. 30: */ 31: 32: ENTRY(mbcopyin) 33: jsr r5,csv 34: mov 012(r5),r0 / grab byte count 35: ble 3f / nothing to do if len <= 0 ... 36: mov 06(r5),r1 / grab offset and computer pointer 37: add $140000,r1 / to mapped in source data 38: mov 010(r5),r2 / grab ptr (destination address) 39: mov PS,-(sp) / save PS since we lock out interrupts 40: SPL7 41: mov SDSA6,r3 / save mapping for stack / u. area 42: mov 04(r5),SDSA6 / map in source data 43: br 0f 44: 45: ENTRY(mbcopyout) 46: jsr r5,csv 47: mov 012(r5),r0 / grab byte count 48: ble 3f / nothing to do if len <= 0 ... 49: mov 04(r5),r1 / grab ptr (source address) 50: mov 010(r5),r2 / grab offset and compute pointer 51: add $140000,r2 / to mapped destination address 52: mov PS,-(sp) / save PS since we lock out interrupts 53: SPL7 54: mov SDSA6,r3 / save mapping for stack / u. area 55: mov 06(r5),SDSA6 / map in destination address data 56: 57: /* 58: * Common loop and return for mbcopyin and mbcopyout. Copy from (r1) to 59: * (r2) for r0 bytes. r3 contains old seg6 address descriptor. 60: */ 61: 0: 62: cmp r0,$8192. / too big? 63: bge 2f / yes, ignore it 64: cmp r0,$10. / if (length >= 10) 65: bhi 4f / try words 66: 1: 67: movb (r1)+,(r2)+ / do *dst++ = *src++ 68: sob r0,1b / while (--length) 69: 2: 70: mov r3,SDSA6 / map back in stack / u. area 71: mov (sp)+,PS / restore original priority 72: 3: 73: jmp cret 74: /* 75: * The length of the copy justifies trying a word by word copy. If src and 76: * dst are of the same parity, we can do a word copy by handling any leading 77: * and trailing odd bytes separately. NOTE: r4 is used to hold the odd byte 78: * indicator because the stack is invalid (mapped out). 79: */ 80: 4: 81: bit $1,r1 / if (src&1 != dst&1) 82: beq 5f / do bytes 83: bit $1,r2 84: beq 1b / (src odd, dst even - do bytes) 85: movb (r1)+,(r2)+ / copy leading odd byte 86: dec r0 87: br 6f 88: 5: 89: bit $1,r2 90: bne 1b / (src even, dst odd - do bytes) 91: 6: 92: mov r0,r4 / save trailing byte indicator 93: asr r0 / length >>= 1 (unsigned) 94: asr r0 / if (length >>= 1, wasodd(length)) 95: bcc 7f / handle leading non multiple of four 96: mov (r1)+,(r2)+ 97: 7: 98: asr r0 / if (length >>= 1, wasodd(length)) 99: bcc 8f / handle leading non multiple of eight 100: mov (r1)+,(r2)+ 101: mov (r1)+,(r2)+ 102: 8: 103: mov (r1)+,(r2)+ / do 104: mov (r1)+,(r2)+ / move eight bytes 105: mov (r1)+,(r2)+ 106: mov (r1)+,(r2)+ 107: sob r0,8b / while (--length) 108: asr r4 / if (odd trailing byte) 109: bcc 2b 110: movb (r1)+,(r2)+ / copy it 111: br 2b / and return