2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-10-16 12:01:38 +03:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-06 15:29:29 +03:00
|
|
|
#include <AK/Types.h>
|
2018-10-16 12:01:38 +03:00
|
|
|
|
2020-01-05 23:51:06 +03:00
|
|
|
namespace AK {
|
|
|
|
class String;
|
|
|
|
}
|
|
|
|
|
2020-01-10 23:26:47 +03:00
|
|
|
namespace Syscall {
|
|
|
|
struct StringArgument;
|
|
|
|
}
|
|
|
|
|
2020-01-05 23:51:06 +03:00
|
|
|
AK::String copy_string_from_user(const char*, size_t);
|
|
|
|
|
2018-11-09 14:20:44 +03:00
|
|
|
extern "C" {
|
|
|
|
|
2019-02-22 12:23:06 +03:00
|
|
|
static_assert(sizeof(size_t) == 4);
|
|
|
|
|
2020-01-19 11:14:14 +03:00
|
|
|
void copy_to_user(void*, const void*, size_t);
|
|
|
|
void copy_from_user(void*, const void*, size_t);
|
|
|
|
void memset_user(void*, int, size_t);
|
2020-01-05 20:00:15 +03:00
|
|
|
|
2019-02-22 12:23:06 +03:00
|
|
|
void* memcpy(void*, const void*, size_t);
|
|
|
|
char* strcpy(char*, const char*);
|
2019-02-07 12:29:26 +03:00
|
|
|
char* strncpy(char*, const char*, size_t);
|
Kernel: Introduce the ACPI subsystem
ACPI subsystem includes 3 types of parsers that are created during
runtime, each one capable of parsing ACPI tables at different level.
ACPIParser is the most basic parser which is essentialy a parser that
can't parse anything useful, due to a user request to disable ACPI
support in a kernel boot parameter.
ACPIStaticParser is a derived class from ACPIParser, which is able to
parse only static data (e.g. FADT, HPET, MCFG and other tables), thus
making it not able to parse AML (ACPI Machine Language) nor to support
handling of hardware events and power management. This type of parser
can be created with a kernel boot parameter.
ACPIDynamicParser is a derived class from ACPIStaticParser, which
includes all the capabilities of the latter, but *should* implement an
AML interpretation, (by building the ACPI AML namespace) and handling
power & hardware events. Currently the methods to support AML
interpretation are not implemented.
This type of parser is created automatically during runtime if the user
didn't specify a boot parameter related to ACPI initialization.
Also, adding strncmp function definition in StdLib.h, to be able to use
it in ACPIStaticParser class.
2019-12-31 14:01:09 +03:00
|
|
|
int strncmp(const char* s1, const char* s2, size_t n);
|
2018-10-17 11:55:43 +03:00
|
|
|
int strcmp(char const*, const char*);
|
2018-12-03 01:34:50 +03:00
|
|
|
size_t strlen(const char*);
|
2019-08-10 18:01:33 +03:00
|
|
|
size_t strnlen(const char*, size_t);
|
2019-02-22 12:23:06 +03:00
|
|
|
void* memset(void*, int, size_t);
|
2019-05-28 12:53:16 +03:00
|
|
|
char* strdup(const char*);
|
2018-10-17 11:55:43 +03:00
|
|
|
int memcmp(const void*, const void*, size_t);
|
2018-11-01 00:43:49 +03:00
|
|
|
char* strrchr(const char* str, int ch);
|
2019-03-24 00:03:17 +03:00
|
|
|
void* memmove(void* dest, const void* src, size_t n);
|
2018-11-09 14:20:44 +03:00
|
|
|
|
2019-07-03 22:17:35 +03:00
|
|
|
inline u16 ntohs(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
|
|
|
|
inline u16 htons(u16 w) { return (w & 0xff) << 8 | ((w >> 8) & 0xff); }
|
2018-11-09 14:20:44 +03:00
|
|
|
}
|
2020-01-11 12:27:37 +03:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline void copy_from_user(T* dest, const T* src)
|
|
|
|
{
|
|
|
|
copy_from_user(dest, src, sizeof(T));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline void copy_to_user(T* dest, const T* src)
|
|
|
|
{
|
|
|
|
copy_to_user(dest, src, sizeof(T));
|
|
|
|
}
|