Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 22:38:16 +00:00
|
|
|
/*
|
2016-09-03 21:46:10 +00:00
|
|
|
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Jonas 'Sortie' Termansen.
|
Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 22:38:16 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* sortix/kernel/log.h
|
|
|
|
* A system for logging various messages to the kernel log.
|
|
|
|
*/
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2022-07-07 23:09:15 +00:00
|
|
|
#ifndef _INCLUDE_SORTIX_KERNEL_LOG_H
|
|
|
|
#define _INCLUDE_SORTIX_KERNEL_LOG_H
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2013-09-23 19:20:00 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
2012-09-22 19:09:33 +00:00
|
|
|
#include <stdio.h>
|
2014-08-13 17:15:20 +00:00
|
|
|
#include <stdint.h>
|
2012-09-22 19:09:33 +00:00
|
|
|
#include <string.h>
|
2011-08-05 12:25:00 +00:00
|
|
|
|
2015-03-19 13:27:28 +00:00
|
|
|
typedef struct multiboot_info multiboot_info_t;
|
|
|
|
|
|
|
|
namespace Sortix {
|
|
|
|
|
2016-09-03 21:46:10 +00:00
|
|
|
class TextBuffer;
|
2015-03-19 13:27:28 +00:00
|
|
|
class TextBufferHandle;
|
|
|
|
|
|
|
|
} // namespace Sortix
|
|
|
|
|
2013-09-23 19:20:00 +00:00
|
|
|
namespace Sortix {
|
|
|
|
namespace Log {
|
|
|
|
|
2015-03-19 23:08:08 +00:00
|
|
|
extern uint8_t* fallback_framebuffer;
|
|
|
|
extern size_t fallback_framebuffer_bpp;
|
|
|
|
extern size_t fallback_framebuffer_pitch;
|
|
|
|
extern size_t fallback_framebuffer_width;
|
|
|
|
extern size_t fallback_framebuffer_height;
|
|
|
|
|
2015-03-19 13:27:28 +00:00
|
|
|
extern TextBufferHandle* device_textbufhandle;
|
2013-09-23 19:20:00 +00:00
|
|
|
extern size_t (*device_callback)(void*, const char*, size_t);
|
2016-11-05 14:23:41 +00:00
|
|
|
extern size_t (*device_writeraw)(void*, const char*, size_t);
|
2013-09-23 19:20:00 +00:00
|
|
|
extern size_t (*device_width)(void*);
|
|
|
|
extern size_t (*device_height)(void*);
|
2013-12-20 20:55:05 +00:00
|
|
|
extern void (*device_get_cursor)(void*, size_t*, size_t*);
|
2013-09-23 19:20:00 +00:00
|
|
|
extern bool (*device_sync)(void*);
|
2015-05-10 18:28:33 +00:00
|
|
|
extern void (*device_invalidate)(void*);
|
2013-09-23 19:20:00 +00:00
|
|
|
extern void* device_pointer;
|
2013-11-11 21:21:56 +00:00
|
|
|
extern bool (*emergency_device_is_impaired)(void*);
|
|
|
|
extern bool (*emergency_device_recoup)(void*);
|
|
|
|
extern void (*emergency_device_reset)(void*);
|
|
|
|
extern size_t (*emergency_device_callback)(void*, const char*, size_t);
|
2016-11-05 14:23:41 +00:00
|
|
|
extern size_t (*emergency_device_writeraw)(void*, const char*, size_t);
|
2013-11-11 21:21:56 +00:00
|
|
|
extern size_t (*emergency_device_width)(void*);
|
|
|
|
extern size_t (*emergency_device_height)(void*);
|
2013-12-20 20:55:05 +00:00
|
|
|
extern void (*emergency_device_get_cursor)(void*, size_t*, size_t*);
|
2013-11-11 21:21:56 +00:00
|
|
|
extern bool (*emergency_device_sync)(void*);
|
|
|
|
extern void* emergency_device_pointer;
|
2013-09-23 19:20:00 +00:00
|
|
|
|
|
|
|
inline void Flush()
|
2011-08-05 12:25:00 +00:00
|
|
|
{
|
2013-09-23 19:20:00 +00:00
|
|
|
device_callback(device_pointer, NULL, 0);
|
2011-08-05 12:25:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 19:20:00 +00:00
|
|
|
inline size_t Width()
|
|
|
|
{
|
|
|
|
return device_width(device_pointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t Height()
|
|
|
|
{
|
|
|
|
return device_height(device_pointer);
|
|
|
|
}
|
|
|
|
|
2013-12-20 20:55:05 +00:00
|
|
|
inline void GetCursor(size_t* col, size_t* row)
|
|
|
|
{
|
|
|
|
return device_get_cursor(device_pointer, col, row);
|
|
|
|
}
|
|
|
|
|
2013-09-23 19:20:00 +00:00
|
|
|
inline bool Sync()
|
|
|
|
{
|
|
|
|
return device_sync(device_pointer);
|
|
|
|
}
|
|
|
|
|
2015-05-10 18:28:33 +00:00
|
|
|
inline void Invalidate()
|
|
|
|
{
|
|
|
|
return device_invalidate(device_pointer);
|
|
|
|
}
|
|
|
|
|
2013-09-23 19:20:00 +00:00
|
|
|
inline size_t Print(const char* str)
|
|
|
|
{
|
|
|
|
return device_callback(device_pointer, str, strlen(str));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t PrintData(const void* ptr, size_t size)
|
|
|
|
{
|
2016-11-05 14:23:41 +00:00
|
|
|
return device_writeraw(device_pointer, (const char*) ptr, size);
|
2013-09-23 19:20:00 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 15:57:34 +00:00
|
|
|
__attribute__((format(printf, 1, 2)))
|
2013-09-23 19:20:00 +00:00
|
|
|
inline size_t PrintF(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
va_start(list, format);
|
2014-08-13 17:15:20 +00:00
|
|
|
int result = vcbprintf(device_pointer, device_callback, format, list);
|
2013-09-23 19:20:00 +00:00
|
|
|
va_end(list);
|
2014-08-13 17:15:20 +00:00
|
|
|
if ( result < 0 )
|
|
|
|
return SIZE_MAX;
|
|
|
|
return (size_t) result;
|
2013-09-23 19:20:00 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 15:57:34 +00:00
|
|
|
__attribute__((format(printf, 1, 0)))
|
2013-09-23 19:20:00 +00:00
|
|
|
inline size_t PrintFV(const char* format, va_list list)
|
|
|
|
{
|
2014-08-13 17:15:20 +00:00
|
|
|
int result = vcbprintf(device_pointer, device_callback, format, list);
|
|
|
|
if ( result < 0 )
|
|
|
|
return SIZE_MAX;
|
|
|
|
return (size_t) result;
|
2013-09-23 19:20:00 +00:00
|
|
|
}
|
|
|
|
|
2015-03-19 13:27:28 +00:00
|
|
|
void Init(multiboot_info_t* bootinfo);
|
2015-10-25 23:09:54 +00:00
|
|
|
void Center(const char* string);
|
2016-09-03 21:46:10 +00:00
|
|
|
void BeginReplace();
|
|
|
|
void CancelReplace();
|
|
|
|
void FinishReplace(TextBuffer* textbuf);
|
2015-03-19 13:27:28 +00:00
|
|
|
|
2013-09-23 19:20:00 +00:00
|
|
|
} // namespace Log
|
|
|
|
} // namespace Sortix
|
|
|
|
|
2011-08-05 12:25:00 +00:00
|
|
|
#endif
|