Annotation of coherent/d/286_KERNEL/USRSRC/io/ipcas.s, revision 1.1.1.1

1.1       root        1: / $Header: /usr/src/sys/i8086/drv/RCS/ipcas.s,v 2.1 88/09/03 13:06:24 src Exp $
                      2: /
                      3: /      The  information  contained herein  is a trade secret  of INETCO
                      4: /      Systems, and is confidential information.   It is provided under
                      5: /      a license agreement,  and may be copied or disclosed  only under
                      6: /      the terms of that agreement.   Any reproduction or disclosure of
                      7: /      this  material  without  the express  written  authorization  of
                      8: /      INETCO Systems or persuant to the license agreement is unlawful.
                      9: /
                     10: /      Copyright (c) 1985, 1984
                     11: /      An unpublished work by INETCO Systems, Ltd.
                     12: /      All rights reserved.
                     13: /
                     14: 
                     15: ////////
                     16: /
                     17: / System V Compatible Inter-Process Communication - Assembler Support
                     18: /
                     19: / ufcopy( base, off, sel, n ) -- copy n bytes from user base to sel:off.
                     20: / fucopy( off, sel, base, n ) -- copy n bytes from sel:off to user base.
                     21: /
                     22: / $Log:        /usr/src/sys/i8086/drv/RCS/ipcas.s,v $
                     23: / Revision 2.1 88/09/03  13:06:24      src
                     24: / *** empty log message ***
                     25: / 
                     26: / Revision 1.1 88/03/24  17:05:05      src
                     27: / Initial revision
                     28: / 
                     29: /
                     30: / 85/07/19     Allan Cornish
                     31: / Inserted code to check user address for validity.
                     32: / Functions ufcopy and fucopy now return 0 if user address is invalid.
                     33: / Replaced 'jnc .+2;movsb' with 'rcl cx,$1;rep movsb' to improve pipelining.
                     34: /
                     35: / 85/07/03     Allan Cornish
                     36: / Functions renamed: uoscopy --> ufcopy, osucopy --> fucopy (f = far).
                     37: / Module moved from msgas.s to ipcas.s, to reflect its shared use.
                     38: /
                     39: ////////
                     40: 
                     41:        .globl  ufcopy_
                     42:        .globl  fucopy_
                     43: 
                     44: ////////
                     45: /
                     46: / ufcopy( base, off, sel, n )  -- copy n bytes from user base to sel:off.
                     47: /
                     48: /      Input:  base = offset in user memory to copy from
                     49: /              off  = offset in the destination segment
                     50: /              sel  = selector to access the destination segment
                     51: /              n    = number of bytes to copy
                     52: /
                     53: /      Action: Copy 'n' bytes of data from offset 'base' in user memory
                     54: /              to offset 'off' in the segment accessed by selector 'sel'.
                     55: /
                     56: /      Return: Number of bytes copied, or 0 if invalid user address.
                     57: /
                     58: ////////
                     59: 
                     60: ufcopy_:                       / ufcopy( base, off, sel, n )
                     61:        push    si              /
                     62:        push    di              / unsigned base;
                     63:        push    bp              / unsigned off;
                     64:        mov     bp, sp          / saddr_t sel;
                     65:        push    ds              / unsigned n;
                     66:        push    es              /
                     67:                                / {
                     68:        mov     ax, 8(bp)       /       Validate user address.
                     69:        dec     ax              /
                     70:        add     ax, 14(bp)      /       Wrap-around error?
                     71:        jc      fuerr           /
                     72:        cmp     ax, udl_        /       Address out of bounds error?
                     73:        ja      fuerr           /
                     74:                                /
                     75:        mov     bx, uds_        /       Map DS:SI into user (source) addr
                     76:        mov     ds, bx          /
                     77:        mov     si, 8(bp)       /
                     78:        les     di, 10(bp)      /       Map ES:DI into segment (dest) addr
                     79:        mov     cx, 14(bp)      /       Transfer count
                     80:                                /
                     81:        cld                     /       Auto Increment
                     82:        clc                     /
                     83:        rcr     cx, $1          /       Change byte count into word count
                     84:        rep                     /       Transfer data words
                     85:        movsw                   /
                     86:        rcl     cx, $1          /       If residual byte count
                     87:        rep                     /               Transfer last data byte.
                     88:        movsb                   /
                     89:                                /
                     90:        mov     ax, 14(bp)      /       Return transfer count.
                     91:        pop     es              / }
                     92:        pop     ds
                     93:        pop     bp
                     94:        pop     di
                     95:        pop     si
                     96:        ret
                     97: 
                     98: fuerr: sub     ax, ax
                     99:        pop     es
                    100:        pop     ds
                    101:        pop     bp
                    102:        pop     di
                    103:        pop     si
                    104:        ret
                    105: 
                    106: ////////
                    107: /
                    108: / fucopy( off, sel, base, n )  -- copy n bytes from sel:off to user base.
                    109: /
                    110: /      Input:  off  = offset is the source segment
                    111: /              sel  = selector to access the source segment
                    112: /              base = offset in user memory to copy to
                    113: /              n    = number of bytes to copy
                    114: /
                    115: /      Action: Copy 'n' bytes of data from offset 'off' in the segment
                    116: /              accessed by selector 'sel' to offset 'base' in user memory.
                    117: /
                    118: /      Return: Number of bytes copied, or 0 if invalid user address.
                    119: /
                    120: ////////
                    121: 
                    122: fucopy_:                       / fucopy( off, sel, base, n )
                    123:        push    si              /
                    124:        push    di              / unsigned off;
                    125:        push    bp              / saddr_t  sel;
                    126:        mov     bp, sp          / unsigned base;
                    127:        push    ds              / unsigned n;
                    128:        push    es              /
                    129:                                / {
                    130:        mov     ax, 12(bp)      /       Validate user address.
                    131:        dec     ax              /
                    132:        add     ax, 14(bp)      /       Wrap-around error?
                    133:        jc      fuerr           /
                    134:        cmp     ax, udl_        /       Address out of bounds error?
                    135:        ja      fuerr           /
                    136:                                /
                    137:        mov     es, uds_        /       Map ES:DI into user (dest) address
                    138:        mov     di, 12(bp)      /
                    139:        lds     si, 8(bp)       /       Map DS:SI into segment (source) addr
                    140:        mov     cx, 14(bp)      /       Transfer count
                    141:                                /
                    142:        cld                     /       Auto Increment
                    143:        clc                     /
                    144:        rcr     cx, $1          /       Change byte count into word count
                    145:        rep                     /
                    146:        movsw                   /       Transfer data words
                    147:        rcl     cx, $1          /       If residual byte count
                    148:        rep                     /               Transfer last data byte.
                    149:        movsb                   /
                    150:                                /
                    151:        mov     ax, 14(bp)      /       Return transfer count.
                    152:        pop     es              / }
                    153:        pop     ds
                    154:        pop     bp
                    155:        pop     di
                    156:        pop     si
                    157:        ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.