Skip to content

Commit

Permalink
tb_ -> sk_
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Philipson <[email protected]>
  • Loading branch information
rossphilipson committed Aug 20, 2021
1 parent b52a164 commit 011a1b9
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 124 deletions.
68 changes: 34 additions & 34 deletions trenchboot/skboot/common/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ static char g_linux_param_values[ARRAY_SIZE(g_linux_cmdline_options)][MAX_VALUE_
typedef struct {
const char *log_name;
uint8_t log_val;
} tb_loglvl_map_t;
} sk_loglvl_map_t;

/* map */
static const tb_loglvl_map_t g_loglvl_map[] = {
static const sk_loglvl_map_t g_loglvl_map[] = {
{ "none", SKBOOT_LOG_LEVEL_NONE },
{ "err", SKBOOT_LOG_LEVEL_ERR },
{ "warn", SKBOOT_LOG_LEVEL_WARN },
Expand All @@ -104,7 +104,7 @@ static const tb_loglvl_map_t g_loglvl_map[] = {
static const char* get_option_val(const cmdline_option_t *options, char vals[][MAX_VALUE_LEN], const char *opt_name)
{
for ( int i = 0; options[i].name != NULL; i++ ) {
if ( tb_strcmp(options[i].name, opt_name) == 0 )
if ( sk_strcmp(options[i].name, opt_name) == 0 )
return vals[i];
}
printk(SKBOOT_ERR"requested unknown option: %s\n", opt_name);
Expand All @@ -119,7 +119,7 @@ static void cmdline_parse(const char *cmdline, const cmdline_option_t *options,

/* copy default values to vals[] */
for ( i = 0; options[i].name != NULL; i++ ) {
tb_strncpy(vals[i], options[i].def_val, MAX_VALUE_LEN-1);
sk_strncpy(vals[i], options[i].def_val, MAX_VALUE_LEN-1);
vals[i][MAX_VALUE_LEN-1] = '\0';
}

Expand All @@ -137,13 +137,13 @@ static void cmdline_parse(const char *cmdline, const cmdline_option_t *options,

/* find end of current option */
const char *opt_start = p;
const char *opt_end = tb_strchr(opt_start, ' ');
const char *opt_end = sk_strchr(opt_start, ' ');
if ( opt_end == NULL )
opt_end = opt_start + tb_strlen(opt_start);
opt_end = opt_start + sk_strlen(opt_start);
p = opt_end;

/* find value part; if no value found, use default and continue */
const char *val_start = tb_strchr(opt_start, '=');
const char *val_start = sk_strchr(opt_start, '=');
if ( val_start == NULL || val_start > opt_end )
continue;
val_start++;
Expand All @@ -157,8 +157,8 @@ static void cmdline_parse(const char *cmdline, const cmdline_option_t *options,

/* value found, so copy it */
for ( i = 0; options[i].name != NULL; i++ ) {
if ( tb_strncmp(options[i].name, opt_start, opt_name_size ) == 0 ) {
tb_strncpy(vals[i], val_start, copy_size);
if ( sk_strncmp(options[i].name, opt_start, opt_name_size ) == 0 ) {
sk_strncpy(vals[i], val_start, copy_size);
vals[i][copy_size] = '\0'; /* add '\0' to the end of string */
break;
}
Expand Down Expand Up @@ -209,9 +209,9 @@ void get_skboot_loglvl(void)
unsigned int i;

for ( i = 0; i < ARRAY_SIZE(g_loglvl_map); i++ ) {
if ( tb_strncmp(loglvl, g_loglvl_map[i].log_name,
tb_strlen(g_loglvl_map[i].log_name)) == 0 ) {
loglvl += tb_strlen(g_loglvl_map[i].log_name);
if ( sk_strncmp(loglvl, g_loglvl_map[i].log_name,
sk_strlen(g_loglvl_map[i].log_name)) == 0 ) {
loglvl += sk_strlen(g_loglvl_map[i].log_name);

if ( g_loglvl_map[i].log_val == SKBOOT_LOG_LEVEL_NONE ) {
g_log_level = SKBOOT_LOG_LEVEL_NONE;
Expand Down Expand Up @@ -245,7 +245,7 @@ void get_skboot_log_targets(void)
return;

/* determine if no targets set explicitly */
if ( tb_strcmp(targets, "none") == 0 ) {
if ( sk_strcmp(targets, "none") == 0 ) {
g_log_targets = SKBOOT_LOG_TARGET_NONE; /* print nothing */
return;
}
Expand All @@ -254,15 +254,15 @@ void get_skboot_log_targets(void)
g_log_targets = SKBOOT_LOG_TARGET_NONE;

while ( *targets != '\0' ) {
if ( tb_strncmp(targets, "memory", 6) == 0 ) {
if ( sk_strncmp(targets, "memory", 6) == 0 ) {
g_log_targets |= SKBOOT_LOG_TARGET_MEMORY;
targets += 6;
}
else if ( tb_strncmp(targets, "serial", 6) == 0 ) {
else if ( sk_strncmp(targets, "serial", 6) == 0 ) {
g_log_targets |= SKBOOT_LOG_TARGET_SERIAL;
targets += 6;
}
else if ( tb_strncmp(targets, "vga", 3) == 0 ) {
else if ( sk_strncmp(targets, "vga", 3) == 0 ) {
g_log_targets |= SKBOOT_LOG_TARGET_VGA;
targets += 3;
}
Expand All @@ -279,15 +279,15 @@ void get_skboot_log_targets(void)
static bool parse_pci_bdf(const char **bdf, uint32_t *bus, uint32_t *slot,
uint32_t *func)
{
*bus = tb_strtoul(*bdf, (char **)bdf, 16);
*bus = sk_strtoul(*bdf, (char **)bdf, 16);
if ( **bdf != ':' )
return false;
(*bdf)++;
*slot = tb_strtoul(*bdf, (char **)bdf, 16);
*slot = sk_strtoul(*bdf, (char **)bdf, 16);
if ( **bdf != '.' )
return false;
(*bdf)++;
*func = tb_strtoul(*bdf, (char **)bdf, 16);
*func = sk_strtoul(*bdf, (char **)bdf, 16);

return true;
}
Expand Down Expand Up @@ -327,7 +327,7 @@ static bool parse_com_fmt(const char **fmt)


/* must specify all values */
if ( tb_strlen(*fmt) < 3 )
if ( sk_strlen(*fmt) < 3 )
return false;

/* data bits */
Expand Down Expand Up @@ -360,15 +360,15 @@ static bool parse_com_fmt(const char **fmt)
static bool parse_serial_param(const char *com)
{
/* parse baud */
g_com_port.comc_curspeed = tb_strtoul(com, (char **)&com, 10);
g_com_port.comc_curspeed = sk_strtoul(com, (char **)&com, 10);
if ( (g_com_port.comc_curspeed < 1200) ||
(g_com_port.comc_curspeed > 115200) )
return false;

/* parse clock hz */
if ( *com == '/' ) {
++com;
g_com_port.comc_clockhz = tb_strtoul(com, (char **)&com, 0) << 4;
g_com_port.comc_clockhz = sk_strtoul(com, (char **)&com, 0) << 4;
if ( g_com_port.comc_clockhz == 0 )
return false;
}
Expand All @@ -386,15 +386,15 @@ static bool parse_serial_param(const char *com)
if ( *com != ',' )
goto exit;
++com;
g_com_port.comc_port = tb_strtoul(com, (char **)&com, 0);
g_com_port.comc_port = sk_strtoul(com, (char **)&com, 0);
if ( g_com_port.comc_port == 0 )
return false;

/* parse irq */
if ( *com != ',' )
goto exit;
++com;
g_com_port.comc_irq = tb_strtoul(com, (char **)&com, 10);
g_com_port.comc_irq = sk_strtoul(com, (char **)&com, 10);
if ( g_com_port.comc_irq == 0 )
return false;

Expand Down Expand Up @@ -433,7 +433,7 @@ void get_skboot_vga_delay(void)
if ( vga_delay == NULL )
return;

g_vga_delay = tb_strtoul(vga_delay, NULL, 0);
g_vga_delay = sk_strtoul(vga_delay, NULL, 0);
}

extern uint32_t g_min_ram;
Expand All @@ -444,7 +444,7 @@ void get_skboot_min_ram(void)
if ( min_ram == NULL )
return;

g_min_ram = tb_strtoul(min_ram, NULL, 0);
g_min_ram = sk_strtoul(min_ram, NULL, 0);
}

uint32_t get_error_shutdown(void)
Expand All @@ -454,11 +454,11 @@ uint32_t get_error_shutdown(void)
g_skboot_param_values,
"error_shutdown");
if ( error_shutdown != NULL ) {
if ( tb_strcmp(error_shutdown, "reboot") == 0 )
if ( sk_strcmp(error_shutdown, "reboot") == 0 )
return SK_SHUTDOWN_REBOOT;
if ( tb_strcmp(error_shutdown, "shutdown") == 0 )
if ( sk_strcmp(error_shutdown, "shutdown") == 0 )
return SK_SHUTDOWN_SHUTDOWN;
if ( tb_strcmp(error_shutdown, "halt") == 0 )
if ( sk_strcmp(error_shutdown, "halt") == 0 )
return SK_SHUTDOWN_HALT;
}

Expand All @@ -477,14 +477,14 @@ bool get_linux_vga(int *vid_mode)
if ( vga == NULL || vid_mode == NULL )
return false;

if ( tb_strcmp(vga, "normal") == 0 )
if ( sk_strcmp(vga, "normal") == 0 )
*vid_mode = 0xFFFF;
else if ( tb_strcmp(vga, "ext") == 0 )
else if ( sk_strcmp(vga, "ext") == 0 )
*vid_mode = 0xFFFE;
else if ( tb_strcmp(vga, "ask") == 0 )
else if ( sk_strcmp(vga, "ask") == 0 )
*vid_mode = 0xFFFD;
else
*vid_mode = tb_strtoul(vga, NULL, 0);
*vid_mode = sk_strtoul(vga, NULL, 0);

return true;
}
Expand All @@ -497,7 +497,7 @@ bool get_linux_mem(uint64_t *max_mem)
if ( mem == NULL || max_mem == NULL )
return false;

*max_mem = tb_strtoul(mem, &last, 0);
*max_mem = sk_strtoul(mem, &last, 0);
if ( *max_mem == 0 )
return false;

Expand Down
26 changes: 13 additions & 13 deletions trenchboot/skboot/common/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ printk_long(const char *what)
{
/* chunk the command line into 70 byte chunks */
#define CHUNK_SIZE 70
int cmdlen = tb_strlen(what);
int cmdlen = sk_strlen(what);
const char *cptr = what;
char cmdchunk[CHUNK_SIZE+1];
while (cmdlen > 0) {
tb_strncpy(cmdchunk, cptr, CHUNK_SIZE);
sk_strncpy(cmdchunk, cptr, CHUNK_SIZE);
cmdchunk[CHUNK_SIZE] = 0;
printk(SKBOOT_INFO"\t%s\n", cmdchunk);
cmdlen -= CHUNK_SIZE;
Expand Down Expand Up @@ -220,7 +220,7 @@ bool expand_linux_image(const void *linux_image, size_t linux_size,
}
}

tb_memmove((void *)initrd_base, initrd_image, initrd_size);
sk_memmove((void *)initrd_base, initrd_image, initrd_size);
printk(SKBOOT_DETA"Initrd from 0x%lx to 0x%lx\n",
(unsigned long)initrd_base,
(unsigned long)(initrd_base + initrd_size));
Expand Down Expand Up @@ -305,17 +305,17 @@ bool expand_linux_image(const void *linux_image, size_t linux_size,
}

/* save linux header struct to temp memory to copy changes to zero page */
tb_memmove(&temp_hdr, hdr, sizeof(temp_hdr));
sk_memmove(&temp_hdr, hdr, sizeof(temp_hdr));

/* load real-mode part */
tb_memmove((void *)real_mode_base, linux_image, real_mode_size);
sk_memmove((void *)real_mode_base, linux_image, real_mode_size);
printk(SKBOOT_DETA"Kernel (real mode) from 0x%lx to 0x%lx size: 0x%lx\n",
(unsigned long)linux_image,
(unsigned long)real_mode_base,
(unsigned long)real_mode_size);

/* load protected-mode part */
tb_memmove((void *)protected_mode_base, linux_image + real_mode_size,
sk_memmove((void *)protected_mode_base, linux_image + real_mode_size,
protected_mode_size);
printk(SKBOOT_DETA"Kernel (protected mode) from 0x%lx to 0x%lx size: 0x%lx\n",
(unsigned long)(linux_image + real_mode_size),
Expand All @@ -326,7 +326,7 @@ bool expand_linux_image(const void *linux_image, size_t linux_size,
hdr = (linux_kernel_header_t *)(real_mode_base + KERNEL_HEADER_OFFSET);

/* copy back the updated kernel header */
tb_memmove(hdr, &temp_hdr, sizeof(temp_hdr));
sk_memmove(hdr, &temp_hdr, sizeof(temp_hdr));

/* set cmd_line_ptr */
hdr->cmd_line_ptr = real_mode_base + KERNEL_CMDLINE_OFFSET;
Expand All @@ -338,11 +338,11 @@ bool expand_linux_image(const void *linux_image, size_t linux_size,
return false;
}
const size_t kernel_cmdline_size = REAL_END_OFFSET - KERNEL_CMDLINE_OFFSET;
size_t kernel_cmdline_strlen = tb_strlen(kernel_cmdline);
size_t kernel_cmdline_strlen = sk_strlen(kernel_cmdline);
if (kernel_cmdline_strlen > kernel_cmdline_size - 1)
kernel_cmdline_strlen = kernel_cmdline_size - 1;
tb_memset((void *)hdr->cmd_line_ptr, 0, kernel_cmdline_size);
tb_memcpy((void *)hdr->cmd_line_ptr, kernel_cmdline, kernel_cmdline_strlen);
sk_memset((void *)hdr->cmd_line_ptr, 0, kernel_cmdline_size);
sk_memcpy((void *)hdr->cmd_line_ptr, kernel_cmdline, kernel_cmdline_strlen);

printk(SKBOOT_INFO"Linux cmdline from 0x%lx to 0x%lx:\n",
(unsigned long)hdr->cmd_line_ptr,
Expand Down Expand Up @@ -380,7 +380,7 @@ bool expand_linux_image(const void *linux_image, size_t linux_size,
uint32_t descr_size = 0, descr_vers = 0, mmap_size = 0, efi_mmap_addr = 0;

/* loader signature */
tb_memcpy(&efi->efi_ldr_sig, "EL64", sizeof(uint32_t));
sk_memcpy(&efi->efi_ldr_sig, "EL64", sizeof(uint32_t));

/* EFI system table addr */
{
Expand Down Expand Up @@ -459,8 +459,8 @@ bool expand_linux_image(const void *linux_image, size_t linux_size,
}

/* Clear out some boot_params we don't want dangling around */
tb_memset((void *)boot_params->skboot_shared_addr, 0, 8);
tb_memset((void *)boot_params->acpi_rsdp_addr, 0, 8);
sk_memset((void *)boot_params->skboot_shared_addr, 0, 8);
sk_memset((void *)boot_params->acpi_rsdp_addr, 0, 8);

/* Copy all the handoff information about the loaded IL kernel */
g_il_kernel_setup.real_mode_base = real_mode_base;
Expand Down
Loading

0 comments on commit 011a1b9

Please sign in to comment.