239 if ((buf_end - *buf) >= num_words) {
243 DRM_ERROR(
"Illegal termination of DMA command buffer\n");
256 struct drm_map_list *r_list;
259 if (map && map->offset <= offset
260 && (offset + size) <= (map->offset + map->size)) {
268 if (map->offset <= offset
269 && (offset + size) <= (map->offset + map->size)
292 DRM_DEBUG(
"Z Buffer start address is 0x%x\n", cur_seq->
z_addr);
295 DRM_DEBUG(
"Destination start address is 0x%x\n",
303 unsigned long lo = ~0,
hi = 0,
tmp;
318 for (i = start; i <=
end; ++
i) {
323 tmp += (*height++ * *pitch++);
325 tmp += (*height++ << *pitch++);
330 if (!via_drm_lookup_agp_map
331 (cur_seq, lo, hi - lo, cur_seq->
dev)) {
333 (
"AGP texture is not in allowed map\n");
352 if ((ret = finish_current_sequence(cur_seq)))
368 DRM_ERROR(
"Illegal DMA HALCYON_HEADER2 command\n");
373 DRM_ERROR(
"Illegal DMA HALCYON_HEADER1 command\n");
378 DRM_ERROR(
"Illegal DMA HALCYON_FIRECMD command\n");
383 DRM_ERROR(
"Illegal DMA HC_DUMMY command\n");
386 if (0xdddddddd == cmd)
388 DRM_ERROR(
"Illegal DMA 0xdddddddd command\n");
398 ((cmd & 0xFF) << 24);
402 if ((cmd & 0x0000C000) == 0)
404 DRM_ERROR(
"Attempt to place Z buffer in system memory\n");
414 ((cmd & 0xFF) << 24);
418 if ((cmd & 0x0000C000) == 0)
421 (
"Attempt to place 3D drawing buffer in system memory\n");
427 *tmp_addr = (*tmp_addr & 0xFF000000) | (cmd & 0x00FFFFFF);
431 tmp = ((cmd >> 24) - 0x20);
434 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF) << 24);
436 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF00) << 16);
438 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF0000) << 8);
457 if (cmd & 0x000FFFFF) {
459 (
"Unimplemented texture level 0 pitch mode.\n");
467 *tmp_addr = (*tmp_addr & 0x00FFFFFF) | ((cmd & 0xFF) << 24);
479 tmp_addr[5] = 1 << ((cmd & 0x00F00000) >> 20);
480 tmp_addr[4] = 1 << ((cmd & 0x000F0000) >> 16);
481 tmp_addr[3] = 1 << ((cmd & 0x0000F000) >> 12);
482 tmp_addr[2] = 1 << ((cmd & 0x00000F00) >> 8);
483 tmp_addr[1] = 1 << ((cmd & 0x000000F0) >> 4);
484 tmp_addr[0] = 1 << (cmd & 0x0000000F);
489 tmp_addr[9] = 1 << ((cmd & 0x0000F000) >> 12);
490 tmp_addr[8] = 1 << ((cmd & 0x00000F00) >> 8);
491 tmp_addr[7] = 1 << ((cmd & 0x000000F0) >> 4);
492 tmp_addr[6] = 1 << (cmd & 0x0000000F);
496 if (2 == (tmp = cmd & 0x00000003)) {
498 (
"Attempt to fetch texture from system memory.\n");
503 (cmd >> 16) & 0x000000007;
512 DRM_ERROR(
"Illegal DMA data: 0x%x\n", cmd);
529 while (buf < buf_end) {
531 if ((buf_end - buf) < 2) {
533 (
"Unexpected termination of primitive list.\n");
541 DRM_ERROR(
"Expected Vertex List A command, got 0x%x\n",
554 if (cur_seq->
agp && ((bcmd & (0xF << 11)) == 0)) {
555 DRM_ERROR(
"Illegal B command vertex data for AGP.\n");
562 dw_count += (cur_seq->
multitex) ? 2 : 1;
564 dw_count += (cur_seq->
multitex) ? 2 : 1;
567 if (bcmd & (1 << 10))
569 if (bcmd & (1 << 11))
571 if (bcmd & (1 << 12))
573 if (bcmd & (1 << 13))
575 if (bcmd & (1 << 14))
578 while (buf < buf_end) {
579 if (*buf == a_fire) {
582 DRM_ERROR(
"Fire offset buffer full.\n");
587 num_fire_offsets++] =
591 if (buf < buf_end && *buf == a_fire)
597 DRM_ERROR(
"Missing Vertex Fire command, "
598 "Stray Vertex Fire command or verifier "
603 if ((ret = eat_words(&buf, buf_end, dw_count)))
606 if (buf >= buf_end && !have_fire) {
607 DRM_ERROR(
"Missing Vertex Fire command or verifier "
612 if (cur_seq->
agp && ((buf - cur_seq->
buf_start) & 0x01)) {
613 DRM_ERROR(
"AGP Primitive list end misaligned.\n");
632 if ((buf_end - buf) < 2) {
634 (
"Illegal termination of DMA HALCYON_HEADER2 sequence.\n");
638 cmd = (*buf++ & 0xFFFF0000) >> 16;
642 if (via_check_prim_list(&buf, buf_end, hc_state))
661 if (eat_words(&buf, buf_end, 2))
666 if (eat_words(&buf, buf_end, 32))
672 DRM_ERROR(
"Texture palettes are rejected because of "
673 "lack of info how to determine their size.\n");
676 DRM_ERROR(
"Fog factor palettes are rejected because of "
677 "lack of info how to determine their size.\n");
686 DRM_ERROR(
"Invalid or unimplemented HALCYON_HEADER2 "
687 "DMA subcommand: 0x%x. Previous dword: 0x%x\n",
693 while (buf < buf_end) {
695 if ((hz = hz_table[cmd >> 24])) {
696 if ((hz_mode = investigate_hazard(cmd, hz, hc_state))) {
704 finish_current_sequence(hc_state)) {
708 if (hc_state->
unfinished && finish_current_sequence(hc_state))
716 const uint32_t *buf_end,
int *fire_count)
725 cmd = (*buf & 0xFFFF0000) >> 16;
729 while ((buf < buf_end) &&
730 (*fire_count < dev_priv->num_fire_offsets) &&
732 while (buf <= next_fire) {
734 (burst & 63), *buf++);
746 while (buf < buf_end) {
755 (burst & 63), *buf++);
765 if ((address > 0x3FF) && (address < 0xC00)) {
766 DRM_ERROR(
"Invalid VIDEO DMA command. "
767 "Attempt to access 3D- or command burst area.\n");
769 }
else if ((address > 0xCFF) && (address < 0x1300)) {
770 DRM_ERROR(
"Invalid VIDEO DMA command. "
771 "Attempt to access PCI DMA area.\n");
773 }
else if (address > 0x13FF) {
774 DRM_ERROR(
"Invalid VIDEO DMA command. "
775 "Attempt to access VGA registers.\n");
787 if (buf_end - buf < dwords) {
788 DRM_ERROR(
"Illegal termination of video command.\n");
793 DRM_ERROR(
"Illegal video command tail.\n");
808 while (buf < buf_end) {
814 DRM_ERROR(
"Invalid HALCYON_HEADER1 command. "
815 "Attempt to access 3D- or command burst area.\n");
821 DRM_ERROR(
"Invalid HALCYON_HEADER1 command. "
822 "Attempt to access VGA registers.\n");
840 while (buf < buf_end) {
844 VIA_WRITE((cmd & ~HALCYON_HEADER1MASK) << 2, *++buf);
857 if (buf_end - buf < 4) {
858 DRM_ERROR(
"Illegal termination of video header5 command\n");
863 if (verify_mmio_address(data))
867 if (*buf++ != 0x00F50000) {
868 DRM_ERROR(
"Illegal header5 header data\n");
871 if (*buf++ != 0x00000000) {
872 DRM_ERROR(
"Illegal header5 header data\n");
875 if (eat_words(&buf, buf_end, data))
877 if ((data & 3) && verify_video_tail(&buf, buf_end, 4 - (data & 3)))
897 buf += 4 - (count & 3);
909 if (buf_end - buf < 4) {
910 DRM_ERROR(
"Illegal termination of video header6 command\n");
915 if (*buf++ != 0x00F60000) {
916 DRM_ERROR(
"Illegal header6 header data\n");
919 if (*buf++ != 0x00000000) {
920 DRM_ERROR(
"Illegal header6 header data\n");
923 if ((buf_end - buf) < (data << 1)) {
924 DRM_ERROR(
"Illegal termination of video header6 command\n");
927 for (i = 0; i <
data; ++
i) {
928 if (verify_mmio_address(*buf++))
933 if ((data & 3) && verify_video_tail(&buf, buf_end, 4 - (data & 3)))
955 buf += 4 - (count & 3);
969 const uint32_t *buf_end = buf + (size >> 2);
986 while (buf < buf_end) {
990 state = via_check_header2(&buf, buf_end, hc_state);
993 state = via_check_header1(&buf, buf_end);
996 state = via_check_vheader5(&buf, buf_end);
999 state = via_check_vheader6(&buf, buf_end);
1014 DRM_ERROR(
"Accelerated 3D is not supported on this chipset yet.\n");
1018 (
"Invalid / Unimplemented DMA HEADER command. 0x%x\n",
1025 *hc_state = saved_state;
1030 *hc_state = saved_state;
1043 const uint32_t *buf_end = buf + (size >> 2);
1047 while (buf < buf_end) {
1052 via_parse_header2(dev_priv, &buf, buf_end,
1056 state = via_parse_header1(dev_priv, &buf, buf_end);
1059 state = via_parse_vheader5(dev_priv, &buf, buf_end);
1062 state = via_parse_vheader6(dev_priv, &buf, buf_end);
1075 (
"Invalid / Unimplemented DMA HEADER command. 0x%x\n",
1095 for (i = 0; i < 256; ++
i)
1098 for (i = 0; i <
size; ++
i)
1099 table[init_table[i].
code] = init_table[i].hz;
1104 setup_hazard_table(init_table1, table1,
1105 sizeof(init_table1) /
sizeof(
hz_init_t));
1106 setup_hazard_table(init_table2, table2,
1107 sizeof(init_table2) /
sizeof(
hz_init_t));
1108 setup_hazard_table(init_table3, table3,
1109 sizeof(init_table3) /
sizeof(
hz_init_t));