release.sh: allow REPO and GITBRANCH env override
[minix.git] / commands / devmand / usb.y
blobdcb38193915f10e02eeeb99055ee3024c04438ad
1 %{
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include "usb_driver.h"
6 #define YY_NO_INPUT
7 static struct devmand_usb_driver *current_drv;
8 static struct devmand_usb_match_id *current_id;
10 int yylex(void);
12 void yyerror(char *s)
14 fprintf(stderr,"parsing error: %s\n",s);
17 int yywrap()
19 return 1;
23 %union {
24 char *string;
27 %start drivers
28 %token <string> USB_DRIVER DEV_PREFIX BINARY INTERFACE_CLASS INTERFACE_SUB_CLASS EQUALS DEV_TYPE BLOCK_DEV CHAR_DEV UPSCRIPT DOWNSCRIPT
29 SEMICOLON BRACKET_OPEN BRACKET_CLOSE STRING ID INTERFACE_PROTOCOL
32 drivers :
33 driver
36 | drivers driver
40 driver :
41 USB_DRIVER STRING {current_drv = add_usb_driver($2);}
42 BRACKET_OPEN
43 usb_driver_statements BRACKET_CLOSE
47 usb_driver_statements:
48 usb_driver_statement
51 | usb_driver_statements usb_driver_statement
55 usb_driver_statement:
56 {current_id = add_usb_match_id(current_drv);}
57 ID BRACKET_OPEN usb_device_id_statements BRACKET_CLOSE
60 | BINARY EQUALS STRING SEMICOLON
62 current_drv->binary = $3;
64 | DEV_PREFIX EQUALS STRING SEMICOLON
66 current_drv->devprefix = $3;
68 | DEV_TYPE EQUALS BLOCK_DEV SEMICOLON
70 current_drv->dev_type = block_dev;
72 | DEV_TYPE EQUALS CHAR_DEV SEMICOLON
74 current_drv->dev_type = char_dev;
76 | UPSCRIPT EQUALS STRING SEMICOLON
78 current_drv->upscript = $3;
80 | DOWNSCRIPT EQUALS STRING SEMICOLON
82 current_drv->downscript = $3;
86 usb_device_id_statements:
87 usb_device_id_statement
90 |usb_device_id_statements usb_device_id_statement
95 usb_device_id_statement:
96 INTERFACE_CLASS EQUALS STRING SEMICOLON
98 int res;
99 unsigned int num;
100 current_id->match_flags |= USB_MATCH_INTERFACE_CLASS;
101 res = sscanf($3, "0x%x", &num);
102 if (res != 1) {
103 fprintf(stderr, "ERROR");
104 exit(1);
106 current_id->match_id.bInterfaceClass = num;
108 | INTERFACE_SUB_CLASS EQUALS STRING SEMICOLON
110 int res;
111 unsigned int num;
112 current_id->match_flags |= USB_MATCH_INTERFACE_SUBCLASS;
113 res = sscanf($3, "0x%x", &num);
114 if (res != 1) {
115 fprintf(stderr, "ERROR");
116 exit(1);
118 current_id->match_id.bInterfaceSubClass = num;
121 | INTERFACE_PROTOCOL EQUALS STRING SEMICOLON
123 int res;
124 unsigned int num;
125 current_id->match_flags |= USB_MATCH_INTERFACE_PROTOCOL;
126 res = sscanf($3, "0x%x", &num);
127 if (res != 1) {
128 fprintf(stderr, "ERROR");
129 exit(1);
131 current_id->match_id.bInterfaceProtocol = num;