2 /* $NecBSD: busio.s,v 1.16.4.1 1999/08/16 09:06:08 kmatsuda Exp $ */
6 * [NetBSD for NEC PC-98 series]
7 * Copyright (c) 1996, 1997, 1998
8 * NetBSD/pc98 porting staff. All rights reserved.
10 * [Ported for FreeBSD]
12 * TAKAHASHI Yoshihiro. All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. The name of the author may not be used to endorse or promote products
23 * derived from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * Copyright (c) 1997, 1998
40 * Naofumi HONDA. All rights reserved.
43 #include <machine/asmacros.h>
47 /***********************************************************
48 * Bus IO access methods (Direct Access)
49 ***********************************************************/
50 #define BUS_ACCESS_ADDR(BSHREG,ADDRREG) \
51 addl BUS_SPACE_HANDLE_BASE/**/(%/**/BSHREG/**/),%/**/ADDRREG
58 ENTRY(SBUS_DA_io_space_read_1)
59 BUS_ACCESS_ADDR(ebx,edx)
63 ENTRY(SBUS_DA_io_space_read_2)
64 BUS_ACCESS_ADDR(ebx,edx)
68 ENTRY(SBUS_DA_io_space_read_4)
69 BUS_ACCESS_ADDR(ebx,edx)
78 ENTRY(SBUS_DA_io_space_write_1)
79 BUS_ACCESS_ADDR(ebx,edx)
83 ENTRY(SBUS_DA_io_space_write_2)
84 BUS_ACCESS_ADDR(ebx,edx)
88 ENTRY(SBUS_DA_io_space_write_4)
89 BUS_ACCESS_ADDR(ebx,edx)
99 ENTRY(SBUS_DA_io_space_read_multi_1)
100 BUS_ACCESS_ADDR(ebx,edx)
106 ENTRY(SBUS_DA_io_space_read_multi_2)
107 BUS_ACCESS_ADDR(ebx,edx)
113 ENTRY(SBUS_DA_io_space_read_multi_4)
114 BUS_ACCESS_ADDR(ebx,edx)
126 ENTRY(SBUS_DA_io_space_write_multi_1)
127 BUS_ACCESS_ADDR(ebx,edx)
133 ENTRY(SBUS_DA_io_space_write_multi_2)
134 BUS_ACCESS_ADDR(ebx,edx)
140 ENTRY(SBUS_DA_io_space_write_multi_4)
141 BUS_ACCESS_ADDR(ebx,edx)
153 ENTRY(SBUS_DA_io_space_read_region_1)
154 BUS_ACCESS_ADDR(ebx,edx)
169 ENTRY(SBUS_DA_io_space_read_region_2)
170 BUS_ACCESS_ADDR(ebx,edx)
185 ENTRY(SBUS_DA_io_space_read_region_4)
186 BUS_ACCESS_ADDR(ebx,edx)
207 ENTRY(SBUS_DA_io_space_write_region_1)
208 BUS_ACCESS_ADDR(ebx,edx)
223 ENTRY(SBUS_DA_io_space_write_region_2)
224 BUS_ACCESS_ADDR(ebx,edx)
239 ENTRY(SBUS_DA_io_space_write_region_4)
240 BUS_ACCESS_ADDR(ebx,edx)
261 ENTRY(SBUS_DA_io_space_set_multi_1)
262 BUS_ACCESS_ADDR(ebx,edx)
272 ENTRY(SBUS_DA_io_space_set_multi_2)
273 BUS_ACCESS_ADDR(ebx,edx)
283 ENTRY(SBUS_DA_io_space_set_multi_4)
284 BUS_ACCESS_ADDR(ebx,edx)
300 ENTRY(SBUS_DA_io_space_set_region_1)
301 BUS_ACCESS_ADDR(ebx,edx)
312 ENTRY(SBUS_DA_io_space_set_region_2)
313 BUS_ACCESS_ADDR(ebx,edx)
324 ENTRY(SBUS_DA_io_space_set_region_4)
325 BUS_ACCESS_ADDR(ebx,edx)
342 ENTRY(SBUS_DA_io_space_copy_region_1)
343 BUS_ACCESS_ADDR(eax,esi)
344 BUS_ACCESS_ADDR(ebx,edi)
365 ENTRY(SBUS_DA_io_space_copy_region_2)
366 BUS_ACCESS_ADDR(eax,esi)
367 BUS_ACCESS_ADDR(ebx,edi)
388 ENTRY(SBUS_DA_io_space_copy_region_4)
389 BUS_ACCESS_ADDR(eax,esi)
390 BUS_ACCESS_ADDR(ebx,edi)
411 /***********************************************************
412 * Bus Memory access methods (Direct Access)
413 ***********************************************************/
417 ENTRY(SBUS_DA_mem_space_read_1)
418 BUS_ACCESS_ADDR(ebx,edx)
422 ENTRY(SBUS_DA_mem_space_read_2)
423 BUS_ACCESS_ADDR(ebx,edx)
427 ENTRY(SBUS_DA_mem_space_read_4)
428 BUS_ACCESS_ADDR(ebx,edx)
435 ENTRY(SBUS_DA_mem_space_write_1)
436 BUS_ACCESS_ADDR(ebx,edx)
440 ENTRY(SBUS_DA_mem_space_write_2)
441 BUS_ACCESS_ADDR(ebx,edx)
445 ENTRY(SBUS_DA_mem_space_write_4)
446 BUS_ACCESS_ADDR(ebx,edx)
453 ENTRY(SBUS_DA_mem_space_read_multi_1)
454 BUS_ACCESS_ADDR(ebx,edx)
468 ENTRY(SBUS_DA_mem_space_read_multi_2)
469 BUS_ACCESS_ADDR(ebx,edx)
483 ENTRY(SBUS_DA_mem_space_read_multi_4)
484 BUS_ACCESS_ADDR(ebx,edx)
501 ENTRY(SBUS_DA_mem_space_write_multi_1)
502 BUS_ACCESS_ADDR(ebx,edx)
516 ENTRY(SBUS_DA_mem_space_write_multi_2)
517 BUS_ACCESS_ADDR(ebx,edx)
531 ENTRY(SBUS_DA_mem_space_write_multi_4)
532 BUS_ACCESS_ADDR(ebx,edx)
549 ENTRY(SBUS_DA_mem_space_read_region_1)
550 BUS_ACCESS_ADDR(ebx,edx)
559 ENTRY(SBUS_DA_mem_space_read_region_2)
560 BUS_ACCESS_ADDR(ebx,edx)
569 ENTRY(SBUS_DA_mem_space_read_region_4)
570 BUS_ACCESS_ADDR(ebx,edx)
582 ENTRY(SBUS_DA_mem_space_write_region_1)
583 BUS_ACCESS_ADDR(ebx,edx)
592 ENTRY(SBUS_DA_mem_space_write_region_2)
593 BUS_ACCESS_ADDR(ebx,edx)
602 ENTRY(SBUS_DA_mem_space_write_region_4)
603 BUS_ACCESS_ADDR(ebx,edx)
615 ENTRY(SBUS_DA_mem_space_set_multi_1)
616 BUS_ACCESS_ADDR(ebx,edx)
626 ENTRY(SBUS_DA_mem_space_set_multi_2)
627 BUS_ACCESS_ADDR(ebx,edx)
637 ENTRY(SBUS_DA_mem_space_set_multi_4)
638 BUS_ACCESS_ADDR(ebx,edx)
651 ENTRY(SBUS_DA_mem_space_set_region_1)
652 BUS_ACCESS_ADDR(ebx,edx)
661 ENTRY(SBUS_DA_mem_space_set_region_2)
662 BUS_ACCESS_ADDR(ebx,edx)
671 ENTRY(SBUS_DA_mem_space_set_region_4)
672 BUS_ACCESS_ADDR(ebx,edx)
684 ENTRY(SBUS_DA_mem_space_copy_region_1)
685 BUS_ACCESS_ADDR(eax,esi)
686 BUS_ACCESS_ADDR(ebx,edi)
692 ENTRY(SBUS_DA_mem_space_copy_region_2)
693 BUS_ACCESS_ADDR(eax,esi)
694 BUS_ACCESS_ADDR(ebx,edi)
700 ENTRY(SBUS_DA_mem_space_copy_region_4)
701 BUS_ACCESS_ADDR(eax,esi)
702 BUS_ACCESS_ADDR(ebx,edi)
708 #undef BUS_ACCESS_ADDR
710 /***********************************************************
711 * Bus IO access methods (Relocate Access)
712 ***********************************************************/
713 #define BUS_ACCESS_ADDR(BSHREG,ADDRREG) \
714 movl BUS_SPACE_HANDLE_IAT/**/(%/**/BSHREG/**/, %/**/ADDRREG/**/, 4), \
716 #define BUS_ACCESS_ADDR2(BSHREG,ADDRREG,DSTREG) \
717 movl BUS_SPACE_HANDLE_IAT/**/(%/**/BSHREG/**/, %/**/ADDRREG/**/, 4), \
724 ENTRY(SBUS_RA_io_space_read_1)
725 BUS_ACCESS_ADDR(ebx,edx)
729 ENTRY(SBUS_RA_io_space_read_2)
730 BUS_ACCESS_ADDR(ebx,edx)
734 ENTRY(SBUS_RA_io_space_read_4)
735 BUS_ACCESS_ADDR(ebx,edx)
744 ENTRY(SBUS_RA_io_space_write_1)
745 BUS_ACCESS_ADDR(ebx,edx)
749 ENTRY(SBUS_RA_io_space_write_2)
750 BUS_ACCESS_ADDR(ebx,edx)
754 ENTRY(SBUS_RA_io_space_write_4)
755 BUS_ACCESS_ADDR(ebx,edx)
765 ENTRY(SBUS_RA_io_space_read_multi_1)
766 BUS_ACCESS_ADDR(ebx,edx)
772 ENTRY(SBUS_RA_io_space_read_multi_2)
773 BUS_ACCESS_ADDR(ebx,edx)
779 ENTRY(SBUS_RA_io_space_read_multi_4)
780 BUS_ACCESS_ADDR(ebx,edx)
792 ENTRY(SBUS_RA_io_space_write_multi_1)
793 BUS_ACCESS_ADDR(ebx,edx)
799 ENTRY(SBUS_RA_io_space_write_multi_2)
800 BUS_ACCESS_ADDR(ebx,edx)
806 ENTRY(SBUS_RA_io_space_write_multi_4)
807 BUS_ACCESS_ADDR(ebx,edx)
819 ENTRY(SBUS_RA_io_space_read_region_1)
827 BUS_ACCESS_ADDR2(ebx,esi,edx)
838 ENTRY(SBUS_RA_io_space_read_region_2)
846 BUS_ACCESS_ADDR2(ebx,esi,edx)
857 ENTRY(SBUS_RA_io_space_read_region_4)
865 BUS_ACCESS_ADDR2(ebx,esi,edx)
882 ENTRY(SBUS_RA_io_space_write_region_1)
890 BUS_ACCESS_ADDR2(ebx,edi,edx)
901 ENTRY(SBUS_RA_io_space_write_region_2)
909 BUS_ACCESS_ADDR2(ebx,edi,edx)
920 ENTRY(SBUS_RA_io_space_write_region_4)
928 BUS_ACCESS_ADDR2(ebx,edi,edx)
945 ENTRY(SBUS_RA_io_space_set_multi_1)
946 BUS_ACCESS_ADDR(ebx,edx)
956 ENTRY(SBUS_RA_io_space_set_multi_2)
957 BUS_ACCESS_ADDR(ebx,edx)
967 ENTRY(SBUS_RA_io_space_set_multi_4)
968 BUS_ACCESS_ADDR(ebx,edx)
984 ENTRY(SBUS_RA_io_space_set_region_1)
990 BUS_ACCESS_ADDR2(ebx,edi,edx)
999 ENTRY(SBUS_RA_io_space_set_region_2)
1005 BUS_ACCESS_ADDR2(ebx,edi,edx)
1014 ENTRY(SBUS_RA_io_space_set_region_4)
1020 BUS_ACCESS_ADDR2(ebx,edi,edx)
1035 ENTRY(SBUS_RA_io_space_copy_region_1)
1041 BUS_ACCESS_ADDR2(ebx,esi,edx)
1045 BUS_ACCESS_ADDR2(ebx,edi,edx)
1056 ENTRY(SBUS_RA_io_space_copy_region_2)
1062 BUS_ACCESS_ADDR2(ebx,esi,edx)
1066 BUS_ACCESS_ADDR2(ebx,edi,edx)
1077 ENTRY(SBUS_RA_io_space_copy_region_4)
1083 BUS_ACCESS_ADDR2(ebx,esi,edx)
1087 BUS_ACCESS_ADDR2(ebx,edi,edx)
1098 /***********************************************************
1099 * Bus Memory access methods
1100 ***********************************************************/
1104 ENTRY(SBUS_RA_mem_space_read_1)
1105 BUS_ACCESS_ADDR(ebx,edx)
1109 ENTRY(SBUS_RA_mem_space_read_2)
1110 BUS_ACCESS_ADDR(ebx,edx)
1114 ENTRY(SBUS_RA_mem_space_read_4)
1115 BUS_ACCESS_ADDR(ebx,edx)
1122 ENTRY(SBUS_RA_mem_space_write_1)
1123 BUS_ACCESS_ADDR(ebx,edx)
1127 ENTRY(SBUS_RA_mem_space_write_2)
1128 BUS_ACCESS_ADDR(ebx,edx)
1132 ENTRY(SBUS_RA_mem_space_write_4)
1133 BUS_ACCESS_ADDR(ebx,edx)
1140 ENTRY(SBUS_RA_mem_space_read_multi_1)
1141 BUS_ACCESS_ADDR(ebx,edx)
1155 ENTRY(SBUS_RA_mem_space_read_multi_2)
1156 BUS_ACCESS_ADDR(ebx,edx)
1170 ENTRY(SBUS_RA_mem_space_read_multi_4)
1171 BUS_ACCESS_ADDR(ebx,edx)
1188 ENTRY(SBUS_RA_mem_space_write_multi_1)
1189 BUS_ACCESS_ADDR(ebx,edx)
1203 ENTRY(SBUS_RA_mem_space_write_multi_2)
1204 BUS_ACCESS_ADDR(ebx,edx)
1218 ENTRY(SBUS_RA_mem_space_write_multi_4)
1219 BUS_ACCESS_ADDR(ebx,edx)
1236 ENTRY(SBUS_RA_mem_space_read_region_1)
1242 BUS_ACCESS_ADDR2(ebx,edx,esi)
1251 ENTRY(SBUS_RA_mem_space_read_region_2)
1257 BUS_ACCESS_ADDR2(ebx,edx,esi)
1266 ENTRY(SBUS_RA_mem_space_read_region_4)
1272 BUS_ACCESS_ADDR2(ebx,edx,esi)
1284 ENTRY(SBUS_RA_mem_space_write_region_1)
1290 BUS_ACCESS_ADDR2(ebx,edx,edi)
1299 ENTRY(SBUS_RA_mem_space_write_region_2)
1305 BUS_ACCESS_ADDR2(ebx,edx,edi)
1314 ENTRY(SBUS_RA_mem_space_write_region_4)
1320 BUS_ACCESS_ADDR2(ebx,edx,edi)
1332 ENTRY(SBUS_RA_mem_space_set_multi_1)
1333 BUS_ACCESS_ADDR(ebx,edx)
1343 ENTRY(SBUS_RA_mem_space_set_multi_2)
1344 BUS_ACCESS_ADDR(ebx,edx)
1354 ENTRY(SBUS_RA_mem_space_set_multi_4)
1355 BUS_ACCESS_ADDR(ebx,edx)
1368 ENTRY(SBUS_RA_mem_space_set_region_1)
1374 BUS_ACCESS_ADDR2(ebx,edx,edi)
1383 ENTRY(SBUS_RA_mem_space_set_region_2)
1389 BUS_ACCESS_ADDR2(ebx,edx,edi)
1398 ENTRY(SBUS_RA_mem_space_set_region_4)
1404 BUS_ACCESS_ADDR2(ebx,edx,edi)
1416 ENTRY(SBUS_RA_mem_space_copy_region_1)
1423 BUS_ACCESS_ADDR(eax,esi)
1424 BUS_ACCESS_ADDR(ebx,edi)
1435 ENTRY(SBUS_RA_mem_space_copy_region_2)
1442 BUS_ACCESS_ADDR(eax,esi)
1443 BUS_ACCESS_ADDR(ebx,edi)
1454 ENTRY(SBUS_RA_mem_space_copy_region_4)
1461 BUS_ACCESS_ADDR(eax,esi)
1462 BUS_ACCESS_ADDR(ebx,edi)
1473 #undef BUS_ACCESS_ADDR
1474 #undef BUS_ACCESS_ADDR2
1477 #include "opt_mecia.h"
1480 /***********************************************************
1481 * NEPC pcmcia 16 bits bus access
1482 ***********************************************************/
1483 #define NEPC_SWITCH_BUS16 \
1487 movl $0x2a8e,%edx ;\
1495 #define NEPC_BUS_RESTORE \
1499 movl $0x2a8e,%edx ;\
1505 /***********************************************************
1506 * NEPC pcmcia 16 bits bus acces (Direct Access)
1507 ***********************************************************/
1508 #define BUS_ACCESS_ADDR(BSHREG,ADDRREG) \
1509 addl BUS_SPACE_HANDLE_BASE/**/(%/**/BSHREG/**/),%/**/ADDRREG
1511 ENTRY(NEPC_DA_io_space_read_2)
1512 BUS_ACCESS_ADDR(ebx,edx)
1519 ENTRY(NEPC_DA_io_space_write_2)
1520 BUS_ACCESS_ADDR(ebx,edx)
1526 ENTRY(NEPC_DA_io_space_read_multi_2)
1527 BUS_ACCESS_ADDR(ebx,edx)
1535 ENTRY(NEPC_DA_io_space_write_multi_2)
1536 BUS_ACCESS_ADDR(ebx,edx)
1544 ENTRY(NEPC_DA_io_space_read_region_2)
1546 call SBUS_DA_io_space_read_region_2
1550 ENTRY(NEPC_DA_io_space_write_region_2)
1552 call SBUS_DA_io_space_write_region_2
1556 ENTRY(NEPC_DA_io_space_set_multi_2)
1558 call SBUS_DA_io_space_set_multi_2
1563 ENTRY(NEPC_DA_io_space_set_region_2)
1565 call SBUS_DA_io_space_set_region_2
1569 ENTRY(NEPC_DA_io_space_copy_region_2)
1571 call SBUS_DA_io_space_copy_region_2
1575 ENTRY(NEPC_DA_io_space_read_4)
1576 BUS_ACCESS_ADDR(ebx,edx)
1582 ENTRY(NEPC_DA_io_space_write_4)
1583 BUS_ACCESS_ADDR(ebx,edx)
1589 ENTRY(NEPC_DA_io_space_read_multi_4)
1590 BUS_ACCESS_ADDR(ebx,edx)
1598 ENTRY(NEPC_DA_io_space_write_multi_4)
1599 BUS_ACCESS_ADDR(ebx,edx)
1607 ENTRY(NEPC_DA_io_space_read_region_4)
1609 call SBUS_DA_io_space_read_region_4
1613 ENTRY(NEPC_DA_io_space_write_region_4)
1615 call SBUS_DA_io_space_write_region_4
1619 ENTRY(NEPC_DA_io_space_set_multi_4)
1621 call SBUS_DA_io_space_set_multi_4
1626 ENTRY(NEPC_DA_io_space_set_region_4)
1628 call SBUS_DA_io_space_set_region_4
1632 ENTRY(NEPC_DA_io_space_copy_region_4)
1634 call SBUS_DA_io_space_copy_region_4
1638 #undef BUS_ACCESS_ADDR
1640 /***********************************************************
1641 * NEPC pcmcia 16 bits bus acces (Relocate Access)
1642 ***********************************************************/
1643 #define BUS_ACCESS_ADDR(BSHREG,ADDRREG) \
1644 movl BUS_SPACE_HANDLE_IAT/**/(%/**/BSHREG/**/, %/**/ADDRREG/**/, 4), \
1647 ENTRY(NEPC_RA_io_space_read_2)
1648 BUS_ACCESS_ADDR(ebx,edx)
1655 ENTRY(NEPC_RA_io_space_write_2)
1656 BUS_ACCESS_ADDR(ebx,edx)
1662 ENTRY(NEPC_RA_io_space_read_multi_2)
1663 BUS_ACCESS_ADDR(ebx,edx)
1671 ENTRY(NEPC_RA_io_space_write_multi_2)
1672 BUS_ACCESS_ADDR(ebx,edx)
1680 ENTRY(NEPC_RA_io_space_read_region_2)
1682 call SBUS_RA_io_space_read_region_2
1686 ENTRY(NEPC_RA_io_space_write_region_2)
1688 call SBUS_RA_io_space_write_region_2
1692 ENTRY(NEPC_RA_io_space_set_multi_2)
1694 call SBUS_RA_io_space_set_multi_2
1699 ENTRY(NEPC_RA_io_space_set_region_2)
1701 call SBUS_RA_io_space_set_region_2
1705 ENTRY(NEPC_RA_io_space_copy_region_2)
1707 call SBUS_RA_io_space_copy_region_2
1711 ENTRY(NEPC_RA_io_space_read_4)
1712 BUS_ACCESS_ADDR(ebx,edx)
1718 ENTRY(NEPC_RA_io_space_write_4)
1719 BUS_ACCESS_ADDR(ebx,edx)
1725 ENTRY(NEPC_RA_io_space_read_multi_4)
1726 BUS_ACCESS_ADDR(ebx,edx)
1734 ENTRY(NEPC_RA_io_space_write_multi_4)
1735 BUS_ACCESS_ADDR(ebx,edx)
1743 ENTRY(NEPC_RA_io_space_read_region_4)
1745 call SBUS_RA_io_space_read_region_4
1749 ENTRY(NEPC_RA_io_space_write_region_4)
1751 call SBUS_RA_io_space_write_region_4
1755 ENTRY(NEPC_RA_io_space_set_multi_4)
1757 call SBUS_RA_io_space_set_multi_4
1762 ENTRY(NEPC_RA_io_space_set_region_4)
1764 call SBUS_RA_io_space_set_region_4
1768 ENTRY(NEPC_RA_io_space_copy_region_4)
1770 call SBUS_RA_io_space_copy_region_4
1774 #endif /* DEV_MECIA */