bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Export input structures used by Hurd in device/input.h.


From: Samuel Thibault
Subject: Re: [PATCH] Export input structures used by Hurd in device/input.h.
Date: Mon, 9 Jan 2023 20:09:01 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Flavio Cruz, le lun. 09 janv. 2023 00:14:20 -0500, a ecrit:
> Also delete sys/ioctl.h and merge it with device/input.h since it is
> only needed here.

It seems that the _IOR/W/WR macros is currently a mess, various drivers
using various conventions. Better isolate the kd piece by itself indeed,
so I applied this.

At some point we might want to make all of them coherent.

Samuel

> ---
>  Makefrag.am            |   1 +
>  i386/i386at/kd.h       |  60 +----------------------
>  include/device/input.h | 106 +++++++++++++++++++++++++++++++++++++++++
>  include/sys/ioctl.h    |  52 --------------------
>  4 files changed, 108 insertions(+), 111 deletions(-)
>  create mode 100644 include/device/input.h
>  delete mode 100644 include/sys/ioctl.h
> 
> diff --git a/Makefrag.am b/Makefrag.am
> index c778ed80..e2b4a3ba 100644
> --- a/Makefrag.am
> +++ b/Makefrag.am
> @@ -364,6 +364,7 @@ include_device_HEADERS = \
>       include/device/device_types.defs \
>       include/device/device_types.h \
>       include/device/disk_status.h \
> +     include/device/input.h \
>       include/device/net_status.h \
>       include/device/notify.defs \
>       include/device/notify.h \
> diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h
> index cfa7819e..ea0d4e13 100644
> --- a/i386/i386at/kd.h
> +++ b/i386/i386at/kd.h
> @@ -71,7 +71,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>  #ifndef      _KD_H_
>  #define _KD_H_
>  
> -#include <sys/ioctl.h>
> +#include <device/input.h>
>  #include <mach/boolean.h>
>  #include <sys/types.h>
>  #include <device/cons.h>
> @@ -617,34 +617,10 @@ struct kbentry {
>   * Ioctl's on /dev/kbd.
>   */
>  
> -/*
> - * KDSKBDMODE - When the console is in "ascii" mode, keyboard events are
> - * converted to Ascii characters that are readable from /dev/console.
> - * When the console is in "event" mode, keyboard events are
> - * timestamped and queued up on /dev/kbd as kd_events.  When the last
> - * close is done on /dev/kbd, the console automatically reverts to ascii
> - * mode.
> - * When /dev/mouse is opened, mouse events are timestamped and queued
> - * on /dev/mouse, again as kd_events.
> - *
> - * KDGKBDTYPE - Returns the type of keyboard installed.  Currently
> - * there is only one type, KB_VANILLAKB, which is your standard PC-AT
> - * keyboard.
> - */
> -
>  #ifdef       KERNEL
>  extern       int     kb_mode;
>  #endif
>  
> -#define KDSKBDMODE   _IOW('K', 1, int)       /* set keyboard mode */
> -#define KB_EVENT     1
> -#define KB_ASCII     2
> -
> -#define KDGKBDTYPE   _IOR('K', 2, int)       /* get keyboard type */
> -#define KB_VANILLAKB 0
> -
> -#define KDSETLEDS    _IOW('K', 5, int)       /* set the keyboard ledstate */
> -
>  struct X_kdb {
>       u_int *ptr;
>       u_int size;
> @@ -661,40 +637,6 @@ struct X_kdb {
>  #define K_X_TYPE     0x03070000
>  #define K_X_PORT     0x0000ffff
>  
> -typedef u_short kev_type;            /* kd event type */
> -
> -/* (used for event records) */
> -struct mouse_motion {                
> -     short mm_deltaX;                /* units? */
> -     short mm_deltaY;
> -};
> -
> -typedef struct {
> -     kev_type type;                  /* see below */
> -     /*
> -      * This is not used anymore but is kept for backwards compatibility.
> -      * Note the use of rpc_time_value to ensure compatibility for a 64 bit 
> kernel and
> -      * 32 bit user land.
> -      */
> -     struct rpc_time_value unused_time;      /* timestamp*/
> -     union {                         /* value associated with event */
> -             boolean_t up;           /* MOUSE_LEFT .. MOUSE_RIGHT */
> -             Scancode sc;            /* KEYBD_EVENT */
> -             struct mouse_motion mmotion;    /* MOUSE_MOTION */
> -     } value;
> -} kd_event;
> -#define m_deltaX     mmotion.mm_deltaX
> -#define m_deltaY     mmotion.mm_deltaY
> -
> -/* 
> - * kd_event ID's.
> - */
> -#define MOUSE_LEFT   1               /* mouse left button up/down */
> -#define MOUSE_MIDDLE 2
> -#define MOUSE_RIGHT  3
> -#define MOUSE_MOTION 4               /* mouse motion */
> -#define KEYBD_EVENT  5               /* key up/down */
> -
>  extern boolean_t kd_isupper (u_char);
>  extern boolean_t kd_islower (u_char);
>  extern void kd_senddata (unsigned char);
> diff --git a/include/device/input.h b/include/device/input.h
> new file mode 100644
> index 00000000..1c6adfd9
> --- /dev/null
> +++ b/include/device/input.h
> @@ -0,0 +1,106 @@
> +/*
> + * Copyright (C) 2023 Free Software Foundation, Inc.
> + *
> + * This file is part of GNU Mach.
> + *
> + * GNU Mach is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2, or (at your option) any later
> + * version.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> + * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> + * for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> + */
> +
> +#ifndef _DEVICE_INPUT_H
> +#define _DEVICE_INPUT_H
> +
> +#include <mach/boolean.h>
> +#include <mach/time_value.h>
> +
> +/*
> + * Ioctl's have the command encoded in the lower word, and the size of
> + * any in or out parameters in the upper word.  The high 3 bits of the
> + * upper word are used to encode the in/out status of the parameter.
> + */
> +#define      IOCPARM_MASK    0x1fff          /* parameter length, at most 13 
> bits */
> +#define      IOC_VOID        0x20000000      /* no parameters */
> +#define      IOC_OUT         0x40000000      /* copy out parameters */
> +#define      IOC_IN          0x80000000U     /* copy in parameters */
> +#define      IOC_INOUT       (IOC_IN|IOC_OUT)
> +
> +#define _IOC(inout,group,num,len) \
> +     (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
> +#define      _IO(g,n)        _IOC(IOC_VOID,  (g), (n), 0)
> +#define      _IOR(g,n,t)     _IOC(IOC_OUT,   (g), (n), sizeof(t))
> +#define      _IOW(g,n,t)     _IOC(IOC_IN,    (g), (n), sizeof(t))
> +#define      _IOWR(g,n,t)    _IOC(IOC_INOUT, (g), (n), sizeof(t))
> +
> +typedef u_char Scancode;
> +typedef u_short kev_type;            /* kd event type */
> +
> +/* (used for event records) */
> +struct mouse_motion {                
> +     short mm_deltaX;                /* units? */
> +     short mm_deltaY;
> +};
> +
> +typedef struct {
> +     kev_type type;                  /* see below */
> +     /*
> +      * This is not used anymore but is kept for backwards compatibility.
> +      * Note the use of rpc_time_value to ensure compatibility for a 64 bit 
> kernel and
> +      * 32 bit user land.
> +      */
> +     struct rpc_time_value unused_time;      /* timestamp*/
> +     union {                         /* value associated with event */
> +             boolean_t up;           /* MOUSE_LEFT .. MOUSE_RIGHT */
> +             Scancode sc;            /* KEYBD_EVENT */
> +             struct mouse_motion mmotion;    /* MOUSE_MOTION */
> +     } value;
> +} kd_event;
> +#define m_deltaX     mmotion.mm_deltaX
> +#define m_deltaY     mmotion.mm_deltaY
> +
> +/* 
> + * kd_event ID's.
> + */
> +#define MOUSE_LEFT   1               /* mouse left button up/down */
> +#define MOUSE_MIDDLE 2
> +#define MOUSE_RIGHT  3
> +#define MOUSE_MOTION 4               /* mouse motion */
> +#define KEYBD_EVENT  5               /* key up/down */
> +
> +/* Keyboard ioctls */
> +
> +/*
> + * KDSKBDMODE - When the console is in "ascii" mode, keyboard events are
> + * converted to Ascii characters that are readable from /dev/console.
> + * When the console is in "event" mode, keyboard events are
> + * timestamped and queued up on /dev/kbd as kd_events.  When the last
> + * close is done on /dev/kbd, the console automatically reverts to ascii
> + * mode.
> + * When /dev/mouse is opened, mouse events are timestamped and queued
> + * on /dev/mouse, again as kd_events.
> + *
> + * KDGKBDTYPE - Returns the type of keyboard installed.  Currently
> + * there is only one type, KB_VANILLAKB, which is your standard PC-AT
> + * keyboard.
> + */
> +
> +#define KDSKBDMODE   _IOW('K', 1, int)       /* set keyboard mode */
> +#define KB_EVENT     1
> +#define KB_ASCII     2
> +
> +#define KDGKBDTYPE   _IOR('K', 2, int)       /* get keyboard type */
> +#define KB_VANILLAKB 0
> +
> +#define KDSETLEDS    _IOW('K', 5, int)       /* set the keyboard ledstate */
> +
> +#endif /* _DEVICE_INPUT_H */
> diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
> deleted file mode 100644
> index 1df6b732..00000000
> --- a/include/sys/ioctl.h
> +++ /dev/null
> @@ -1,52 +0,0 @@
> -/*
> - * Mach Operating System
> - * Copyright (c) 1991 Carnegie Mellon University
> - * All Rights Reserved.
> - *
> - * Permission to use, copy, modify and distribute this software and its
> - * documentation is hereby granted, provided that both the copyright
> - * notice and this permission notice appear in all copies of the
> - * software, derivative works or modified versions, and any portions
> - * thereof, and that both notices appear in supporting documentation.
> - *
> - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
> - * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
> - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
> - *
> - * Carnegie Mellon requests users of this software to return to
> - *
> - *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
> - *  School of Computer Science
> - *  Carnegie Mellon University
> - *  Pittsburgh PA 15213-3890
> - *
> - * any improvements or extensions that they make and grant Carnegie Mellon 
> rights
> - * to redistribute these changes.
> - */
> -/*
> - * Format definitions for 'ioctl' commands in device definitions.
> - *
> - * From BSD4.4.
> - */
> -
> -#ifndef _MACH_SYS_IOCTL_H_
> -#define _MACH_SYS_IOCTL_H_
> -/*
> - * Ioctl's have the command encoded in the lower word, and the size of
> - * any in or out parameters in the upper word.  The high 3 bits of the
> - * upper word are used to encode the in/out status of the parameter.
> - */
> -#define      IOCPARM_MASK    0x1fff          /* parameter length, at most 13 
> bits */
> -#define      IOC_VOID        0x20000000      /* no parameters */
> -#define      IOC_OUT         0x40000000      /* copy out parameters */
> -#define      IOC_IN          0x80000000U     /* copy in parameters */
> -#define      IOC_INOUT       (IOC_IN|IOC_OUT)
> -
> -#define _IOC(inout,group,num,len) \
> -     (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
> -#define      _IO(g,n)        _IOC(IOC_VOID,  (g), (n), 0)
> -#define      _IOR(g,n,t)     _IOC(IOC_OUT,   (g), (n), sizeof(t))
> -#define      _IOW(g,n,t)     _IOC(IOC_IN,    (g), (n), sizeof(t))
> -#define      _IOWR(g,n,t)    _IOC(IOC_INOUT, (g), (n), sizeof(t))
> -
> -#endif        /* _MACH_SYS_IOCTL_H_ */
> -- 
> 2.39.0
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]