1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747
|
/*
* $Id: chip_intel_82443LX.c,v 1.17 2009-11-13 10:19:55 vrsieh Exp $
*
* Copyright (C) 2003-2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
/*
* This is an implementation of the host controller of the
* Intel 440LX chipset.
*/
#define DEBUG_SMRAM 0
#define DEBUG_CHIPSET 0
#include "config.h"
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fixme.h"
#include "glue-log.h"
#include "pci.h" /* Should go away - FIXME VOSSI */
#include "chip_intel_82443LX.h"
#define CHIP_(x) chip_intel_82443LX_ ## x
enum CHIP_(orig) {
ORIG_HOST_BUS,
ORIG_PCI_BUS,
};
struct cpssp {
/*
* Config
*/
/*
* Signals
*/
struct sig_host_bus_main *port_host_bus;
struct sig_pci_bus_main *port_pci_bus;
struct sig_pci_bus_idsel *port_idsel;
struct sig_agp_bus_main *port_agp_bus;
struct sig_pci_bus_idsel *port_gidsel;
struct sig_cs *sig_mem_cs[8];
/*
* State
*/
uint32_t confsp[64];
enum CHIP_(region) {
REGION_NONE,
REGION_PM2_CTL,
REGION_CONFADD,
REGION_CONFDATA,
REGION_MEM0,
REGION_MEM1,
REGION_MEM2,
REGION_MEM3,
REGION_MEM4,
REGION_MEM5,
REGION_MEM6,
REGION_MEM7,
REGION_PCI,
} selected;
uint32_t selected_addr;
uint32_t confadd; /* Currently addressed device/register */
};
/* ----------------------------------------------------------------- */
/* Built-In Functions */
/* ----------------------------------------------------------------- */
/*
* FIXME:
* This (optional, for ACPI) register is used to disable both
* the PCI and AGP arbiters in the 82443LX to prevent any
* external bus masters from acquiring the PCI or AGP bus.
*/
static int
CHIP_(pm2_ctl_read)(
struct cpssp *cpssp,
unsigned int bs,
uint32_t *datap
)
{
if ((bs >> 2) & 1) {
fprintf(stderr, "WARNING: 82443LX (Power Management): "
"reading from unimplemented PM2_CTL register\n");
*datap &= ~(0xff << 16);
*datap |= 0x00 << 16;
return 0;
} else {
return -1;
}
}
static int
CHIP_(pm2_ctl_write)(
struct cpssp *cpssp,
unsigned int bs,
uint32_t data
)
{
if ((bs >> 2) & 1) {
data >>= 16;
data &= 0xff;
fprintf(stderr, "WARNING: 82443LX (Power Management): "
"writing 0x%02x%s to unimplemented PM2_CTL "
"register\n", data, (data & ~0x01) ? " (reserved bits!)" : "");
return 0;
} else {
return -1;
}
}
static int
CHIP_(confadd_read)(
struct cpssp *cpssp,
unsigned int bs,
uint32_t *datap
)
{
if (bs == 0xf) {
*datap = cpssp->confadd;
return 0;
} else {
return -1;
}
}
static int
CHIP_(confadd_write)(
struct cpssp *cpssp,
unsigned int bs,
uint32_t data
)
{
if (bs == 0xf) {
uint32_t odata;
data &= ~(1 << 30); /* Clear reserved bits. */
data &= ~(1 << 29);
data &= ~(1 << 28);
data &= ~(1 << 27);
data &= ~(1 << 26);
data &= ~(1 << 25);
data &= ~(1 << 24);
data &= ~(1 << 1);
data &= ~(1 << 0);
odata = cpssp->confadd;
cpssp->confadd = data;
if (((odata >> 31) & 1) != ((data >> 31) & 1)) {
sig_host_bus_ior_info_flush(cpssp->port_host_bus, cpssp,
0x0cfc, 0);
sig_host_bus_iow_info_flush(cpssp->port_host_bus, cpssp,
0x0cfc, 0);
}
return 0;
} else {
return -1;
}
}
static enum CHIP_(region)
CHIP_(_region)(
struct cpssp *cpssp,
enum CHIP_(orig) orig,
unsigned int type,
unsigned int smm,
uint32_t addr
)
{
enum CHIP_(region) region;
switch (type) {
case SIG_HOST_BUS_IOR:
case SIG_HOST_BUS_IOW:
if (addr == 0x0020
&& ((pci_getconfigb(cpssp->confsp, 0x7A) >> 6) & 1)) {
/*
* "When bit 6 of the PMCR is set to `1', the ACPI
* Register [...] is enabled. When bit 6 is set to
* `0', I/O accesses to location 0022h are forwarded
* to PCI or AGP"
* (3-4, 82443LX datasheet)
*/
region = REGION_PM2_CTL;
} else if (addr == 0x0cf8) {
region = REGION_CONFADD;
} else if (addr == 0x0cfc
&& ((cpssp->confadd >> 31) & 1)) {
region = REGION_CONFDATA;
} else {
region = REGION_PCI;
}
break;
case SIG_HOST_BUS_MR:
case SIG_HOST_BUS_MW: {
unsigned int rw;
if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x60)) {
region = REGION_MEM0;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x61)) {
region = REGION_MEM1;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x62)) {
region = REGION_MEM2;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x63)) {
region = REGION_MEM3;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x64)) {
region = REGION_MEM4;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x65)) {
region = REGION_MEM5;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x66)) {
region = REGION_MEM6;
} else if ((addr >> 23) < pci_getconfigb(cpssp->confsp, 0x67)) {
region = REGION_MEM7;
} else {
region = REGION_PCI;
}
if (/* 0x00000000 <= addr && */ addr < 0x000a0000) {
/*
* Low memory.
*/
rw = 3;
} else if (0x000a0000 <= addr && addr < 0x000c0000) {
/*
* VGA hole / SMRAM
*/
unsigned int n;
n = pci_getconfigb(cpssp->confsp, 0x72); /*SMRAM Control*/
if ((n & (1 << 3) /* G_SMRAME */)
&& (smm || ((n & (1 << 6) /* D_OPEN */)))) {
/* SMRAM */
rw = 3;
} else {
/* VGA Hole */
rw = 0;
}
} else if (0x000c0000 <= addr && addr < 0x000c4000) {
rw = pci_getconfigb(cpssp->confsp, 0x5a) & 0xf;
} else if (0x000c4000 <= addr && addr < 0x000c8000) {
rw = pci_getconfigb(cpssp->confsp, 0x5a) >> 4;
} else if (0x000c8000 <= addr && addr < 0x000cc000) {
rw = pci_getconfigb(cpssp->confsp, 0x5b) & 0xf;
} else if (0x000cc000 <= addr && addr < 0x000d0000) {
rw = pci_getconfigb(cpssp->confsp, 0x5b) >> 4;
} else if (0x000d0000 <= addr && addr < 0x000d4000) {
rw = pci_getconfigb(cpssp->confsp, 0x5c) & 0xf;
} else if (0x000d4000 <= addr && addr < 0x000d8000) {
rw = pci_getconfigb(cpssp->confsp, 0x5c) >> 4;
} else if (0x000d8000 <= addr && addr < 0x000dc000) {
rw = pci_getconfigb(cpssp->confsp, 0x5d) & 0xf;
} else if (0x000dc000 <= addr && addr < 0x000e0000) {
rw = pci_getconfigb(cpssp->confsp, 0x5d) >> 4;
} else if (0x000e0000 <= addr && addr < 0x000e4000) {
rw = pci_getconfigb(cpssp->confsp, 0x5e) & 0xf;
} else if (0x000e4000 <= addr && addr < 0x000e8000) {
rw = pci_getconfigb(cpssp->confsp, 0x5e) >> 4;
} else if (0x000e8000 <= addr && addr < 0x000ec000) {
rw = pci_getconfigb(cpssp->confsp, 0x5f) & 0xf;
} else if (0x000ec000 <= addr && addr < 0x000f0000) {
rw = pci_getconfigb(cpssp->confsp, 0x5f) >> 4;
} else if (0x000f0000 <= addr && addr < 0x00100000) {
/*
* BIOS Area configured by PAM register 0x59.
*/
rw = pci_getconfigb(cpssp->confsp, 0x59) >> 4;
} else {
/*
* High memory.
*/
rw = 3;
}
if ((type == SIG_HOST_BUS_MR && ! (rw & 1))
|| (type == SIG_HOST_BUS_MW && ! (rw & 2))) {
region = REGION_PCI;
}
break;
}
default:
assert(0); /* Cannot happen. */
}
if (orig == ORIG_PCI_BUS
&& region == REGION_PCI) {
region = REGION_NONE;
}
return region;
}
static int
CHIP_(type_addr)(
void *_css,
enum CHIP_(orig) orig,
unsigned int type,
uint32_t addr
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
cpssp->selected = CHIP_(_region)(cpssp, orig, type, 0, addr);
switch (cpssp->selected) {
case REGION_NONE:
/* Do nothing... */
return -1;
case REGION_MEM0 ... REGION_MEM7:
cpssp->selected_addr = addr;
return 0;
case REGION_PM2_CTL:
case REGION_CONFADD:
(void) sig_pci_bus_main_type_addr(
cpssp->port_pci_bus, cpssp,
type, addr);
return 0; /* Might be wrong - FIXME */
case REGION_PCI:
return sig_pci_bus_main_type_addr(
cpssp->port_pci_bus, cpssp,
type, addr);
case REGION_CONFDATA:
if (((cpssp->confadd >> 16) & 0xff) == 0x00) {
/* Config Space Type 0 */
uint32_t bus;
uint32_t dev;
uint32_t reg;
bus = (cpssp->confadd >> 16) & 0xff;
dev = (cpssp->confadd >> 11) & 0x1f;
reg = (cpssp->confadd >> 0) & 0x7fc;
if (dev < 32 - 11) {
dev = 1 << (11 + dev);
} else {
dev = 0;
}
(void) sig_pci_bus_main_type_addr(
cpssp->port_pci_bus, (void *) 0,
type == SIG_HOST_BUS_IOR
? SIG_PCI_BUS_C0R
: SIG_PCI_BUS_C0W,
dev | reg);
return 0;
} else {
/* Config Space Type 1 */
(void) sig_pci_bus_main_type_addr(
cpssp->port_pci_bus, (void *) 0,
type == SIG_HOST_BUS_IOR
? SIG_PCI_BUS_C1R
: SIG_PCI_BUS_C1W,
cpssp->confadd & ~3);
return 0;
}
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(read_data)(
void *_css,
unsigned int bs,
uint32_t *datap
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
int ret;
switch (cpssp->selected) {
case REGION_NONE:
ret = -1;
break;
case REGION_MEM0 ... REGION_MEM7:
ret = sig_cs_read(
cpssp->sig_mem_cs[cpssp->selected - REGION_MEM0],
cpssp,
cpssp->selected_addr, bs, datap);
break;
case REGION_PM2_CTL:
case REGION_CONFADD:
case REGION_CONFDATA:
case REGION_PCI:
ret = sig_pci_bus_main_read_data(
cpssp->port_pci_bus, (void *) 0,
bs, datap);
break;
default:
assert(0); /* Cannot happen. */
}
switch (cpssp->selected) {
case REGION_PM2_CTL:
ret &= CHIP_(pm2_ctl_read)(cpssp, bs, datap);
break;
case REGION_CONFADD:
ret &= CHIP_(confadd_read)(cpssp, bs, datap);
break;
default:
break;
}
return ret;
}
static int
CHIP_(write_data)(
void *_css,
unsigned int bs,
uint32_t data
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
int ret;
switch (cpssp->selected) {
case REGION_NONE:
ret = -1;
break;
case REGION_MEM0 ... REGION_MEM7:
ret = sig_cs_write(
cpssp->sig_mem_cs[cpssp->selected - REGION_MEM0],
cpssp,
cpssp->selected_addr, bs, data);
break;
case REGION_PM2_CTL:
case REGION_CONFADD:
case REGION_CONFDATA:
case REGION_PCI:
ret = sig_pci_bus_main_write_data(
cpssp->port_pci_bus, (void *) 0,
bs, data);
break;
default:
assert(0); /* Cannot happen. */
}
switch (cpssp->selected) {
case REGION_PM2_CTL:
ret &= CHIP_(pm2_ctl_write)(cpssp, bs, data);
break;
case REGION_CONFADD:
ret &= CHIP_(confadd_write)(cpssp, bs, data);
break;
default:
break;
}
return ret;
}
static int
CHIP_(ior)(
void *_css,
uint32_t port,
unsigned int bs,
uint32_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
switch (CHIP_(_region)(cpssp,
ORIG_HOST_BUS, SIG_HOST_BUS_IOR, 0, port)) {
case REGION_NONE:
return -1;
case REGION_PM2_CTL:
return sig_pci_bus_ior(cpssp->port_pci_bus, cpssp,
port, bs, valp)
& CHIP_(pm2_ctl_read)(cpssp, bs, valp);
case REGION_CONFADD:
return sig_pci_bus_ior(cpssp->port_pci_bus, cpssp,
port, bs, valp)
& CHIP_(confadd_read)(cpssp, bs, valp);
case REGION_CONFDATA: {
/*
* Configuration Data Register
*/
uint32_t bus;
uint32_t dev;
uint32_t addr;
bus = (cpssp->confadd >> 16) & 0xff;
dev = (cpssp->confadd >> 11) & 0x1f;
if (bus == 0) {
/* Generate Type 0 configuration cycle. */
addr = cpssp->confadd & 0x7fc;
if (dev < 21) {
return sig_pci_bus_main_c0r(
cpssp->port_pci_bus,
(void *) 0, /* FIXME */
(1 << (11 + dev)) | addr,
bs, valp);
} else {
*valp = 0xffffffff;
return 0;
}
} else {
/* Generate Type 1 configuration cycle. */
addr = cpssp->confadd & ~3;
return sig_pci_bus_c1r(cpssp->port_pci_bus,
cpssp, addr, bs, valp);
}
}
case REGION_PCI:
/*
* Forward to PCI bus.
*/
return sig_pci_bus_ior(cpssp->port_pci_bus, cpssp,
port, bs, valp);
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(iow)(
void *_css,
uint32_t port,
unsigned int bs,
uint32_t val
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
switch (CHIP_(_region)(cpssp,
ORIG_HOST_BUS, SIG_HOST_BUS_IOW, 0, port)) {
case REGION_NONE:
return -1;
case REGION_PM2_CTL:
return sig_pci_bus_iow(cpssp->port_pci_bus, cpssp,
port, bs, val)
& CHIP_(pm2_ctl_write)(cpssp, bs, val);
case REGION_CONFADD:
return sig_pci_bus_iow(cpssp->port_pci_bus, cpssp,
port, bs, val)
& CHIP_(confadd_write)(cpssp, bs, val);
case REGION_CONFDATA: {
/*
* Configuration Data Register
*/
uint32_t bus;
uint32_t dev;
uint32_t addr;
bus = (cpssp->confadd >> 16) & 0xff;
dev = (cpssp->confadd >> 11) & 0x1f;
if (bus == 0) {
/* Generate Type 0 configuration cycle. */
addr = cpssp->confadd & 0x7fc;
if (dev < 21) {
return sig_pci_bus_main_c0w(
cpssp->port_pci_bus,
(void *) 0, /* FIXME */
(1 << (11 + dev)) | addr,
bs, val);
} else {
return 0;
}
} else {
/* Generate Type 1 configuration cycle. */
addr = cpssp->confadd & ~3;
return sig_pci_bus_c1w(cpssp->port_pci_bus,
cpssp, addr, bs, val);
}
}
case REGION_PCI:
/*
* Forward to PCI bus.
*/
return sig_pci_bus_iow(cpssp->port_pci_bus, cpssp,
port, bs, val);
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(ior_info)(
struct cpssp *cpssp,
enum CHIP_(orig) orig,
uint32_t port,
unsigned int bs,
int (**cf)(void *, uint32_t, unsigned int, uint32_t *),
void **cs
)
{
switch (CHIP_(_region)(cpssp, orig, SIG_HOST_BUS_IOR, 0, port)) {
case REGION_PM2_CTL:
case REGION_CONFADD:
case REGION_CONFDATA:
*cf = CHIP_(ior);
*cs = cpssp;
return 0;
case REGION_PCI:
return sig_pci_bus_ior_info(cpssp->port_pci_bus, cpssp,
port, bs, cf, cs);
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(iow_info)(
struct cpssp *cpssp,
enum CHIP_(orig) orig,
uint32_t port,
unsigned int bs,
int (**cf)(void *, uint32_t, unsigned int, uint32_t),
void **cs
)
{
switch (CHIP_(_region)(cpssp, orig, SIG_HOST_BUS_IOW, 0, port)) {
case REGION_PM2_CTL:
case REGION_CONFADD:
case REGION_CONFDATA:
*cf = CHIP_(iow);
*cs = cpssp;
return 0;
case REGION_PCI:
return sig_pci_bus_iow_info(cpssp->port_pci_bus, cpssp,
port, bs, cf, cs);
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(mem_read)(
void *_css,
enum CHIP_(orig) orig,
unsigned int smm,
uint32_t addr,
unsigned int bs,
uint32_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
cpssp->selected = CHIP_(_region)(cpssp, orig,
SIG_HOST_BUS_MR, smm, addr);
cpssp->selected_addr = addr;
switch (cpssp->selected) {
case REGION_NONE:
return -1;
case REGION_MEM0 ... REGION_MEM7:
return sig_cs_read(cpssp->sig_mem_cs[cpssp->selected - REGION_MEM0],
cpssp, cpssp->selected_addr, bs, valp);
case REGION_PCI:
return sig_pci_bus_mr(cpssp->port_pci_bus, cpssp,
cpssp->selected_addr, bs, valp);
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(mem_write)(
void *_css,
enum CHIP_(orig) orig,
unsigned int smm,
uint32_t addr,
unsigned int bs,
uint32_t val
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
cpssp->selected = CHIP_(_region)(cpssp,
orig, SIG_HOST_BUS_MW, smm, addr);
cpssp->selected_addr = addr;
switch (cpssp->selected) {
case REGION_NONE:
return -1;
case REGION_MEM0 ... REGION_MEM7:
return sig_cs_write(cpssp->sig_mem_cs[cpssp->selected - REGION_MEM0],
cpssp, cpssp->selected_addr, bs, val);
case REGION_PCI:
return sig_pci_bus_mw(cpssp->port_pci_bus, cpssp,
cpssp->selected_addr, bs, val);
default:
assert(0); /* Cannot happen. */
}
}
static int
CHIP_(map_r)(
void *_css,
enum CHIP_(orig) orig,
unsigned int smm,
unsigned long addr,
char **haddr_p
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
enum CHIP_(region) region;
char *haddr_dummy;
int ret;
region = CHIP_(_region)(cpssp, orig, SIG_HOST_BUS_MR, smm, addr);
switch (region) {
case REGION_NONE:
ret = 1;
break;
case REGION_MEM0 ... REGION_MEM7:
/* Forward to memory. */
ret = sig_cs_map(cpssp->sig_mem_cs[region - REGION_MEM0],
cpssp, addr, haddr_p, &haddr_dummy);
break;
case REGION_PCI:
/* Forward to PCI bus. */
ret = sig_pci_bus_map_r(cpssp->port_pci_bus, cpssp, addr,
haddr_p);
break;
default:
assert(0); /* Cannot happen. */
}
if (ret != 0) {
*haddr_p = NULL;
}
return 0;
}
static int
CHIP_(map_w)(
void *_css,
enum CHIP_(orig) orig,
unsigned int smm,
unsigned long addr,
char **haddr_p
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
enum CHIP_(region) region;
char *haddr_dummy;
int ret;
region = CHIP_(_region)(cpssp, orig, SIG_HOST_BUS_MW, smm, addr);
switch (region) {
case REGION_NONE:
ret = -1;
break;
case REGION_MEM0 ... REGION_MEM7:
/* Forward to memory. */
ret = sig_cs_map(cpssp->sig_mem_cs[region - REGION_MEM0],
cpssp, addr, &haddr_dummy, haddr_p);
break;
case REGION_PCI:
/* Forward to PCI bus. */
ret = sig_pci_bus_map_w(cpssp->port_pci_bus, cpssp, addr,
haddr_p);
break;
default:
assert(0); /* Cannot happen. */
}
if (ret != 0) {
*haddr_p = NULL;
}
return 0;
}
/* ----------------------------------------------------------------- */
/* Host Bus Interface */
/* ----------------------------------------------------------------- */
static int
CHIP_(host_bus_type_addr)(
void *_css,
unsigned int type,
uint32_t addr
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(type_addr)(cpssp, ORIG_HOST_BUS, type, addr);
}
static int
CHIP_(host_bus_read_data)(
void *_css,
unsigned int bs,
uint32_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(read_data)(cpssp, bs, valp);
}
static int
CHIP_(host_bus_write_data)(
void *_css,
unsigned int bs,
uint32_t val
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(write_data)(cpssp, bs, val);
}
static int
CHIP_(host_bus_ior)(
void *_css,
uint32_t port,
unsigned int bs,
uint32_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(ior)(cpssp, port, bs, valp);
}
static int
CHIP_(host_bus_iow)(
void *_css,
uint32_t port,
unsigned int bs,
uint32_t val
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(iow)(cpssp, port, bs, val);
}
static int
CHIP_(host_bus_ior_info)(
void *_css,
uint32_t port,
unsigned int bs,
int (**cf)(void *, uint32_t, unsigned int, uint32_t *),
void **cs
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(ior_info)(cpssp, ORIG_HOST_BUS, port, bs, cf, cs);
}
static int
CHIP_(host_bus_iow_info)(
void *_css,
uint32_t port,
unsigned int bs,
int (**cf)(void *, uint32_t, unsigned int, uint32_t),
void **cs
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(iow_info)(cpssp, ORIG_HOST_BUS, port, bs, cf, cs);
}
static int
CHIP_(host_bus_inta_addr)(
void *_css
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return sig_pci_bus_inta_addr(cpssp->port_pci_bus, cpssp);
}
static int
CHIP_(host_bus_inta_data)(
void *_css,
uint8_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return sig_pci_bus_inta_data(cpssp->port_pci_bus, cpssp, valp);
}
static int
CHIP_(host_bus_mr)(
void *_css,
unsigned int smm,
uint32_t addr,
unsigned int bs,
uint32_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(mem_read)(cpssp, ORIG_HOST_BUS,
smm, addr, bs, valp);
}
static int
CHIP_(host_bus_mw)(
void *_css,
unsigned int smm,
uint32_t addr,
unsigned int bs,
uint32_t val
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(mem_write)(cpssp, ORIG_HOST_BUS,
smm, addr, bs, val);
}
/* Re-used as CHIP_(host_bus_map_x_check). */
static int
CHIP_(host_bus_map_r_check)(
void *_css,
unsigned int smm,
unsigned long pa
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
/* SMM? FIXME */
return sig_pci_bus_map_r_check(cpssp->port_pci_bus, cpssp, pa);
}
/* Re-used as CHIP_(host_bus_map_x). */
static int
CHIP_(host_bus_map_r)(
void *_css,
unsigned int smm,
unsigned long pa,
char **haddr_p
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(map_r)(cpssp, ORIG_HOST_BUS, smm, pa, haddr_p);
}
static int
CHIP_(host_bus_map_w_check)(
void *_css,
unsigned int smm,
unsigned long pa
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
/* SMM? FIXME */
return sig_pci_bus_map_w_check(cpssp->port_pci_bus, cpssp, pa);
}
static int
CHIP_(host_bus_map_w)(
void *_css,
unsigned int smm,
unsigned long pa,
char **haddr_p
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(map_w)(cpssp, ORIG_HOST_BUS, smm, pa, haddr_p);
}
/* ----------------------------------------------------------------- */
/* MEM Bus Interface */
/* ----------------------------------------------------------------- */
static int
CHIP_(memX_unmap)(void *_css, unsigned long pa, unsigned long len)
{
struct cpssp *cpssp = (struct cpssp *) _css;
/* Should unmap interval [pa, pa + len) only - FIXME VOSSI */
sig_host_bus_unmap(cpssp->port_host_bus, cpssp, 0, 1024*1024*1024);
sig_pci_bus_unmap(cpssp->port_pci_bus, cpssp, 0, 1024*1024*1024);
return 0;
}
/* ----------------------------------------------------------------- */
/* PCI Bus Interface */
/* ----------------------------------------------------------------- */
static int
CHIP_(pci_bus_mr)(
void *_css,
uint32_t addr,
unsigned int bs,
uint32_t *valp
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(mem_read)(cpssp, ORIG_PCI_BUS,
0, addr, bs, valp);
}
static int
CHIP_(pci_bus_mw)(
void *_css,
uint32_t addr,
unsigned int bs,
uint32_t val
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(mem_write)(cpssp, ORIG_PCI_BUS,
0, addr, bs, val);
}
static int
CHIP_(pci_bus_map_r_check)(
void *_css,
unsigned long pa
)
{
struct cpssp *cpssp = _css;
/* SMM? FIXME */
return sig_host_bus_map_r_check(cpssp->port_host_bus, cpssp, 0, pa);
}
static int
CHIP_(pci_bus_map_r)(
void *_css,
unsigned long pa,
char **haddr_p
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(map_r)(cpssp, ORIG_PCI_BUS, 0, pa, haddr_p);
}
static int
CHIP_(pci_bus_map_w_check)(
void *_css,
unsigned long pa
)
{
struct cpssp *cpssp = _css;
/* SMM? FIXME */
return sig_host_bus_map_w_check(cpssp->port_host_bus, cpssp, 0, pa);
}
static int
CHIP_(pci_bus_map_w)(
void *_css,
unsigned long pa,
char **haddr_p
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
return CHIP_(map_w)(cpssp, ORIG_PCI_BUS, 0, pa, haddr_p);
}
static void
CHIP_(pci_bus_unmap)(
void *_css,
unsigned long pa,
unsigned long len
)
{
struct cpssp *cpssp = (struct cpssp *) _css;
sig_host_bus_unmap(cpssp->port_host_bus, cpssp, pa, len);
}
/* ----------------------------------------------------------------- */
/* Config Space Interface */
/* ----------------------------------------------------------------- */
/*
* This are helper functions - all config spaces writes, no matter if they
* are byte, word or long accesses, get mapped to this.
*/
static void
CHIP_(_pci_bus_cwriteb)(
struct cpssp *cpssp,
unsigned char addr,
unsigned char val
)
{
unsigned char oldval;
switch (addr) {
case 0x00 ... 0x3f:
/*
* Writing to reserved config space registers *below* 0x40
* is allowed. Value written is discarded.
*/
/* Nothing to do... */
break;
/* NBX Configuration Register */
/* 3-16 */
case 0x50: /* Bit 7-0 */
val &= 0xec; /* Mask "reserved" bits */
pci_setconfigb(cpssp->confsp, addr, val);
break;
case 0x51: /* Bit 15-8 */
val &= 0xbf; /* Mask "reserved" bits */
pci_setconfigb(cpssp->confsp, addr, val);
break;
case 0x52: /* Bit 23-16 */
val &= 0x07; /* Mask "reserved" bits */
pci_setconfigb(cpssp->confsp, addr, val);
break;
case 0x53: /* Bit 31-24 */
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* DRAM Control Register */
/* 3-19 */
case 0x57:
/* Just remember settings. Not used by simulation. */
val &= 0x3f;
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* DRAM Timing Register */
/* 3-20 */
case 0x58:
/* Just remember settings. Not used by simulation. */
val &= 0x3; /* Mask "reserved" bits */
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* Programmable Attribute Map Register */
/* 3-20 */
case 0x59:
val &= 0x30; /* Mask "reserved" bits */
oldval = pci_getconfigb(cpssp->confsp, addr);
if (val != oldval) {
pci_setconfigb(cpssp->confsp, addr, val);
sig_host_bus_unmap(cpssp->port_host_bus, cpssp,
0x000f0000, 0x00010000);
sig_pci_bus_unmap(cpssp->port_pci_bus, cpssp,
0x000f0000, 0x00010000);
if (DEBUG_CHIPSET) {
faum_log(FAUM_LOG_DEBUG, "82443LX", "", \
"Changed PAM register 0x%x to 0x%x\n",
addr, val);
}
}
break;
/* Programmable Attribute Map Registers */
/* 3-20 */
case 0x5a ... 0x5f:
val &= 0x33; /* Mask "reserved" bits */
oldval = pci_getconfigb(cpssp->confsp, addr);
if (val != oldval) {
pci_setconfigb(cpssp->confsp, addr, val);
sig_host_bus_unmap(cpssp->port_host_bus, cpssp,
0x000c0000 + (addr - 0x5a) * 0x8000, 0x8000);
sig_pci_bus_unmap(cpssp->port_pci_bus, cpssp,
0x000c0000 + (addr - 0x5a) * 0x8000, 0x8000);
if (DEBUG_CHIPSET) {
faum_log(FAUM_LOG_DEBUG, "82443LX", "", \
"Changed PAM register 0x%x to 0x%x\n",
addr, val);
}
}
break;
/* DRAM Row Boundary Register */
/* 3-22 */
case 0x60 ... 0x67:
oldval = pci_getconfigb(cpssp->confsp, addr);
pci_setconfigb(cpssp->confsp, addr, val);
if (val != oldval) {
sig_host_bus_unmap(cpssp->port_host_bus, cpssp,
0x00000000, 0x40000000);
sig_pci_bus_unmap(cpssp->port_pci_bus, cpssp,
0x00000000, 0x40000000);
}
break;
/* Fixed DRAM Hole Control Register */
/* 3-24 */
case 0x68:
val &= 0xc0; /* Mask "reserved" bits. */
if (val != 0) {
/* FIXME */
fixme();
}
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* Memory Buffer Strength Control Register */
/* 3-25 */
case 0x69 ... 0x6e:
/* Just remember settings. Not used by simulation. */
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* System Management RAM Control Register */
/* 3-28 */
case 0x72:
val &= 0x78; /* mask "reserved" bit 7 and readonly bits 2:0 */
val |= 0x02; /* bits 2:0 hardwired to '010' */
oldval = pci_getconfigb(cpssp->confsp, addr);
if (oldval & (1 << 4) /* D_LCK */) {
/* if D_LCK is set, D_OPEN can't be set any more;
* D_LCK can only be cleared by a power-on reset */
val &= ~(1 << 6); /* D_OPEN */
val |= (1 << 4); /* D_LCK */
}
if (val != oldval) {
if (DEBUG_SMRAM) {
faum_log(FAUM_LOG_DEBUG, "82443LX", "",
"Writing 0x%02x to SMRAM "
"Control (was 0x%02x)\n", val, oldval);
}
pci_setconfigb(cpssp->confsp, addr, val);
/* SMRAM mapping may have changed */
sig_host_bus_unmap(cpssp->port_host_bus, cpssp,
0x000a0000, 0x00020000);
sig_pci_bus_unmap(cpssp->port_pci_bus, cpssp,
0x000a0000, 0x00020000);
}
break;
/* Extended System Management RAM Control Register */
/* 3-29 */
case 0x73:
goto unimplemented;
/* SDRAM Row Page Size Register */
/* 3-30 */
case 0x74 ... 0x75:
goto unimplemented;
/* SDRAM Control Register */
/* 3-30 */
case 0x76 ... 0x77:
goto unimplemented;
/* Paging Policy Register */
/* 3-32 */
case 0x78 ... 0x79:
goto unimplemented;
/* Power Management Control Register */
/* 3-33 */
case 0x7A:
val &= ~0x02; /* Bit 1 is read only */
pci_setconfigb(cpssp->confsp, addr, val);
sig_host_bus_ior_info_flush(cpssp->port_host_bus, cpssp,
0x0020, 1 << 2);
sig_host_bus_iow_info_flush(cpssp->port_host_bus, cpssp,
0x0020, 1 << 2);
break;
/* Suspend CBR Refresh Rate Register */
/* 3-34 */
case 0x7b ... 0x7c:
goto unimplemented;
/* Error Address Pointer Register */
/* 3-35 */
case 0x80 ... 0x83:
goto unimplemented;
/* Error Command Register */
/* 3-36 */
case 0x90:
/* Just remember settings. Not used by simulation. */
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* Error Status Register */
/* 3-37 */
case 0x91 ... 0x92:
/* As we don't set any error bits we don't need to
* reset them... */
break;
/* AGP Capability Identifier Register */
/* 3-38 */
case 0xa0 ... 0xa3:
goto unimplemented;
/* AGP Status Register */
/* 3-38 */
case 0xa4 ... 0xa7:
goto unimplemented;
/* AGP Command Register */
/* 3-39 */
case 0xa8 ... 0xab:
goto unimplemented;
/* AGP Control Register */
/* 3-40 */
case 0xb0 ... 0xb3:
goto unimplemented;
/* Aperture Size Register */
/* 3-41 */
case 0xb4:
val &= 0x3f; /* Masking "reserved" bits. */
pci_setconfigb(cpssp->confsp, addr, val);
break;
/* Aperture Translation Table Base Register */
/* 3-41 */
case 0xb8 ... 0xbb:
goto unimplemented;
/* Memory Buffer Frequency Select Register */
/* 3-42 */
case 0xca ... 0xcc:
goto unimplemented;
/* BIOS Scratch Pad Register */
/* 3-44 */
case 0xd0 ... 0xd7:
goto unimplemented;
/* DRAM Write Thermal Throttling Control Register */
/* 3-44 */
/* Just remember settings. Not used by simulation. */
case 0xe0: /* Bit 7-0 */
case 0xe1: /* Bit 15-8 */
case 0xe2: /* Bit 23-16 */
case 0xe3: /* Bit 31-24 */
case 0xe4: /* Bit 39-32 */
if (! ((pci_getconfigb(cpssp->confsp, 0xe7) >> 7) & 1)) {
pci_setconfigb(cpssp->confsp, addr, val);
}
break;
case 0xe5: /* Bit 47-40 */
if (! ((pci_getconfigb(cpssp->confsp, 0xe7) >> 7) & 1)) {
val &= 0x3f; /* Masking "reserved" bits. */
pci_setconfigb(cpssp->confsp, addr, val);
}
break;
case 0xe6: /* Bit 55-48 */
/* All bits "reserved". */
break;
case 0xe7: /* Bit 63-56 */
if (! ((pci_getconfigb(cpssp->confsp, 0xe7) >> 7) & 1)) {
val &= 0x80; /* Masking "reserved" bits. */
pci_setconfigb(cpssp->confsp, addr, val);
}
break;
/* DRAM Read Thermal Throttling Control Register */
/* 3-46 */
/* Just remember settings. Not used by simulation. */
case 0xe8: /* Bit 7-0 */
case 0xe9: /* Bit 15-8 */
case 0xea: /* Bit 23-16 */
case 0xeb: /* Bit 31-24 */
case 0xec: /* Bit 39-32 */
if (! ((pci_getconfigb(cpssp->confsp, 0xe7) >> 7) & 1)) {
pci_setconfigb(cpssp->confsp, addr, val);
}
break;
case 0xed: /* Bit 47-40 */
if (! ((pci_getconfigb(cpssp->confsp, 0xe7) >> 7) & 1)) {
val &= 0x3f; /* Masking "reserved" bits. */
pci_setconfigb(cpssp->confsp, addr, val);
}
break;
case 0xee: /* Bit 55-48 */
case 0xef: /* Bit 63-56 */
/* All bits "reserved". */
break;
/* Buffer Control Register */
/* 3-47 */
case 0xf0 ... 0xf1:
goto unimplemented;
unimplemented:;
faum_log(FAUM_LOG_WARNING, "82443LX (Host Controller)", "",
"Writing 0x%02x to unimplemented register 0x%02x.\n",
val, addr);
break;
default:
faum_log(FAUM_LOG_WARNING, "82443LX (Host Controller)", "",
"Writing 0x%02x to reserved register 0x%02x.\n",
val, addr);
break;
}
}
static int
CHIP_(c0w)(void *_css, uint32_t addr, unsigned int bs, uint32_t val)
{
struct cpssp *cpssp = (struct cpssp *) _css;
if ((addr >> 11) & 1) {
/* Host/PCI Bridge */
if ((bs >> 0) & 1) {
CHIP_(_pci_bus_cwriteb)(cpssp,
(addr + 0) & 0xff, (val >> 0) & 0xff);
}
if ((bs >> 1) & 1) {
CHIP_(_pci_bus_cwriteb)(cpssp,
(addr + 1) & 0xff, (val >> 8) & 0xff);
}
if ((bs >> 2) & 1) {
CHIP_(_pci_bus_cwriteb)(cpssp,
(addr + 2) & 0xff, (val >> 16) & 0xff);
}
if ((bs >> 3) & 1) {
CHIP_(_pci_bus_cwriteb)(cpssp,
(addr + 3) & 0xff, (val >> 24) & 0xff);
}
return 0;
} else if ((addr >> 12) & 1) {
/* AGP - FIXME VOSSI */
return -1;
} else {
return -1;
}
}
static int
CHIP_(c0r)(void *_css, uint32_t addr, unsigned int bs, uint32_t *valp)
{
struct cpssp *cpssp = (struct cpssp *) _css;
if (((addr >> 11) & 1) /* Device 0 */
&& ((addr >> 8) & 7) == 0) { /* Function 0 */
/* Host/PCI Bridge */
if ((bs >> 0) & 1) {
*valp &= ~(0xff << 0);
*valp |= pci_getconfigb(cpssp->confsp,
(addr + 0) & 0xff) << 0;
}
if ((bs >> 1) & 1) {
*valp &= ~(0xff << 8);
*valp |= pci_getconfigb(cpssp->confsp,
(addr + 1) & 0xff) << 8;
}
if ((bs >> 2) & 1) {
*valp &= ~(0xff << 16);
*valp |= pci_getconfigb(cpssp->confsp,
(addr + 2) & 0xff) << 16;
}
if ((bs >> 3) & 1) {
*valp &= ~(0xff << 24);
*valp |= pci_getconfigb(cpssp->confsp,
(addr + 3) & 0xff) << 24;
}
return 0;
} else if (((addr >> 12) & 1) /* Device 1 */
&& ((addr >> 8) & 7) == 0) { /* Function 0 */
/* AGP - FIXME VOSSI */
return -1;
} else {
return -1;
}
}
static void
CHIP_(power_set)(void *_css, unsigned int val)
{
/* FIXME */
}
static void
CHIP_(n_reset_set)(void *_css, unsigned int n_val)
{
struct cpssp *cpssp = (struct cpssp *) _css;
int i;
/* Set PAM to default */
for (i = 0x59; i < 0x5f; i++) {
pci_setconfigb(cpssp->confsp, i, 0x00);
}
for (i = 0x60; i < 0x68; i++) {
pci_setconfigb(cpssp->confsp, i, 0x01);
}
/* SMRAM register defaults to 0x02 on reset */
pci_setconfigb(cpssp->confsp, 0x72, 0x02);
}
/* ----------------------------------------------------------------- */
/* Init Function */
/* ----------------------------------------------------------------- */
void *
CHIP_(create)(
const char *name,
struct sig_manage *port_manage,
struct sig_boolean *port_power,
struct sig_boolean *port_reset_hash_,
struct sig_host_bus_main *port_host_bus,
struct sig_cs *port_mem_cs0,
struct sig_cs *port_mem_cs1,
struct sig_cs *port_mem_cs2,
struct sig_cs *port_mem_cs3,
struct sig_cs *port_mem_cs4,
struct sig_cs *port_mem_cs5,
struct sig_cs *port_mem_cs6,
struct sig_cs *port_mem_cs7,
struct sig_mem_bus_main *port_mem,
struct sig_pci_bus_main *port_pci_bus,
struct sig_pci_bus_idsel *port_idsel,
struct sig_agp_bus_main *port_agp_bus,
struct sig_pci_bus_idsel *port_gidsel
)
{
static const struct sig_boolean_funcs power_funcs = {
.set = CHIP_(power_set),
};
static const struct sig_boolean_funcs reset_hash__funcs = {
.set = CHIP_(n_reset_set),
};
static const struct sig_host_bus_main_funcs host_bus_funcs = {
.type_addr = CHIP_(host_bus_type_addr),
.read_data = CHIP_(host_bus_read_data),
.write_data = CHIP_(host_bus_write_data),
.ior = CHIP_(host_bus_ior),
.iow = CHIP_(host_bus_iow),
.ior_info = CHIP_(host_bus_ior_info),
.iow_info = CHIP_(host_bus_iow_info),
.mr = CHIP_(host_bus_mr),
.mw = CHIP_(host_bus_mw),
.map_r_check = CHIP_(host_bus_map_r_check),
.map_r = CHIP_(host_bus_map_r),
.map_w_check = CHIP_(host_bus_map_w_check),
.map_w = CHIP_(host_bus_map_w),
.map_x_check = CHIP_(host_bus_map_r_check), /* ! */
.map_x = CHIP_(host_bus_map_r), /* ! */
.inta_addr = CHIP_(host_bus_inta_addr),
.inta_data = CHIP_(host_bus_inta_data),
#if 0 /* Not used yet. */
.unmap = CHIP_(host_bus_unmap),
#endif
};
static const struct sig_cs_funcs mem_cs0_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs1_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs2_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs3_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs4_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs5_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs6_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_cs_funcs mem_cs7_funcs = {
.unmap = CHIP_(memX_unmap),
};
static const struct sig_pci_bus_main_funcs pci_bus_funcs = {
.mr = CHIP_(pci_bus_mr),
.mw = CHIP_(pci_bus_mw),
.map_r_check = CHIP_(pci_bus_map_r_check),
.map_r = CHIP_(pci_bus_map_r),
.map_w_check = CHIP_(pci_bus_map_w_check),
.map_w = CHIP_(pci_bus_map_w),
#if 0 /* Not used yet. */
.ack = CHIP_(pci_bus_ack),
#endif
.unmap = CHIP_(pci_bus_unmap),
};
static const struct sig_pci_bus_idsel_funcs idsel_funcs = {
.c0r = CHIP_(c0r),
.c0w = CHIP_(c0w),
};
struct cpssp *cpssp;
cpssp = malloc(sizeof(*cpssp));
assert(cpssp);
/* initialize PCI config space */
memset(cpssp->confsp, 0, 0x100);
pci_setconfigw(cpssp->confsp, PCI_VENDOR_ID, PCI_VENDOR_ID_INTEL);
/* Set device ID for LX chipset with AGP disabled */
pci_setconfigw(cpssp->confsp, PCI_DEVICE_ID, 0x7180);
pci_setconfigw(cpssp->confsp, PCI_COMMAND, 0x0006);
pci_setconfigw(cpssp->confsp, PCI_STATUS, 0x2210);
pci_setconfigb(cpssp->confsp, PCI_REVISION_ID, 0x03);
pci_setconfigw(cpssp->confsp, PCI_CLASS_DEVICE, PCI_CLASS_BRIDGE_HOST);
pci_setconfigb(cpssp->confsp, PCI_LATENCY_TIMER, 0x40);
pci_setconfigl(cpssp->confsp, PCI_BASE_ADDRESS_0, 0x00000008);
/* Out */
/* Call */
cpssp->port_host_bus = port_host_bus;
sig_host_bus_main_connect(port_host_bus, cpssp, &host_bus_funcs);
cpssp->sig_mem_cs[0] = port_mem_cs0;
sig_cs_connect(port_mem_cs0, cpssp, &mem_cs0_funcs);
cpssp->sig_mem_cs[1] = port_mem_cs1;
sig_cs_connect(port_mem_cs1, cpssp, &mem_cs1_funcs);
cpssp->sig_mem_cs[2] = port_mem_cs2;
sig_cs_connect(port_mem_cs2, cpssp, &mem_cs2_funcs);
cpssp->sig_mem_cs[3] = port_mem_cs3;
sig_cs_connect(port_mem_cs3, cpssp, &mem_cs3_funcs);
cpssp->sig_mem_cs[4] = port_mem_cs4;
sig_cs_connect(port_mem_cs4, cpssp, &mem_cs4_funcs);
cpssp->sig_mem_cs[5] = port_mem_cs5;
sig_cs_connect(port_mem_cs5, cpssp, &mem_cs5_funcs);
cpssp->sig_mem_cs[6] = port_mem_cs6;
sig_cs_connect(port_mem_cs6, cpssp, &mem_cs6_funcs);
cpssp->sig_mem_cs[7] = port_mem_cs7;
sig_cs_connect(port_mem_cs7, cpssp, &mem_cs7_funcs);
cpssp->port_pci_bus = port_pci_bus;
sig_pci_bus_main_connect(port_pci_bus, cpssp, &pci_bus_funcs);
cpssp->port_idsel = port_idsel;
sig_pci_bus_idsel_connect(port_idsel, cpssp, &idsel_funcs);
cpssp->port_agp_bus = port_agp_bus;
/* FIXME */
cpssp->port_gidsel = port_gidsel;
/* FIXME */
/* In */
sig_boolean_connect_in(port_power, cpssp, &power_funcs);
sig_boolean_connect_in(port_reset_hash_, cpssp, &reset_hash__funcs);
return cpssp;
}
void
CHIP_(destroy)(void *_cpssp)
{
struct cpssp *cpssp = _cpssp;
free(cpssp);
}
|