root/arch/i386/i386/db_magic.s

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. outb
  2. inb
  3. outw
  4. inw
  5. outl
  6. inl
  7. dr6
  8. dr0
  9. dr1
  10. dr2
  11. dr3
  12. dr_addr

    1 /*      $OpenBSD: db_magic.s,v 1.2 2003/04/17 03:42:14 drahn Exp $      */
    2 
    3 /*
    4  * Mach Operating System
    5  * Copyright (c) 1995 Carnegie Mellon University
    6  * All Rights Reserved.
    7  *
    8  * Permission to use, copy, modify and distribute this software and its
    9  * documentation is hereby granted, provided that both the copyright
   10  * notice and this permission notice appear in all copies of the
   11  * software, derivative works or modified versions, and any portions
   12  * thereof, and that both notices appear in supporting documentation.
   13  *
   14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   16  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   17  *
   18  * Carnegie Mellon requests users of this software to return to
   19  *
   20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   21  *  School of Computer Science
   22  *  Carnegie Mellon University
   23  *  Pittsburgh PA 15213-3890
   24  *
   25  * any improvements or extensions that they make and grant Carnegie Mellon
   26  * the rights to redistribute these changes.
   27  */
   28 
   29 #include <machine/asm.h>
   30 #define S_ARG0         4(%esp)
   31 #define S_ARG1         8(%esp)
   32 #define S_ARG2        12(%esp)
   33 #define S_ARG3        16(%esp)
   34 #define B_ARG0         8(%ebp)
   35 #define B_ARG1        12(%ebp)
   36 #define B_ARG2        16(%ebp)
   37 #define B_ARG3        20(%ebp)
   38 /*
   39  * void outb(unsigned char *io_port,
   40  *         unsigned char byte)
   41  *
   42  * Output a byte to an IO port.
   43  */
   44 ENTRY(outb)
   45       movl    S_ARG0,%edx             /* IO port address */
   46       movl    S_ARG1,%eax             /* data to output */
   47       outb    %al,%dx                 /* send it out */
   48       ret
   49 /*
   50  * unsigned char inb(unsigned char *io_port)
   51  *
   52  * Input a byte from an IO port.
   53  */
   54 ENTRY(inb)
   55       movl    S_ARG0,%edx             /* IO port address */
   56       xor     %eax,%eax               /* clear high bits of register */
   57       inb     %dx,%al                 /* get the byte */
   58       ret
   59 /*
   60  * void outw(unsigned short *io_port,
   61  *         unsigned short word)
   62  *
   63  * Output a word to an IO port.
   64  */
   65 ENTRY(outw)
   66       movl    S_ARG0,%edx             /* IO port address */
   67       movl    S_ARG1,%eax             /* data to output */
   68       outw    %ax,%dx                 /* send it out */
   69       ret
   70 /*
   71  * unsigned short inw(unsigned short *io_port)
   72  *
   73  * Input a word from an IO port.
   74  */
   75 ENTRY(inw)
   76       movl    S_ARG0,%edx             /* IO port address */
   77       xor     %eax,%eax               /* clear high bits of register */
   78       inw     %dx,%ax                 /* get the word */
   79       ret
   80 /*
   81  * void outl(unsigned int *io_port,
   82  *         unsigned int byte)
   83  *
   84  * Output an int to an IO port.
   85  */
   86 ENTRY(outl)
   87       movl    S_ARG0,%edx             /* IO port address */
   88       movl    S_ARG1,%eax             /* data to output */
   89       outl    %eax,%dx                /* send it out */
   90       ret
   91 /*
   92  * unsigned int inl(unsigned int *io_port)
   93  *
   94  * Input an int from an IO port.
   95  */
   96 ENTRY(inl)
   97       movl    S_ARG0,%edx             /* IO port address */
   98       inl     %dx,%eax                /* get the int */
   99       ret
  100 ENTRY(dr6)
  101       movl    %db6, %eax
  102       ret
  103 /*    dr<i>(address, type, len, persistence)
  104  *    type:
  105  *       00   execution (use len 00)
  106  *       01   data write
  107  *       11   data read/write
  108  *    len:
  109  *       00   one byte
  110  *       01   two bytes
  111  *       11   four bytes
  112  */
  113 ENTRY(dr0)
  114       movl    S_ARG0, %eax
  115       movl    %eax,_C_LABEL(dr_addr)
  116       movl    %eax, %db0
  117       movl    $0, %ecx
  118       jmp     0f
  119 ENTRY(dr1)
  120       movl    S_ARG0, %eax
  121       movl    %eax,_C_LABEL(dr_addr)+1*4
  122       movl    %eax, %db1
  123       movl    $2, %ecx
  124       jmp     0f
  125 ENTRY(dr2)
  126       movl    S_ARG0, %eax
  127       movl    %eax,_C_LABEL(dr_addr)+2*4
  128       movl    %eax, %db2
  129       movl    $4, %ecx
  130       jmp     0f
  131 ENTRY(dr3)
  132       movl    S_ARG0, %eax
  133       movl    %eax,_C_LABEL(dr_addr)+3*4
  134       movl    %eax, %db3
  135       movl    $6, %ecx
  136 0:
  137       pushl   %ebp
  138       movl    %esp, %ebp
  139       movl    %db7, %edx
  140       movl    %edx,_C_LABEL(dr_addr)+4*4
  141       andl    dr_msk(,%ecx,2),%edx    /* clear out new entry */
  142       movl    %edx,_C_LABEL(dr_addr)+5*4
  143       movzbl  B_ARG3, %eax
  144       andb    $3, %al
  145       shll    %cl, %eax
  146       orl     %eax, %edx
  147       movzbl  B_ARG1, %eax
  148       andb    $3, %al
  149       add     $0x10, %ecx
  150       shll    %cl, %eax
  151       orl     %eax, %edx
  152       movzbl  B_ARG2, %eax
  153       andb    $3, %al
  154       add     $0x2, %ecx
  155       shll    %cl, %eax
  156       orl     %eax, %edx
  157       movl    %edx, %db7
  158       movl    %edx,_C_LABEL(dr_addr)+7*4
  159       movl    %edx, %eax
  160       leave
  161       ret
  162       .data
  163 dr_msk:
  164       .long   ~0x000f0003
  165       .long   ~0x00f0000c
  166       .long   ~0x0f000030
  167       .long   ~0xf00000c0
  168 ENTRY(dr_addr)
  169       .long   0,0,0,0
  170       .long   0,0,0,0
  171       .text
  172 

/* [<][>][^][v][top][bottom][index][help] */