Skip to content

Commit

Permalink
[servers/console] Add new activate flag
Browse files Browse the repository at this point in the history
This flag is to be used by cludio, and by cluido only, to ensure that
the cluido console is always made visible when created; other servers
have a lower pirority. This is important to give the user a decent
experience when running e.g. the chaos Docker container, using a
pre-compiled chaos .iso image etc.

Closes #45; there are still some issues with the kernel log console (as
being created by the log server) not being visible, but I will create a
separate issue for that before merging this one.
  • Loading branch information
perlun committed Nov 10, 2018
1 parent eab58d6 commit 6a50ee9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
9 changes: 5 additions & 4 deletions libraries/console/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ return_type console_init(console_structure_type *console_structure, tag_type *ta

// Allocate and open a new console with the specified attributes.

// FIXME: If input parameters are all zero (except for mode_type), a default mode with the requested type should be set and the
// attributes of that mode should be returned.
return_type console_open(console_structure_type *console_structure, unsigned int width, unsigned int height, unsigned int depth,
int mode_type)
// FIXME: If input parameters are all zero (except for mode_type), a default mode with the requested
// type should be set and the attributes of that mode should be returned.
return_type console_open(console_structure_type *console_structure, unsigned int width,
unsigned int height, unsigned int depth, int mode_type, bool activate)
{
if (!console_structure->initialised)
{
Expand All @@ -67,6 +67,7 @@ return_type console_open(console_structure_type *console_structure, unsigned int
console_attribute.height = height;
console_attribute.depth = depth;
console_attribute.mode_type = mode_type;
console_attribute.activate = activate;

message_parameter_type message_parameter;
message_parameter.protocol = IPC_PROTOCOL_CONSOLE;
Expand Down
29 changes: 18 additions & 11 deletions libraries/console/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@

C_EXTERN_BEGIN

extern return_type console_init(console_structure_type *console_structure, tag_type *tag, unsigned int connection_class);
extern return_type console_open(console_structure_type *console_structure, unsigned int width, unsigned int height,
unsigned int depth, int mode_type);
extern return_type console_mode_set(console_structure_type *console_structure, unsigned int width, unsigned int height,
unsigned int depth, int mode_type);
extern return_type console_init(console_structure_type *console_structure, tag_type *tag,
unsigned int connection_class);
extern return_type console_open(console_structure_type *console_structure, unsigned int width,
unsigned int height, unsigned int depth, int mode_type, bool activate);
extern return_type console_mode_set(console_structure_type *console_structure, unsigned int width,
unsigned int height, unsigned int depth, int mode_type);

extern return_type console_resize(console_structure_type *console_structure, unsigned int width, unsigned int height);
extern return_type console_resize(console_structure_type *console_structure, unsigned int width,
unsigned int height);
extern return_type console_print(console_structure_type *console_structure, const char *string);
extern return_type console_print_formatted(console_structure_type *console_structure, const char *string, ...);
extern return_type console_print_formatted(console_structure_type *console_structure,
const char *string, ...);
// __attribute__ ((format (printf, 1, 2)));
extern return_type console_clear(console_structure_type *console_structure);
extern return_type console_cursor_move(console_structure_type *console_structure, unsigned int x, unsigned int y);
extern return_type console_attribute_set(console_structure_type *console_structure, int foreground, int background, int attributes);
extern return_type console_cursor_appearance_set(console_structure_type *console_structure, bool visibility, bool block);
extern return_type console_cursor_move(console_structure_type *console_structure, unsigned int x,
unsigned int y);
extern return_type console_attribute_set(console_structure_type *console_structure, int foreground,
int background, int attributes);
extern return_type console_cursor_appearance_set(console_structure_type *console_structure,
bool visibility, bool block);
extern return_type console_use_keyboard(console_structure_type *console_structure, bool which, int type);
extern return_type console_use_mouse(console_structure_type *console_structure, bool which);
extern return_type console_event_wait(console_structure_type *console_structure, void *event_data, int *type, bool block);
extern return_type console_event_wait(console_structure_type *console_structure, void *event_data,
int *type, bool block);

C_EXTERN_END
1 change: 1 addition & 0 deletions libraries/ipc/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ typedef struct
unsigned int height;
unsigned int depth;
unsigned int mode_type;
bool activate;
} ipc_console_attribute_type;
6 changes: 4 additions & 2 deletions programs/cluido/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ int main(void)
system_thread_name_set("Initialising");

// First of all, initiate a connection to the console service.
if (console_init(&console_structure, &empty_tag, IPC_CONSOLE_CONNECTION_CLASS_CLIENT) != CONSOLE_RETURN_SUCCESS)
if (console_init(&console_structure, &empty_tag, IPC_CONSOLE_CONNECTION_CLASS_CLIENT) !=
CONSOLE_RETURN_SUCCESS)
{
return -1;
}

if (console_open(&console_structure, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) != CONSOLE_RETURN_SUCCESS)
if (console_open(&console_structure, 80, 50, 4, VIDEO_MODE_TYPE_TEXT, TRUE) !=
CONSOLE_RETURN_SUCCESS)
{
return -1;
}
Expand Down
4 changes: 3 additions & 1 deletion servers/system/console/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ static void connection_client(message_parameter_type *message_parameter, console
(*our_application)->ipc_structure.input_mailbox_id = ipc_structure->input_mailbox_id;
(*our_application)->ipc_structure.output_mailbox_id = ipc_structure->output_mailbox_id;

if (current_console == NULL)
// The client opening a console can set the activate flag, to enable switching to
// the newly created console.
if (console_attribute->activate && current_console == NULL)
{
current_console = *our_console;
(*our_console)->output = screen;
Expand Down
4 changes: 2 additions & 2 deletions servers/system/log/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static return_type handle_server_logging(void)
return -1;
}

if (console_open(&console_structure_server, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) !=
if (console_open(&console_structure_server, 80, 50, 4, VIDEO_MODE_TYPE_TEXT, FALSE) !=
CONSOLE_RETURN_SUCCESS)
{
return -1;
Expand Down Expand Up @@ -207,7 +207,7 @@ static void handle_kernel_logging(void *argument UNUSED)
return;
}

if (console_open(&console_structure_kernel, 80, 50, 4, VIDEO_MODE_TYPE_TEXT) !=
if (console_open(&console_structure_kernel, 80, 50, 4, VIDEO_MODE_TYPE_TEXT, FALSE) !=
CONSOLE_RETURN_SUCCESS)
{
return;
Expand Down

0 comments on commit 6a50ee9

Please sign in to comment.