/******************************************************************************
*
* Module Name: osunixxf - UNIX OSL interfaces
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
/*
* These interfaces are required in order to compile the ASL compiler and the
* various ACPICA tools under Linux or other Unix-like system.
*/
#include <acpi/acpi.h>
#include "accommon.h"
#include "amlcode.h"
#include "acparser.h"
#include "acdebug.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/time.h>
#include <semaphore.h>
#include <pthread.h>
#include <errno.h>
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME("osunixxf")
/* Upcalls to acpi_exec */
void
ae_table_override(struct acpi_table_header *existing_table,
struct acpi_table_header **new_table);
typedef void *(*PTHREAD_CALLBACK) (void *);
/* Buffer used by acpi_os_vprintf */
#define ACPI_VPRINTF_BUFFER_SIZE 512
#define _ASCII_NEWLINE '\n'
/* Terminal support for acpi_exec only */
#ifdef ACPI_EXEC_APP
#include <termios.h>
struct termios original_term_attributes;
int term_attributes_were_set = 0;
acpi_status acpi_ut_read_line(char *buffer, u32 buffer_length, u32 *bytes_read);
static void os_enter_line_edit_mode(void);
static void os_exit_line_edit_mode(void);
/******************************************************************************
*
* FUNCTION: os_enter_line_edit_mode, os_exit_line_edit_mode
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Enter/Exit the raw character input mode for the terminal.
*
* Interactive line-editing support for the AML debugger. Used with the
* common/acgetline module.
*
* readline() is not used because of non-portability. It is not available
* on all systems, and if it is, often the package must be manually installed.
*
* Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line
* editing that we need in acpi_os_get_line.
*
* If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these
* calls will also work:
* For os_enter_line_edit_mode: system ("stty cbreak -echo")
* For os_exit_line_edit_mode: system ("stty cooked echo")
*
*****************************************************************************/
static void os_enter_line_edit_mode(void)
{
struct termios local_term_attributes;
term_attributes_were_set = 0;
/* STDIN must be a terminal */
if (!isatty(STDIN_FILENO)) {
return;