blob: 768eb62a588321811c45a596fb3792ba59933895 [file] [log] [blame]
Sreelakshmi Gownipallicb8893d2016-10-19 16:02:34 -07001/* Copyright (c) 2008-2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef DIAGCHAR_H
14#define DIAGCHAR_H
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/mempool.h>
19#include <linux/mutex.h>
20#include <linux/list.h>
21#include <linux/spinlock.h>
22#include <linux/workqueue.h>
23#include <linux/sched.h>
24#include <linux/wakelock.h>
25#include <linux/atomic.h>
26#include "diagfwd_bridge.h"
27
28/* Size of the USB buffers used for read and write*/
29#define USB_MAX_OUT_BUF 4096
30#define APPS_BUF_SIZE 4096
31#define IN_BUF_SIZE 16384
32#define MAX_SYNC_OBJ_NAME_SIZE 32
33
34#define DIAG_MAX_REQ_SIZE (16 * 1024)
35#define DIAG_MAX_RSP_SIZE (16 * 1024)
36#define APF_DIAG_PADDING 256
37/*
38 * In the worst case, the HDLC buffer can be atmost twice the size of the
39 * original packet. Add 3 bytes for 16 bit CRC (2 bytes) and a delimiter
40 * (1 byte)
41 */
42#define DIAG_MAX_HDLC_BUF_SIZE ((DIAG_MAX_REQ_SIZE * 2) + 3)
43
44/* The header of callback data type has remote processor token (of type int) */
45#define CALLBACK_HDR_SIZE (sizeof(int))
46#define CALLBACK_BUF_SIZE (DIAG_MAX_REQ_SIZE + CALLBACK_HDR_SIZE)
47
48#define MAX_SSID_PER_RANGE 200
49
50#define ALL_PROC -1
51
52#define REMOTE_DATA 4
53
54#define USER_SPACE_DATA 16384
55
56#define DIAG_CTRL_MSG_LOG_MASK 9
57#define DIAG_CTRL_MSG_EVENT_MASK 10
58#define DIAG_CTRL_MSG_F3_MASK 11
59#define CONTROL_CHAR 0x7E
60
61#define DIAG_CON_APSS (0x0001) /* Bit mask for APSS */
62#define DIAG_CON_MPSS (0x0002) /* Bit mask for MPSS */
63#define DIAG_CON_LPASS (0x0004) /* Bit mask for LPASS */
64#define DIAG_CON_WCNSS (0x0008) /* Bit mask for WCNSS */
65#define DIAG_CON_SENSORS (0x0010) /* Bit mask for Sensors */
66#define DIAG_CON_WDSP (0x0020) /* Bit mask for WDSP */
67
68#define DIAG_CON_NONE (0x0000) /* Bit mask for No SS*/
69#define DIAG_CON_ALL (DIAG_CON_APSS | DIAG_CON_MPSS \
70 | DIAG_CON_LPASS | DIAG_CON_WCNSS \
71 | DIAG_CON_SENSORS | DIAG_CON_WDSP)
72
73#define DIAG_STM_MODEM 0x01
74#define DIAG_STM_LPASS 0x02
75#define DIAG_STM_WCNSS 0x04
76#define DIAG_STM_APPS 0x08
77#define DIAG_STM_SENSORS 0x10
78#define DIAG_STM_WDSP 0x20
79
80#define INVALID_PID -1
81#define DIAG_CMD_FOUND 1
82#define DIAG_CMD_NOT_FOUND 0
83#define DIAG_CMD_POLLING 1
84#define DIAG_CMD_NOT_POLLING 0
85#define DIAG_CMD_ADD 1
86#define DIAG_CMD_REMOVE 0
87
88#define DIAG_CMD_VERSION 0
89#define DIAG_CMD_ERROR 0x13
90#define DIAG_CMD_DOWNLOAD 0x3A
91#define DIAG_CMD_DIAG_SUBSYS 0x4B
92#define DIAG_CMD_LOG_CONFIG 0x73
93#define DIAG_CMD_LOG_ON_DMND 0x78
94#define DIAG_CMD_EXT_BUILD 0x7c
95#define DIAG_CMD_MSG_CONFIG 0x7D
96#define DIAG_CMD_GET_EVENT_MASK 0x81
97#define DIAG_CMD_SET_EVENT_MASK 0x82
98#define DIAG_CMD_EVENT_TOGGLE 0x60
99#define DIAG_CMD_NO_SUBSYS 0xFF
100#define DIAG_CMD_STATUS 0x0C
101#define DIAG_SS_WCDMA 0x04
102#define DIAG_CMD_QUERY_CALL 0x0E
103#define DIAG_SS_GSM 0x08
104#define DIAG_CMD_QUERY_TMC 0x02
105#define DIAG_SS_TDSCDMA 0x57
106#define DIAG_CMD_TDSCDMA_STATUS 0x0E
107#define DIAG_CMD_DIAG_SUBSYS_DELAY 0x80
108
109#define DIAG_SS_DIAG 0x12
110#define DIAG_SS_PARAMS 0x32
111#define DIAG_SS_FILE_READ_MODEM 0x0816
112#define DIAG_SS_FILE_READ_ADSP 0x0E10
113#define DIAG_SS_FILE_READ_WCNSS 0x141F
114#define DIAG_SS_FILE_READ_SLPI 0x01A18
115#define DIAG_SS_FILE_READ_APPS 0x020F
116
117#define DIAG_DIAG_MAX_PKT_SZ 0x55
118#define DIAG_DIAG_STM 0x214
119#define DIAG_DIAG_POLL 0x03
120#define DIAG_DEL_RSP_WRAP 0x04
121#define DIAG_DEL_RSP_WRAP_CNT 0x05
122#define DIAG_EXT_MOBILE_ID 0x06
123#define DIAG_GET_TIME_API 0x21B
124#define DIAG_SET_TIME_API 0x21C
125#define DIAG_SWITCH_COMMAND 0x081B
126#define DIAG_BUFFERING_MODE 0x080C
127
128#define DIAG_CMD_OP_LOG_DISABLE 0
129#define DIAG_CMD_OP_GET_LOG_RANGE 1
130#define DIAG_CMD_OP_SET_LOG_MASK 3
131#define DIAG_CMD_OP_GET_LOG_MASK 4
132
133#define DIAG_CMD_OP_GET_SSID_RANGE 1
134#define DIAG_CMD_OP_GET_BUILD_MASK 2
135#define DIAG_CMD_OP_GET_MSG_MASK 3
136#define DIAG_CMD_OP_SET_MSG_MASK 4
137#define DIAG_CMD_OP_SET_ALL_MSG_MASK 5
138
139#define DIAG_CMD_OP_GET_MSG_ALLOC 0x33
140#define DIAG_CMD_OP_GET_MSG_DROP 0x30
141#define DIAG_CMD_OP_RESET_MSG_STATS 0x2F
142#define DIAG_CMD_OP_GET_LOG_ALLOC 0x31
143#define DIAG_CMD_OP_GET_LOG_DROP 0x2C
144#define DIAG_CMD_OP_RESET_LOG_STATS 0x2B
145#define DIAG_CMD_OP_GET_EVENT_ALLOC 0x32
146#define DIAG_CMD_OP_GET_EVENT_DROP 0x2E
147#define DIAG_CMD_OP_RESET_EVENT_STATS 0x2D
148
149#define DIAG_CMD_OP_HDLC_DISABLE 0x218
150
151#define BAD_PARAM_RESPONSE_MESSAGE 20
152
153#define PERSIST_TIME_SUCCESS 0
154#define PERSIST_TIME_FAILURE 1
155#define PERSIST_TIME_NOT_SUPPORTED 2
156
157#define MODE_CMD 41
158#define RESET_ID 2
159
160#define PKT_DROP 0
161#define PKT_ALLOC 1
162#define PKT_RESET 2
163
164#define FEATURE_MASK_LEN 2
165
166#define DIAG_MD_NONE 0
167#define DIAG_MD_PERIPHERAL 1
168
169/*
170 * The status bit masks when received in a signal handler are to be
171 * used in conjunction with the peripheral list bit mask to determine the
172 * status for a peripheral. For instance, 0x00010002 would denote an open
173 * status on the MPSS
174 */
175#define DIAG_STATUS_OPEN (0x00010000) /* DCI channel open status mask */
176#define DIAG_STATUS_CLOSED (0x00020000) /* DCI channel closed status mask */
177
178#define MODE_NONREALTIME 0
179#define MODE_REALTIME 1
180#define MODE_UNKNOWN 2
181
182#define DIAG_BUFFERING_MODE_STREAMING 0
183#define DIAG_BUFFERING_MODE_THRESHOLD 1
184#define DIAG_BUFFERING_MODE_CIRCULAR 2
185
186#define DIAG_MIN_WM_VAL 0
187#define DIAG_MAX_WM_VAL 100
188
189#define DEFAULT_LOW_WM_VAL 15
190#define DEFAULT_HIGH_WM_VAL 85
191
192#define TYPE_DATA 0
193#define TYPE_CNTL 1
194#define TYPE_DCI 2
195#define TYPE_CMD 3
196#define TYPE_DCI_CMD 4
197#define NUM_TYPES 5
198
199#define PERIPHERAL_MODEM 0
200#define PERIPHERAL_LPASS 1
201#define PERIPHERAL_WCNSS 2
202#define PERIPHERAL_SENSORS 3
203#define PERIPHERAL_WDSP 4
204#define NUM_PERIPHERALS 5
205#define APPS_DATA (NUM_PERIPHERALS)
206
207/* Number of sessions possible in Memory Device Mode. +1 for Apps data */
208#define NUM_MD_SESSIONS (NUM_PERIPHERALS + 1)
209
210#define MD_PERIPHERAL_MASK(x) (1 << x)
211
212/*
213 * Number of stm processors includes all the peripherals and
214 * apps.Added 1 below to indicate apps
215 */
216#define NUM_STM_PROCESSORS (NUM_PERIPHERALS + 1)
217/*
218 * Indicates number of peripherals that can support DCI and Apps
219 * processor. This doesn't mean that a peripheral has the
220 * feature.
221 */
222#define NUM_DCI_PERIPHERALS (NUM_PERIPHERALS + 1)
223
224#define DIAG_PROC_DCI 1
225#define DIAG_PROC_MEMORY_DEVICE 2
226
227/* Flags to vote the DCI or Memory device process up or down
228 * when it becomes active or inactive.
229 */
230#define VOTE_DOWN 0
231#define VOTE_UP 1
232
233#define DIAG_TS_SIZE 50
234
235#define DIAG_MDM_BUF_SIZE 2048
236/* The Maximum request size is 2k + DCI header + footer (6 bytes) */
237#define DIAG_MDM_DCI_BUF_SIZE (2048 + 6)
238
239#define DIAG_LOCAL_PROC 0
240
241#ifndef CONFIG_DIAGFWD_BRIDGE_CODE
242/* Local Processor only */
243#define DIAG_NUM_PROC 1
244#else
245/* Local Processor + Remote Devices */
246#define DIAG_NUM_PROC (1 + NUM_REMOTE_DEV)
247#endif
248
249#define DIAG_WS_DCI 0
250#define DIAG_WS_MUX 1
251
252#define DIAG_DATA_TYPE 1
253#define DIAG_CNTL_TYPE 2
254#define DIAG_DCI_TYPE 3
255
256/* List of remote processor supported */
257enum remote_procs {
258 MDM = 1,
259 MDM2 = 2,
260 QSC = 5,
261};
262
263struct diag_pkt_header_t {
264 uint8_t cmd_code;
265 uint8_t subsys_id;
266 uint16_t subsys_cmd_code;
267} __packed;
268
269struct diag_cmd_ext_mobile_rsp_t {
270 struct diag_pkt_header_t header;
271 uint8_t version;
272 uint8_t padding[3];
273 uint32_t family;
274 uint32_t chip_id;
275} __packed;
276
277struct diag_cmd_time_sync_query_req_t {
278 struct diag_pkt_header_t header;
279 uint8_t version;
280};
281
282struct diag_cmd_time_sync_query_rsp_t {
283 struct diag_pkt_header_t header;
284 uint8_t version;
285 uint8_t time_api;
286};
287
288struct diag_cmd_time_sync_switch_req_t {
289 struct diag_pkt_header_t header;
290 uint8_t version;
291 uint8_t time_api;
292 uint8_t persist_time;
293};
294
295struct diag_cmd_time_sync_switch_rsp_t {
296 struct diag_pkt_header_t header;
297 uint8_t version;
298 uint8_t time_api;
299 uint8_t time_api_status;
300 uint8_t persist_time_status;
301};
302
303struct diag_cmd_reg_entry_t {
304 uint16_t cmd_code;
305 uint16_t subsys_id;
306 uint16_t cmd_code_lo;
307 uint16_t cmd_code_hi;
308} __packed;
309
310struct diag_cmd_reg_t {
311 struct list_head link;
312 struct diag_cmd_reg_entry_t entry;
313 uint8_t proc;
314 int pid;
315};
316
317/*
318 * @sync_obj_name: name of the synchronization object associated with this proc
319 * @count: number of entries in the bind
320 * @entries: the actual packet registrations
321 */
322struct diag_cmd_reg_tbl_t {
323 char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE];
324 uint32_t count;
325 struct diag_cmd_reg_entry_t *entries;
326};
327
328struct diag_client_map {
329 char name[20];
330 int pid;
331};
332
333struct real_time_vote_t {
334 int client_id;
335 uint16_t proc;
336 uint8_t real_time_vote;
337} __packed;
338
339struct real_time_query_t {
340 int real_time;
341 int proc;
342} __packed;
343
344struct diag_buffering_mode_t {
345 uint8_t peripheral;
346 uint8_t mode;
347 uint8_t high_wm_val;
348 uint8_t low_wm_val;
349} __packed;
350
351struct diag_callback_reg_t {
352 int proc;
353} __packed;
354
355struct diag_ws_ref_t {
356 int ref_count;
357 int copy_count;
358 spinlock_t lock;
359};
360
361/* This structure is defined in USB header file */
362#ifndef CONFIG_DIAG_OVER_USB
363struct diag_request {
364 char *buf;
365 int length;
366 int actual;
367 int status;
368 void *context;
369};
370#endif
371
372struct diag_pkt_stats_t {
373 uint32_t alloc_count;
374 uint32_t drop_count;
375};
376
377struct diag_cmd_stats_rsp_t {
378 struct diag_pkt_header_t header;
379 uint32_t payload;
380};
381
382struct diag_cmd_hdlc_disable_rsp_t {
383 struct diag_pkt_header_t header;
384 uint8_t framing_version;
385 uint8_t result;
386};
387
388struct diag_pkt_frame_t {
389 uint8_t start;
390 uint8_t version;
391 uint16_t length;
392};
393
394struct diag_partial_pkt_t {
395 uint32_t total_len;
396 uint32_t read_len;
397 uint32_t remaining;
398 uint32_t capacity;
399 uint8_t processing;
400 unsigned char *data;
401} __packed;
402
403struct diag_logging_mode_param_t {
404 uint32_t req_mode;
405 uint32_t peripheral_mask;
406 uint8_t mode_param;
407} __packed;
408
409struct diag_md_session_t {
410 int pid;
411 int peripheral_mask;
412 uint8_t hdlc_disabled;
413 struct timer_list hdlc_reset_timer;
414 struct diag_mask_info *msg_mask;
415 struct diag_mask_info *log_mask;
416 struct diag_mask_info *event_mask;
417 struct task_struct *task;
418};
419
420/*
421 * High level structure for storing Diag masks.
422 *
423 * @ptr: Pointer to the buffer that stores the masks
424 * @mask_len: Length of the buffer pointed by ptr
425 * @update_buf: Buffer for performing mask updates to peripherals
426 * @update_buf_len: Length of the buffer pointed by buf
427 * @status: status of the mask - all enable, disabled, valid
428 * @lock: To protect access to the mask variables
429 */
430struct diag_mask_info {
431 uint8_t *ptr;
432 int mask_len;
433 uint8_t *update_buf;
434 int update_buf_len;
435 uint8_t status;
436 struct mutex lock;
437};
438
439struct diag_md_proc_info {
440 int pid;
441 struct task_struct *socket_process;
442 struct task_struct *callback_process;
443 struct task_struct *mdlog_process;
444};
445
446struct diag_feature_t {
447 uint8_t feature_mask[FEATURE_MASK_LEN];
448 uint8_t rcvd_feature_mask;
449 uint8_t log_on_demand;
450 uint8_t separate_cmd_rsp;
451 uint8_t encode_hdlc;
452 uint8_t peripheral_buffering;
453 uint8_t mask_centralization;
454 uint8_t stm_support;
455 uint8_t sockets_enabled;
456 uint8_t sent_feature_mask;
457};
458
459struct diagchar_dev {
460
461 /* State for the char driver */
462 unsigned int major;
463 unsigned int minor_start;
464 int num;
465 struct cdev *cdev;
466 char *name;
467 struct class *diagchar_class;
468 struct device *diag_dev;
469 int ref_count;
470 int mask_clear;
471 struct mutex diag_maskclear_mutex;
472 struct mutex diagchar_mutex;
473 struct mutex diag_file_mutex;
474 wait_queue_head_t wait_q;
475 struct diag_client_map *client_map;
476 int *data_ready;
477 int num_clients;
478 int polling_reg_flag;
479 int use_device_tree;
480 int supports_separate_cmdrsp;
481 int supports_apps_hdlc_encoding;
482 int supports_sockets;
483 /* The state requested in the STM command */
484 int stm_state_requested[NUM_STM_PROCESSORS];
485 /* The current STM state */
486 int stm_state[NUM_STM_PROCESSORS];
487 uint16_t stm_peripheral;
488 struct work_struct stm_update_work;
489 uint16_t mask_update;
490 struct work_struct mask_update_work;
491 uint16_t close_transport;
492 struct work_struct close_transport_work;
493 struct workqueue_struct *cntl_wq;
494 struct mutex cntl_lock;
495 /* Whether or not the peripheral supports STM */
496 /* Delayed response Variables */
497 uint16_t delayed_rsp_id;
498 struct mutex delayed_rsp_mutex;
499 /* DCI related variables */
500 struct list_head dci_req_list;
501 struct list_head dci_client_list;
502 int dci_tag;
503 int dci_client_id;
504 struct mutex dci_mutex;
505 int num_dci_client;
506 unsigned char *apps_dci_buf;
507 int dci_state;
508 struct workqueue_struct *diag_dci_wq;
509 struct list_head cmd_reg_list;
510 struct mutex cmd_reg_mutex;
511 uint32_t cmd_reg_count;
512 struct mutex diagfwd_channel_mutex;
513 /* Sizes that reflect memory pool sizes */
514 unsigned int poolsize;
515 unsigned int poolsize_hdlc;
516 unsigned int poolsize_dci;
517 unsigned int poolsize_user;
518 /* Buffers for masks */
519 struct mutex diag_cntl_mutex;
520 /* Members for Sending response */
521 unsigned char *encoded_rsp_buf;
522 int encoded_rsp_len;
523 uint8_t rsp_buf_busy;
524 spinlock_t rsp_buf_busy_lock;
525 int rsp_buf_ctxt;
526 struct diagfwd_info *diagfwd_data[NUM_PERIPHERALS];
527 struct diagfwd_info *diagfwd_cntl[NUM_PERIPHERALS];
528 struct diagfwd_info *diagfwd_dci[NUM_PERIPHERALS];
529 struct diagfwd_info *diagfwd_cmd[NUM_PERIPHERALS];
530 struct diagfwd_info *diagfwd_dci_cmd[NUM_PERIPHERALS];
531 struct diag_feature_t feature[NUM_PERIPHERALS];
532 struct diag_buffering_mode_t buffering_mode[NUM_PERIPHERALS];
533 uint8_t buffering_flag[NUM_PERIPHERALS];
534 struct mutex mode_lock;
535 unsigned char *user_space_data_buf;
536 uint8_t user_space_data_busy;
537 struct diag_pkt_stats_t msg_stats;
538 struct diag_pkt_stats_t log_stats;
539 struct diag_pkt_stats_t event_stats;
540 /* buffer for updating mask to peripherals */
541 unsigned char *buf_feature_mask_update;
542 uint8_t hdlc_disabled;
543 struct mutex hdlc_disable_mutex;
544 struct timer_list hdlc_reset_timer;
545 struct mutex diag_hdlc_mutex;
546 unsigned char *hdlc_buf;
547 uint32_t hdlc_buf_len;
548 unsigned char *apps_rsp_buf;
549 struct diag_partial_pkt_t incoming_pkt;
550 int in_busy_pktdata;
551 /* Variables for non real time mode */
552 int real_time_mode[DIAG_NUM_PROC];
553 int real_time_update_busy;
554 uint16_t proc_active_mask;
555 uint16_t proc_rt_vote_mask[DIAG_NUM_PROC];
556 struct mutex real_time_mutex;
557 struct work_struct diag_real_time_work;
558 struct workqueue_struct *diag_real_time_wq;
559#ifdef CONFIG_DIAG_OVER_USB
560 int usb_connected;
561#endif
562 struct workqueue_struct *diag_wq;
563 struct work_struct diag_drain_work;
564 struct work_struct update_user_clients;
565 struct work_struct update_md_clients;
566 struct workqueue_struct *diag_cntl_wq;
567 uint8_t log_on_demand_support;
568 uint8_t *apps_req_buf;
569 uint32_t apps_req_buf_len;
570 uint8_t *dci_pkt_buf; /* For Apps DCI packets */
571 uint32_t dci_pkt_length;
572 int in_busy_dcipktdata;
573 int logging_mode;
574 int logging_mask;
575 int mask_check;
576 uint32_t md_session_mask;
577 uint8_t md_session_mode;
578 struct diag_md_session_t *md_session_map[NUM_MD_SESSIONS];
579 struct mutex md_session_lock;
580 /* Power related variables */
581 struct diag_ws_ref_t dci_ws;
582 struct diag_ws_ref_t md_ws;
583 /* Pointers to Diag Masks */
584 struct diag_mask_info *msg_mask;
585 struct diag_mask_info *log_mask;
586 struct diag_mask_info *event_mask;
587 struct diag_mask_info *build_time_mask;
588 uint8_t msg_mask_tbl_count;
589 uint16_t event_mask_size;
590 uint16_t last_event_id;
591 /* Variables for Mask Centralization */
592 uint16_t num_event_id[NUM_PERIPHERALS];
593 uint32_t num_equip_id[NUM_PERIPHERALS];
594 uint32_t max_ssid_count[NUM_PERIPHERALS];
595#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
596 /* For sending command requests in callback mode */
597 unsigned char *hdlc_encode_buf;
598 int hdlc_encode_buf_len;
599#endif
600 int time_sync_enabled;
601 uint8_t uses_time_api;
602};
603
604extern struct diagchar_dev *driver;
605
606extern int wrap_enabled;
607extern uint16_t wrap_count;
608
609void diag_get_timestamp(char *time_str);
610void check_drain_timer(void);
611int diag_get_remote(int remote_info);
612
613void diag_ws_init(void);
614void diag_ws_on_notify(void);
615void diag_ws_on_read(int type, int pkt_len);
616void diag_ws_on_copy(int type);
617void diag_ws_on_copy_fail(int type);
618void diag_ws_on_copy_complete(int type);
619void diag_ws_reset(int type);
620void diag_ws_release(void);
621void chk_logging_wakeup(void);
622int diag_cmd_add_reg(struct diag_cmd_reg_entry_t *new_entry, uint8_t proc,
623 int pid);
624struct diag_cmd_reg_entry_t *diag_cmd_search(
625 struct diag_cmd_reg_entry_t *entry,
626 int proc);
627void diag_cmd_remove_reg(struct diag_cmd_reg_entry_t *entry, uint8_t proc);
628void diag_cmd_remove_reg_by_pid(int pid);
629void diag_cmd_remove_reg_by_proc(int proc);
630int diag_cmd_chk_polling(struct diag_cmd_reg_entry_t *entry);
631void diag_clear_masks(struct diag_md_session_t *info);
632
633void diag_record_stats(int type, int flag);
634
635struct diag_md_session_t *diag_md_session_get_pid(int pid);
636struct diag_md_session_t *diag_md_session_get_peripheral(uint8_t peripheral);
637
638#endif