Changes in kernel/generic/src/console/cmd.c [e8a1530:6eef3c4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
re8a1530 r6eef3c4 56 56 #include <cpu.h> 57 57 #include <mm/tlb.h> 58 #include <mm/km.h>59 58 #include <arch/mm/tlb.h> 60 59 #include <mm/frame.h> … … 82 81 .func = cmd_help, 83 82 .argc = 0 84 };85 86 /* Data and methods for pio_read_8 command */87 static int cmd_pio_read_8(cmd_arg_t *argv);88 static cmd_arg_t pio_read_8_argv[] = { { .type = ARG_TYPE_INT } };89 static cmd_info_t pio_read_8_info = {90 .name = "pio_read_8",91 .description = "pio_read_8 <address> Read 1 byte from memory (or port).",92 .func = cmd_pio_read_8,93 .argc = 1,94 .argv = pio_read_8_argv95 };96 97 /* Data and methods for pio_read_16 command */98 static int cmd_pio_read_16(cmd_arg_t *argv);99 static cmd_arg_t pio_read_16_argv[] = { { .type = ARG_TYPE_INT } };100 static cmd_info_t pio_read_16_info = {101 .name = "pio_read_16",102 .description = "pio_read_16 <address> Read 2 bytes from memory (or port).",103 .func = cmd_pio_read_16,104 .argc = 1,105 .argv = pio_read_16_argv106 };107 108 /* Data and methods for pio_read_32 command */109 static int cmd_pio_read_32(cmd_arg_t *argv);110 static cmd_arg_t pio_read_32_argv[] = { { .type = ARG_TYPE_INT } };111 static cmd_info_t pio_read_32_info = {112 .name = "pio_read_32",113 .description = "pio_read_32 <address> Read 4 bytes from memory (or port).",114 .func = cmd_pio_read_32,115 .argc = 1,116 .argv = pio_read_32_argv117 };118 119 /* Data and methods for pio_write_8 command */120 static int cmd_pio_write_8(cmd_arg_t *argv);121 static cmd_arg_t pio_write_8_argv[] = {122 { .type = ARG_TYPE_INT },123 { .type = ARG_TYPE_INT }124 };125 static cmd_info_t pio_write_8_info = {126 .name = "pio_write_8",127 .description = "pio_write_8 <address> <value> Write 1 byte to memory (or port).",128 .func = cmd_pio_write_8,129 .argc = 2,130 .argv = pio_write_8_argv131 };132 133 /* Data and methods for pio_write_16 command */134 static int cmd_pio_write_16(cmd_arg_t *argv);135 static cmd_arg_t pio_write_16_argv[] = {136 { .type = ARG_TYPE_INT },137 { .type = ARG_TYPE_INT }138 };139 static cmd_info_t pio_write_16_info = {140 .name = "pio_write_16",141 .description = "pio_write_16 <address> <value> Write 2 bytes to memory (or port).",142 .func = cmd_pio_write_16,143 .argc = 2,144 .argv = pio_write_16_argv145 };146 147 /* Data and methods for pio_write_32 command */148 static int cmd_pio_write_32(cmd_arg_t *argv);149 static cmd_arg_t pio_write_32_argv[] = {150 { .type = ARG_TYPE_INT },151 { .type = ARG_TYPE_INT }152 };153 static cmd_info_t pio_write_32_info = {154 .name = "pio_write_32",155 .description = "pio_write_32 <address> <value> Write 4 bytes to memory (or port).",156 .func = cmd_pio_write_32,157 .argc = 2,158 .argv = pio_write_32_argv159 83 }; 160 84 … … 607 531 &btrace_info, 608 532 #endif 609 &pio_read_8_info,610 &pio_read_16_info,611 &pio_read_32_info,612 &pio_write_8_info,613 &pio_write_16_info,614 &pio_write_32_info,615 533 NULL 616 534 }; … … 683 601 spinlock_unlock(&cmd_lock); 684 602 685 return 1;686 }687 688 /** Read 1 byte from phys memory or io port.689 *690 * @param argv Argument vector.691 *692 * @return 0 on failure, 1 on success.693 */694 static int cmd_pio_read_8(cmd_arg_t *argv)695 {696 uint8_t *ptr = NULL;697 #ifdef IO_SPACE_BOUNDARY698 if (argv->intval < IO_SPACE_BOUNDARY)699 ptr = argv[0].intval;700 else701 #endif702 ptr = (uint8_t*)km_map(argv[0].intval, sizeof(uint8_t), PAGE_NOT_CACHEABLE);703 const uint8_t val = pio_read_8(ptr);704 printf("read %x: %"PRIx8"\n", argv[0].intval, val);705 #ifdef IO_SPACE_BOUNDARY706 if (argv->intval < IO_SPACE_BOUNDARY)707 return 1;708 #endif709 km_unmap((uintptr_t)ptr, sizeof(uint8_t));710 return 1;711 }712 713 /** Read 2 bytes from phys memory or io port.714 *715 * @param argv Argument vector.716 *717 * @return 0 on failure, 1 on success.718 */719 static int cmd_pio_read_16(cmd_arg_t *argv)720 {721 uint16_t *ptr = NULL;722 #ifdef IO_SPACE_BOUNDARY723 if (argv->intval < IO_SPACE_BOUNDARY)724 ptr = argv[0].intval;725 else726 #endif727 ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t), PAGE_NOT_CACHEABLE);728 const uint16_t val = pio_read_16(ptr);729 printf("read %x: %"PRIx16"\n", argv[0].intval, val);730 #ifdef IO_SPACE_BOUNDARY731 if (argv->intval < IO_SPACE_BOUNDARY)732 return 1;733 #endif734 km_unmap((uintptr_t)ptr, sizeof(uint16_t));735 return 1;736 }737 738 /** Read 4 bytes from phys memory or io port.739 *740 * @param argv Argument vector.741 *742 * @return 0 on failure, 1 on success.743 */744 static int cmd_pio_read_32(cmd_arg_t *argv)745 {746 uint32_t *ptr = NULL;747 #ifdef IO_SPACE_BOUNDARY748 if (argv->intval < IO_SPACE_BOUNDARY)749 ptr = argv[0].intval;750 else751 #endif752 ptr = (uint32_t*)km_map(argv[0].intval, sizeof(uint32_t), PAGE_NOT_CACHEABLE);753 const uint32_t val = pio_read_32(ptr);754 printf("read %#x: %#"PRIx32"\n", argv[0].intval, val);755 #ifdef IO_SPACE_BOUNDARY756 if (argv->intval < IO_SPACE_BOUNDARY)757 return 1;758 #endif759 km_unmap((uintptr_t)ptr, sizeof(uint32_t));760 return 1;761 }762 763 /** Write 1 byte to phys memory or io port.764 *765 * @param argv Argument vector.766 *767 * @return 0 on failure, 1 on success.768 */769 static int cmd_pio_write_8(cmd_arg_t *argv)770 {771 uint8_t *ptr = NULL;772 #ifdef IO_SPACE_BOUNDARY773 if (argv->intval < IO_SPACE_BOUNDARY)774 ptr = argv[0].intval;775 else776 #endif777 ptr = (uint8_t*)km_map(argv[0].intval, sizeof(uint8_t), PAGE_NOT_CACHEABLE);778 printf("write %x: %"PRIx8"\n", argv[0].intval, (uint8_t)argv[1].intval);779 pio_write_8(ptr, (uint8_t)argv[1].intval);780 #ifdef IO_SPACE_BOUNDARY781 if (argv->intval < IO_SPACE_BOUNDARY)782 return 1;783 #endif784 km_unmap((uintptr_t)ptr, sizeof(uint8_t));785 return 1;786 }787 788 /** Write 2 bytes to phys memory or io port.789 *790 * @param argv Argument vector.791 *792 * @return 0 on failure, 1 on success.793 */794 static int cmd_pio_write_16(cmd_arg_t *argv)795 {796 uint16_t *ptr = NULL;797 #ifdef IO_SPACE_BOUNDARY798 if (argv->intval < IO_SPACE_BOUNDARY)799 ptr = argv[0].intval;800 else801 #endif802 ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t), PAGE_NOT_CACHEABLE);803 printf("write %x: %"PRIx16"\n", argv[0].intval, (uint16_t)argv[1].intval);804 pio_write_16(ptr, (uint16_t)argv[1].intval);805 #ifdef IO_SPACE_BOUNDARY806 if (argv->intval < IO_SPACE_BOUNDARY)807 return 1;808 #endif809 km_unmap((uintptr_t)ptr, sizeof(uint16_t));810 return 1;811 }812 813 /** Write 4 bytes to phys memory or io port.814 *815 * @param argv Argument vector.816 *817 * @return 0 on failure, 1 on success.818 */819 static int cmd_pio_write_32(cmd_arg_t *argv)820 {821 uint32_t *ptr = NULL;822 #ifdef IO_SPACE_BOUNDARY823 if (argv->intval < IO_SPACE_BOUNDARY)824 ptr = argv[0].intval;825 else826 #endif827 ptr = (uint32_t*)km_map(argv[0].intval, sizeof(uint32_t), PAGE_NOT_CACHEABLE);828 printf("write %x: %"PRIx32"\n", argv[0].intval, (uint32_t)argv[1].intval);829 pio_write_32(ptr, (uint32_t)argv[1].intval);830 #ifdef IO_SPACE_BOUNDARY831 if (argv->intval < IO_SPACE_BOUNDARY)832 return 1;833 #endif834 km_unmap((uintptr_t)ptr, sizeof(uint32_t));835 603 return 1; 836 604 }
Note:
See TracChangeset
for help on using the changeset viewer.