kdb
[Top] [All Lists]

Re: [PATCH]:display/modify i/o port

To: adegawa@xxxxxxxxxxxxxx (Masahiro Adegawa)
Subject: Re: [PATCH]:display/modify i/o port
From: slurn@xxxxxxxxxxxxxxxxxxxx (Scott Lurndal)
Date: Tue, 26 Oct 1999 10:53:32 -0700 (PDT)
Cc: kdb@xxxxxxxxxxx
In-reply-to: <3815709F2D0.7577ADEGAWA@mail.zerosoft.co.jp> from Masahiro Adegawa at "Oct 26, 99 06:13:03 pm"
Sender: owner-kdb@xxxxxxxxxxx
> hi,
> 
> I have 2 patchs about i/o port.
> 
> 1st patch is a small bug fix.

Oops.  Good catch.

> 2nd patch is added commands display/modify i/o port.
>       iob             <port> [<contents>]  Display/Modify i/o port(8bit)
>       iow             <port> [<contents>]  Display/Modify i/o port(16bit)
>       iol             <port> [<contents>]  Display/Modify i/o port(32bit)
>   ex.
>       Entering kdb due to Keyboard Entry
>       kdb> iob 0x378
>       in : 0x378 = 0x00
>       kdb> iob 0x378 0x23
>       out : 0x378 = 0x23
>       kdb> iob 0x378
>       in : 0x378 = 0x23
>       kdb> 

This is fine, but as part of the december release of KDB I've been
splitting it into architecture dependent and architecture independent
parts.  These commands best fit as architecture dependent - so they
should probably be done in a new source file.

Thanks, 

scott
> 
> thanks, 
> 
> 
> 
> --- linux-2.2.12/arch/i386/kdb/kdb_io.c       Fri Aug 27 17:36:16 1999
> +++ linux/arch/i386/kdb/kdb_io.c      Tue Oct 26 12:36:20 1999
> @@ -46,7 +46,7 @@
>  {
>       while (inb(KBD_STATUS_REG) & KBD_STAT_IBF)
>               ;
> -     outb(KBD_DATA_REG, byte);
> +     outb(byte, KBD_DATA_REG);
>  }
>  
>  static void
> --- linux-2.2.12/arch/i386/kdb/kdb.c  Fri Aug 27 17:36:16 1999
> +++ linux/arch/i386/kdb/kdb.c Tue Oct 26 17:50:35 1999
> @@ -21,6 +21,7 @@
>  #endif
>  #include <linux/kdb.h>
>  #include <asm/system.h>
> +#include <asm/io.h>
>  #include "kdbsupport.h"
>  
>  int kdb_active = 0;
> @@ -1082,6 +1083,85 @@
>  
>       return 0;
>  }
> +/*
> + * kdb_io
> + *
> + *   This function implements the 'iob','iow' and 'iol' commands.
> + *
> + *   iob|iow|iol  [<addr arg> [<new value>]]
> + *
> + * Inputs:
> + *   argc    argument count
> + *   argv    argument vector
> + *   envp    environment vector
> + *   regs    registers at time kdb was entered.
> + * Outputs:
> + *   None.
> + * Returns:
> + *   zero for success, a kdb diagnostic if error
> + * Locking:
> + *   none.
> + * Remarks:
> + *   none.
> + */
> +
> +int
> +kdb_io(int argc, const char **argv, const char **envp, struct pt_regs *regs)
> +{
> +     int diag;
> +     unsigned long addr;
> +     long          offset = 0;
> +     unsigned long contents;
> +     int nextarg;
> +     int mod = 0;
> +
> +     if (argc == 0) {
> +             return KDB_ARGCOUNT;
> +     }
> +
> +     nextarg = 1;
> +     diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
> +     if (diag)
> +             return diag;
> +
> +     if (nextarg <= argc) {
> +             diag = kdbgetaddrarg(argc, argv, &nextarg, &contents, NULL, 
> NULL, regs);
> +             if (diag)
> +                     return diag;
> +             mod = 1;
> +             if (nextarg != argc + 1)
> +                     return KDB_ARGCOUNT;
> +     }
> +
> +     /*
> +      * To prevent access of invalid addresses, check first.
> +      * Hmm...
> +      */
> +
> +     if (strcmp(argv[0], "iob") == 0) {
> +             if (mod)
> +                     outb(contents, addr);
> +             else
> +                     contents = inb(addr);
> +             kdb_printf("%s : 0x%x = 0x%2.2x\n", mod?"out":"in", addr, 
> contents);
> +     }
> +     if (strcmp(argv[0], "iow") == 0) {
> +             if (mod)
> +                     outw(contents, addr);
> +             else
> +                     contents = inw(addr);
> +             kdb_printf("%s : 0x%x = 0x%4.4x\n", mod?"out":"in", addr, 
> contents);
> +     }
> +     if (strcmp(argv[0], "iol") == 0) {
> +             if (mod)
> +                     outl(contents, addr);
> +             else
> +                     contents = inl(addr);
> +             kdb_printf("%s : 0x%x = 0x%8.8x\n", mod?"out":"in", addr, 
> contents);
> +     }
> +
> +     return 0;
> +}
>  
>  /*
>   * kdb_go
> @@ -1751,6 +1831,9 @@
>       kdb_register("cpu", kdb_cpu, "<cpunum>","Switch to new cpu", 0);
>  #endif       /* __SMP__ */
>       kdb_register("ps", kdb_ps, "",          "Display active task list", 0);
> +     kdb_register("iob", kdb_io, "<port> [<contents>]", "Display/Modify i/o 
> port(8bit)", 0);
> +     kdb_register("iow", kdb_io, "<port> [<contents>]", "Display/Modify i/o 
> port(16bit)", 0);
> +     kdb_register("iol", kdb_io, "<port> [<contents>]", "Display/Modify i/o 
> port(32bit)", 0);
>       kdb_register("reboot", kdb_reboot, "",  "Reboot the machine 
> immediately", 0);
>  }
>  
> 
> -
> 


<Prev in Thread] Current Thread [Next in Thread>