Changeset 2f33fbc in mainline for kernel/generic/src/console/cmd.c
- Timestamp:
- 2012-11-23T15:52:03Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00e3ad2, 6e634d6, a801688b
- Parents:
- 894d9ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r894d9ea r2f33fbc 695 695 { 696 696 uint8_t *ptr = NULL; 697 697 698 #ifdef IO_SPACE_BOUNDARY 698 699 if ((void *) argv->intval < IO_SPACE_BOUNDARY) … … 700 701 else 701 702 #endif 702 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),703 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 703 704 PAGE_NOT_CACHEABLE); 705 704 706 const uint8_t val = pio_read_8(ptr); 705 printf("read %"PRIxn": %"PRIx8"\n", argv[0].intval, val); 707 printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val); 708 706 709 #ifdef IO_SPACE_BOUNDARY 707 710 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 708 711 return 1; 709 712 #endif 710 km_unmap((uintptr_t)ptr, sizeof(uint8_t)); 713 714 km_unmap((uintptr_t) ptr, sizeof(uint8_t)); 711 715 return 1; 712 716 } … … 721 725 { 722 726 uint16_t *ptr = NULL; 723 #ifdef IO_SPACE_BOUNDARY 724 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 725 ptr = (void *)argv[0].intval; 726 else 727 #endif 728 ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t), 729 PAGE_NOT_CACHEABLE); 730 const uint16_t val = pio_read_16(ptr); 731 printf("read %"PRIxn": %"PRIx16"\n", argv[0].intval, val); 732 #ifdef IO_SPACE_BOUNDARY 733 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 734 return 1; 735 #endif 736 km_unmap((uintptr_t)ptr, sizeof(uint16_t)); 737 return 1; 738 } 739 740 /** Read 4 bytes from phys memory or io port. 741 * 742 * @param argv Argument vector. 743 * 744 * @return 0 on failure, 1 on success. 745 */ 746 static int cmd_pio_read_32(cmd_arg_t *argv) 747 { 748 uint32_t *ptr = NULL; 727 749 728 #ifdef IO_SPACE_BOUNDARY 750 729 if ((void *) argv->intval < IO_SPACE_BOUNDARY) … … 752 731 else 753 732 #endif 754 ptr = (uint 32_t*)km_map(argv[0].intval, sizeof(uint32_t),733 ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t), 755 734 PAGE_NOT_CACHEABLE); 756 const uint32_t val = pio_read_32(ptr); 757 printf("read %"PRIxn": %"PRIx32"\n", argv[0].intval, val); 735 736 const uint16_t val = pio_read_16(ptr); 737 printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val); 738 758 739 #ifdef IO_SPACE_BOUNDARY 759 740 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 760 741 return 1; 761 742 #endif 762 km_unmap((uintptr_t)ptr, sizeof(uint32_t)); 763 return 1; 764 } 765 766 /** Write 1 byte to phys memory or io port. 743 744 km_unmap((uintptr_t) ptr, sizeof(uint16_t)); 745 return 1; 746 } 747 748 /** Read 4 bytes from phys memory or io port. 767 749 * 768 750 * @param argv Argument vector. … … 770 752 * @return 0 on failure, 1 on success. 771 753 */ 772 static int cmd_pio_write_8(cmd_arg_t *argv) 773 { 774 uint8_t *ptr = NULL; 754 static int cmd_pio_read_32(cmd_arg_t *argv) 755 { 756 uint32_t *ptr = NULL; 757 775 758 #ifdef IO_SPACE_BOUNDARY 776 759 if ((void *) argv->intval < IO_SPACE_BOUNDARY) … … 778 761 else 779 762 #endif 780 ptr = (uint 8_t*)km_map(argv[0].intval, sizeof(uint8_t),763 ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t), 781 764 PAGE_NOT_CACHEABLE); 782 printf("write %"PRIxn": %"PRIx8"\n", argv[0].intval, 783 (uint8_t)argv[1].intval); 784 pio_write_8(ptr, (uint8_t)argv[1].intval); 765 766 const uint32_t val = pio_read_32(ptr); 767 printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val); 768 785 769 #ifdef IO_SPACE_BOUNDARY 786 770 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 787 771 return 1; 788 772 #endif 789 km_unmap((uintptr_t)ptr, sizeof(uint8_t)); 790 return 1; 791 } 792 793 /** Write 2 bytes to phys memory or io port. 773 774 km_unmap((uintptr_t) ptr, sizeof(uint32_t)); 775 return 1; 776 } 777 778 /** Write 1 byte to phys memory or io port. 794 779 * 795 780 * @param argv Argument vector. … … 797 782 * @return 0 on failure, 1 on success. 798 783 */ 799 static int cmd_pio_write_16(cmd_arg_t *argv) 800 { 801 uint16_t *ptr = NULL; 784 static int cmd_pio_write_8(cmd_arg_t *argv) 785 { 786 uint8_t *ptr = NULL; 787 802 788 #ifdef IO_SPACE_BOUNDARY 803 789 if ((void *) argv->intval < IO_SPACE_BOUNDARY) … … 805 791 else 806 792 #endif 807 ptr = (uint 16_t*)km_map(argv[0].intval, sizeof(uint16_t),793 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 808 794 PAGE_NOT_CACHEABLE); 809 printf("write %"PRIxn": %"PRIx16"\n", argv[0].intval, 810 (uint16_t)argv[1].intval); 811 pio_write_16(ptr, (uint16_t)argv[1].intval); 795 796 printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval, 797 (uint8_t) argv[1].intval); 798 pio_write_8(ptr, (uint8_t) argv[1].intval); 799 812 800 #ifdef IO_SPACE_BOUNDARY 813 801 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 814 802 return 1; 815 803 #endif 816 km_unmap((uintptr_t)ptr, sizeof(uint16_t)); 817 return 1; 818 } 819 820 /** Write 4 bytes to phys memory or io port. 804 805 km_unmap((uintptr_t) ptr, sizeof(uint8_t)); 806 return 1; 807 } 808 809 /** Write 2 bytes to phys memory or io port. 821 810 * 822 811 * @param argv Argument vector. … … 824 813 * @return 0 on failure, 1 on success. 825 814 */ 826 static int cmd_pio_write_32(cmd_arg_t *argv) 827 { 828 uint32_t *ptr = NULL; 815 static int cmd_pio_write_16(cmd_arg_t *argv) 816 { 817 uint16_t *ptr = NULL; 818 829 819 #ifdef IO_SPACE_BOUNDARY 830 820 if ((void *) argv->intval < IO_SPACE_BOUNDARY) … … 832 822 else 833 823 #endif 834 ptr = (uint 32_t*)km_map(argv[0].intval, sizeof(uint32_t),824 ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t), 835 825 PAGE_NOT_CACHEABLE); 836 printf("write %"PRIxn": %"PRIx32"\n", argv[0].intval, 837 (uint32_t)argv[1].intval); 838 pio_write_32(ptr, (uint32_t)argv[1].intval); 826 827 printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval, 828 (uint16_t) argv[1].intval); 829 pio_write_16(ptr, (uint16_t) argv[1].intval); 830 839 831 #ifdef IO_SPACE_BOUNDARY 840 832 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 841 833 return 1; 842 834 #endif 843 km_unmap((uintptr_t)ptr, sizeof(uint32_t)); 835 836 km_unmap((uintptr_t) ptr, sizeof(uint16_t)); 837 return 1; 838 } 839 840 /** Write 4 bytes to phys memory or io port. 841 * 842 * @param argv Argument vector. 843 * 844 * @return 0 on failure, 1 on success. 845 */ 846 static int cmd_pio_write_32(cmd_arg_t *argv) 847 { 848 uint32_t *ptr = NULL; 849 850 #ifdef IO_SPACE_BOUNDARY 851 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 852 ptr = (void *) argv[0].intval; 853 else 854 #endif 855 ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t), 856 PAGE_NOT_CACHEABLE); 857 858 printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval, 859 (uint32_t) argv[1].intval); 860 pio_write_32(ptr, (uint32_t) argv[1].intval); 861 862 #ifdef IO_SPACE_BOUNDARY 863 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 864 return 1; 865 #endif 866 867 km_unmap((uintptr_t) ptr, sizeof(uint32_t)); 844 868 return 1; 845 869 }
Note:
See TracChangeset
for help on using the changeset viewer.