Changeset 94d211e in mainline for kernel/generic/src/console/cmd.c
- Timestamp:
- 2018-03-21T19:32:48Z (7 years ago)
- Children:
- 1c7a170
- Parents:
- 973be387
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r973be387 r94d211e 727 727 else 728 728 #endif 729 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 730 PAGE_NOT_CACHEABLE); 729 ptr = (uint8_t *) km_map( 730 argv[0].intval, sizeof(uint8_t), 731 PAGE_READ_ONLY | PAGE_KERNEL | PAGE_NOT_CACHEABLE); 731 732 732 733 const uint8_t val = pio_read_8(ptr); … … 749 750 */ 750 751 static int cmd_pio_read_16(cmd_arg_t *argv) 752 { 753 uint16_t *ptr = NULL; 754 755 #ifdef IO_SPACE_BOUNDARY 756 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 757 ptr = (void *) argv[0].intval; 758 else 759 #endif 760 ptr = (uint16_t *) km_map( 761 argv[0].intval, sizeof(uint16_t), 762 PAGE_READ_ONLY | PAGE_KERNEL | PAGE_NOT_CACHEABLE); 763 764 const uint16_t val = pio_read_16(ptr); 765 printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val); 766 767 #ifdef IO_SPACE_BOUNDARY 768 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 769 return 1; 770 #endif 771 772 km_unmap((uintptr_t) ptr, sizeof(uint16_t)); 773 return 1; 774 } 775 776 /** Read 4 bytes from phys memory or io port. 777 * 778 * @param argv Argument vector. 779 * 780 * @return 0 on failure, 1 on success. 781 */ 782 static int cmd_pio_read_32(cmd_arg_t *argv) 783 { 784 uint32_t *ptr = NULL; 785 786 #ifdef IO_SPACE_BOUNDARY 787 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 788 ptr = (void *) argv[0].intval; 789 else 790 #endif 791 ptr = (uint32_t *) km_map( 792 argv[0].intval, sizeof(uint32_t), 793 PAGE_READ_ONLY | PAGE_KERNEL | PAGE_NOT_CACHEABLE); 794 795 const uint32_t val = pio_read_32(ptr); 796 printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val); 797 798 #ifdef IO_SPACE_BOUNDARY 799 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 800 return 1; 801 #endif 802 803 km_unmap((uintptr_t) ptr, sizeof(uint32_t)); 804 return 1; 805 } 806 807 /** Write 1 byte to phys memory or io port. 808 * 809 * @param argv Argument vector. 810 * 811 * @return 0 on failure, 1 on success. 812 */ 813 static int cmd_pio_write_8(cmd_arg_t *argv) 814 { 815 uint8_t *ptr = NULL; 816 817 #ifdef IO_SPACE_BOUNDARY 818 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 819 ptr = (void *) argv[0].intval; 820 else 821 #endif 822 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 823 PAGE_READ_WRITE | PAGE_KERNEL | PAGE_NOT_CACHEABLE); 824 825 printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval, 826 (uint8_t) argv[1].intval); 827 pio_write_8(ptr, (uint8_t) argv[1].intval); 828 829 #ifdef IO_SPACE_BOUNDARY 830 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 831 return 1; 832 #endif 833 834 km_unmap((uintptr_t) ptr, sizeof(uint8_t)); 835 return 1; 836 } 837 838 /** Write 2 bytes to phys memory or io port. 839 * 840 * @param argv Argument vector. 841 * 842 * @return 0 on failure, 1 on success. 843 */ 844 static int cmd_pio_write_16(cmd_arg_t *argv) 751 845 { 752 846 uint16_t *ptr = NULL; … … 758 852 #endif 759 853 ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t), 760 PAGE_NOT_CACHEABLE); 761 762 const uint16_t val = pio_read_16(ptr); 763 printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val); 854 PAGE_READ_WRITE | PAGE_KERNEL | PAGE_NOT_CACHEABLE); 855 856 printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval, 857 (uint16_t) argv[1].intval); 858 pio_write_16(ptr, (uint16_t) argv[1].intval); 764 859 765 860 #ifdef IO_SPACE_BOUNDARY … … 772 867 } 773 868 774 /** Read 4 bytes fromphys memory or io port.869 /** Write 4 bytes to phys memory or io port. 775 870 * 776 871 * @param argv Argument vector. … … 778 873 * @return 0 on failure, 1 on success. 779 874 */ 780 static int cmd_pio_ read_32(cmd_arg_t *argv)875 static int cmd_pio_write_32(cmd_arg_t *argv) 781 876 { 782 877 uint32_t *ptr = NULL; … … 788 883 #endif 789 884 ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t), 790 PAGE_NOT_CACHEABLE); 791 792 const uint32_t val = pio_read_32(ptr); 793 printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val); 794 795 #ifdef IO_SPACE_BOUNDARY 796 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 797 return 1; 798 #endif 799 800 km_unmap((uintptr_t) ptr, sizeof(uint32_t)); 801 return 1; 802 } 803 804 /** Write 1 byte to phys memory or io port. 805 * 806 * @param argv Argument vector. 807 * 808 * @return 0 on failure, 1 on success. 809 */ 810 static int cmd_pio_write_8(cmd_arg_t *argv) 811 { 812 uint8_t *ptr = NULL; 813 814 #ifdef IO_SPACE_BOUNDARY 815 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 816 ptr = (void *) argv[0].intval; 817 else 818 #endif 819 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 820 PAGE_NOT_CACHEABLE); 821 822 printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval, 823 (uint8_t) argv[1].intval); 824 pio_write_8(ptr, (uint8_t) argv[1].intval); 825 826 #ifdef IO_SPACE_BOUNDARY 827 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 828 return 1; 829 #endif 830 831 km_unmap((uintptr_t) ptr, sizeof(uint8_t)); 832 return 1; 833 } 834 835 /** Write 2 bytes to phys memory or io port. 836 * 837 * @param argv Argument vector. 838 * 839 * @return 0 on failure, 1 on success. 840 */ 841 static int cmd_pio_write_16(cmd_arg_t *argv) 842 { 843 uint16_t *ptr = NULL; 844 845 #ifdef IO_SPACE_BOUNDARY 846 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 847 ptr = (void *) argv[0].intval; 848 else 849 #endif 850 ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t), 851 PAGE_NOT_CACHEABLE); 852 853 printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval, 854 (uint16_t) argv[1].intval); 855 pio_write_16(ptr, (uint16_t) argv[1].intval); 856 857 #ifdef IO_SPACE_BOUNDARY 858 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 859 return 1; 860 #endif 861 862 km_unmap((uintptr_t) ptr, sizeof(uint16_t)); 863 return 1; 864 } 865 866 /** Write 4 bytes to phys memory or io port. 867 * 868 * @param argv Argument vector. 869 * 870 * @return 0 on failure, 1 on success. 871 */ 872 static int cmd_pio_write_32(cmd_arg_t *argv) 873 { 874 uint32_t *ptr = NULL; 875 876 #ifdef IO_SPACE_BOUNDARY 877 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 878 ptr = (void *) argv[0].intval; 879 else 880 #endif 881 ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t), 882 PAGE_NOT_CACHEABLE); 885 PAGE_READ_WRITE | PAGE_KERNEL | PAGE_NOT_CACHEABLE); 883 886 884 887 printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval,
Note:
See TracChangeset
for help on using the changeset viewer.