summaryrefslogtreecommitdiff
path: root/sos-code-article6
diff options
context:
space:
mode:
Diffstat (limited to 'sos-code-article6')
-rw-r--r--sos-code-article6/cdrom/boot/grub/stage2_eltoritobin0 -> 147440 bytes
-rw-r--r--sos-code-article6/sos.map268
-rw-r--r--sos-code-article6/sos/main.c61
3 files changed, 300 insertions, 29 deletions
diff --git a/sos-code-article6/cdrom/boot/grub/stage2_eltorito b/sos-code-article6/cdrom/boot/grub/stage2_eltorito
new file mode 100644
index 0000000..6d82f08
--- /dev/null
+++ b/sos-code-article6/cdrom/boot/grub/stage2_eltorito
Binary files differ
diff --git a/sos-code-article6/sos.map b/sos-code-article6/sos.map
new file mode 100644
index 0000000..da7c0a6
--- /dev/null
+++ b/sos-code-article6/sos.map
@@ -0,0 +1,268 @@
+002084c8 a.1066
+002077ce alloc_node_binop
+00207752 alloc_node_num
+0020781a alloc_node_unarop
+00207786 alloc_node_var
+00206dbb backtracer.1277
+00201000 __b_kernel
+00200000 __b_load
+0020833c bootstrap_stack_bottom
+00208340 bootstrap_stack_size
+00204ab7 cache_add_slab
+00204c08 cache_grow
+00204978 cache_initialize
+0020a590 cache_of_struct_kslab
+0020a58c cache_of_struct_kslab_cache
+00204cfb cache_release_slab
+00206d83 clk_it
+0021adf0 clock_count.1265
+002033e8 core_routine
+00204eaf create_cache_of_caches
+00204fd9 create_cache_of_ranges
+00203b02 create_range
+0021ae04 ctxt_hello1
+0021ae00 ctxt_hello2
+0021ae0c ctxt_main
+0021addc data_lexer_to_parser
+0021add8 data_reader_to_lexer
+0020adc0 deep_stack
+0021adf4 demand_paging_count.1288
+00206cf8 display_bits
+0020a340 double_fault_alternate_stack
+00206f1f dump_backtrace
+0021f000 __e_kernel
+00209ab9 __e_load
+00207eac eval_expression
+00207111 exit_hello12
+0020394e find_suitable_free_range
+002058fa free_object
+0020a59c free_ppage
+00207f7b free_syntax_tree
+00207e6e func_eval
+002074cd func_exit
+00207f27 func_free
+00207547 func_lexer
+00207b45 func_parser
+002074f0 func_reader
+00208348 gdt
+002038f8 get_closest_preceding_kmem_range
+00207993 get_expr
+002079ae get_expr_lr
+00207a8b get_factor
+0020788d get_number
+00207918 get_op
+002062be get_page_descr_at_paddr
+00207956 get_par
+00207b0f get_scalar
+002078ca get_str
+00207a0f get_term
+00207a2a get_term_lr
+00207133 hello1
+0021ae08 hello1_stack
+00207176 hello2
+0021adfc hello2_stack
+00209ac0 idt
+0020399e insert_range
+00208400 kmalloc_cache
+0020a580 kmem_free_range_list
+0020a588 kmem_range_cache
+0020a584 kmem_used_range_list
+0020a594 kslab_cache_list
+00203a4b lookup_range
+00201011 loop
+00206697 memcmp
+00206640 memcpy
+00206671 memset
+002086a0 msg_double_fault_not_supported
+00208780 msg_nested_level_overflow
+00201000 multiboot_entry
+00200000 multiboot_header
+0020248c paging_setup_map_helper
+00207b6c parse_expression
+0020785d parser_exception
+00206f94 pgflt_ex
+0020a598 physical_page_descr_array
+0020a5a4 physmem_base
+0020a5a8 physmem_top
+0020a5ac physmem_total_pages
+0020a5b0 physmem_used_pages
+00209308 __PRETTY_FUNCTION__.1040
+00208da6 __PRETTY_FUNCTION__.1064
+00208db3 __PRETTY_FUNCTION__.1073
+00208a54 __PRETTY_FUNCTION__.1093
+00208dc0 __PRETTY_FUNCTION__.1101
+0020885f __PRETTY_FUNCTION__.1111
+00208a80 __PRETTY_FUNCTION__.1121
+00209368 __PRETTY_FUNCTION__.1124
+00208aab __PRETTY_FUNCTION__.1131
+00208ddd __PRETTY_FUNCTION__.1132
+00208ac2 __PRETTY_FUNCTION__.1136
+00209142 __PRETTY_FUNCTION__.1137
+00208877 __PRETTY_FUNCTION__.1145
+00208ad9 __PRETTY_FUNCTION__.1145
+00209160 __PRETTY_FUNCTION__.1177
+00209187 __PRETTY_FUNCTION__.1227
+0020919c __PRETTY_FUNCTION__.1242
+002091c0 __PRETTY_FUNCTION__.1262
+00209a94 __PRETTY_FUNCTION__.1292
+00209a9d __PRETTY_FUNCTION__.1327
+00209ab0 __PRETTY_FUNCTION__.1563
+002071b9 print_hello_world
+002084c4 q.1067
+002084cc r.1068
+00206888 random
+002084c0 _random_seed
+00207c48 rec_eval.1511
+002074c8 reclaim
+002070fe reclaim_stack
+002038cf resume_pc
+00208af8 sizeof_struct_sos_kmem_range
+00206c4a snprintf
+002037f0 sos_backtrace
+002032dd sos_bochs_hexdump
+002033a2 sos_bochs_printf
+002030c2 sos_bochs_putchar
+002030ff sos_bochs_puthex
+002030da sos_bochs_putstring
+002030b8 sos_bochs_setup
+002036c1 sos_cpu_context_dump
+002038d0 sos_cpu_context_exit_to
+002037df sos_cpu_context_get_EX_faulting_vaddr
+00203798 sos_cpu_context_get_EX_info
+00203636 sos_cpu_context_get_PC
+0020367d sos_cpu_context_get_SP
+0020388c sos_cpu_context_switch
+00203437 sos_cpu_kstate_init
+0020354f sos_cpu_state_detect_kernel_stack_overflow
+00203518 sos_cpu_state_prepare_detect_kernel_stack_overflow
+00206c80 sos_display_fatal_error
+00201382 sos_exception_get_name
+00201353 sos_exception_get_routine
+0020a2c0 sos_exception_handler_array
+002012c0 sos_exception_set_routine
+00201260 sos_exception_subsystem_setup
+002013a4 sos_exception_wrapper_0
+002013e8 sos_exception_wrapper_1
+00201a48 sos_exception_wrapper_10
+00201a8c sos_exception_wrapper_11
+00201ad0 sos_exception_wrapper_12
+00201b14 sos_exception_wrapper_13
+00201b58 sos_exception_wrapper_14
+00201608 sos_exception_wrapper_15
+0020164c sos_exception_wrapper_16
+00201b9c sos_exception_wrapper_17
+00201690 sos_exception_wrapper_18
+002016d4 sos_exception_wrapper_19
+0020142c sos_exception_wrapper_2
+00201718 sos_exception_wrapper_20
+0020175c sos_exception_wrapper_21
+002017a0 sos_exception_wrapper_22
+002017e4 sos_exception_wrapper_23
+00201828 sos_exception_wrapper_24
+0020186c sos_exception_wrapper_25
+002018b0 sos_exception_wrapper_26
+002018f4 sos_exception_wrapper_27
+00201938 sos_exception_wrapper_28
+0020197c sos_exception_wrapper_29
+00201470 sos_exception_wrapper_3
+002019c0 sos_exception_wrapper_30
+00201a04 sos_exception_wrapper_31
+002014b4 sos_exception_wrapper_4
+002014f8 sos_exception_wrapper_5
+0020153c sos_exception_wrapper_6
+00201580 sos_exception_wrapper_7
+00201be0 sos_exception_wrapper_8
+002015c4 sos_exception_wrapper_9
+00208700 sos_exception_wrapper_array
+002011e4 sos_gdt_subsystem_setup
+00201218 sos_generic_ex
+00202e44 sos_i8254_set_frequency
+00202432 sos_i8259_disable_irq_line
+002023d4 sos_i8259_enable_irq_line
+00202384 sos_i8259_subsystem_setup
+00201174 sos_idt_get_handler
+002010b9 sos_idt_set_handler
+00201014 sos_idt_subsystem_setup
+00201cfe sos_irq_get_nested_level
+00201cdc sos_irq_get_routine
+0020a540 sos_irq_handler_array
+0021adf8 sos_irq_nested_level_counter
+00201c13 sos_irq_set_routine
+00201bfc sos_irq_subsystem_setup
+00201d08 sos_irq_wrapper_0
+00201d6c sos_irq_wrapper_1
+00202114 sos_irq_wrapper_10
+0020217c sos_irq_wrapper_11
+002021e4 sos_irq_wrapper_12
+0020224c sos_irq_wrapper_13
+002022b4 sos_irq_wrapper_14
+0020231c sos_irq_wrapper_15
+00201dd4 sos_irq_wrapper_2
+00201e3c sos_irq_wrapper_3
+00201ea4 sos_irq_wrapper_4
+00201f0c sos_irq_wrapper_5
+00201f74 sos_irq_wrapper_6
+00201fdc sos_irq_wrapper_7
+00202044 sos_irq_wrapper_8
+002020ac sos_irq_wrapper_9
+002087c0 sos_irq_wrapper_array
+00205e4b sos_kfree
+00205da9 sos_kmalloc
+00205ce0 sos_kmalloc_subsystem_setup
+0020565e sos_kmem_cache_alloc
+002054cb sos_kmem_cache_create
+002055cf sos_kmem_cache_destroy
+00205bc8 sos_kmem_cache_free
+00205c11 sos_kmem_cache_release_struct_range
+002054af sos_kmem_cache_subsystem_setup_commit
+002050f1 sos_kmem_cache_subsystem_setup_prepare
+0020488b sos_kmem_vmm_alloc
+0020432f sos_kmem_vmm_del_range
+002048c2 sos_kmem_vmm_free
+00204954 sos_kmem_vmm_is_valid_vaddr
+002040cf sos_kmem_vmm_new_range
+0020492b sos_kmem_vmm_resolve_slab
+0020490b sos_kmem_vmm_set_slab
+00203d52 sos_kmem_vmm_subsystem_setup
+00207fd4 sos_main
+00202d87 sos_paging_get_paddr
+00202cd7 sos_paging_get_prot
+00202851 sos_paging_map
+002026c5 sos_paging_subsystem_setup
+00202b2f sos_paging_unmap
+002065b9 sos_physmem_get_kmem_range
+00206613 sos_physmem_get_state
+0020630b sos_physmem_ref_physpage_at
+00206151 sos_physmem_ref_physpage_new
+002065e2 sos_physmem_set_kmem_range
+00205e74 sos_physmem_subsystem_setup
+0020644e sos_physmem_unref_physpage
+00208360 sos_x86_exnames
+00202edc sos_x86_videomem_cls
+00203026 sos_x86_videomem_printf
+00202faf sos_x86_videomem_putchar
+00202f1f sos_x86_videomem_putstring
+00202ebc sos_x86_videomem_setup
+002068d5 srandom
+0021b000 stack
+0020a9c0 stack_lexer
+0020a5c0 stack_reader
+00201000 start
+00201000 _start
+0021adcc st_eval
+0021add0 st_free
+0021adc4 st_lexer
+0021add4 st_main
+0021adc8 st_parser
+002067e5 strcmp
+0021adc0 st_reader
+002066f1 strlen
+00206827 strncmp
+00206716 strnlen
+0020679a strzcat
+00206749 strzcpy
+0020748d test_backtrace
+002072a2 test_demand_paging
+0020a5a0 used_ppage
+002083e0 video
+002068e2 vsnprintf
diff --git a/sos-code-article6/sos/main.c b/sos-code-article6/sos/main.c
index 37f1d68..546dbe7 100644
--- a/sos-code-article6/sos/main.c
+++ b/sos-code-article6/sos/main.c
@@ -79,7 +79,7 @@ static void dump_backtrace(const struct sos_cpu_state *cpu_state,
sos_bool_t on_console,
sos_bool_t on_bochs)
{
- static void backtracer(sos_vaddr_t PC,
+ void backtracer(sos_vaddr_t PC,
sos_vaddr_t params,
sos_ui32_t depth,
void *custom_arg)
@@ -599,24 +599,23 @@ struct syntax_node
};
};
-static void func_parser(struct syntax_node ** syntax_tree)
-{
- static struct syntax_node *alloc_node_num(int val);
- static struct syntax_node *alloc_node_var(const char * name);
- static struct syntax_node *alloc_node_binop(char op,
+// BEGIN AUX FUNCTIONS
+ struct syntax_node *alloc_node_num(int val);
+ struct syntax_node *alloc_node_var(const char * name);
+ struct syntax_node *alloc_node_binop(char op,
struct syntax_node *parm_left,
struct syntax_node *parm_right);
- static struct syntax_node *alloc_node_unarop(char op,
+ struct syntax_node *alloc_node_unarop(char op,
struct syntax_node *parm);
- static struct syntax_node * get_expr();
- static struct syntax_node * get_expr_lr(struct syntax_node *n);
- static struct syntax_node * get_term();
- static struct syntax_node * get_term_lr(struct syntax_node *n);
- static struct syntax_node * get_factor();
- static struct syntax_node * get_scalar();
+ struct syntax_node * get_expr();
+ struct syntax_node * get_expr_lr(struct syntax_node *n);
+ struct syntax_node * get_term();
+ struct syntax_node * get_term_lr(struct syntax_node *n);
+ struct syntax_node * get_factor();
+ struct syntax_node * get_scalar();
/* Create a new node to store a number */
- static struct syntax_node *alloc_node_num(int val)
+ struct syntax_node *alloc_node_num(int val)
{
struct syntax_node *n
= (struct syntax_node*) sos_kmalloc(sizeof(struct syntax_node), 0);
@@ -625,7 +624,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
return n;
}
/* Create a new node to store a variable */
- static struct syntax_node *alloc_node_var(const char * name)
+ struct syntax_node *alloc_node_var(const char * name)
{
struct syntax_node *n
= (struct syntax_node*) sos_kmalloc(sizeof(struct syntax_node), 0);
@@ -634,7 +633,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
return n;
}
/* Create a new node to store a binary operator */
- static struct syntax_node *alloc_node_binop(char op,
+ struct syntax_node *alloc_node_binop(char op,
struct syntax_node *parm_left,
struct syntax_node *parm_right)
{
@@ -647,7 +646,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
return n;
}
/* Create a new node to store a unary operator */
- static struct syntax_node *alloc_node_unarop(char op,
+ struct syntax_node *alloc_node_unarop(char op,
struct syntax_node *parm)
{
struct syntax_node *n
@@ -660,7 +659,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
/* Raise an exception: transfer control back to main context,
without unrolling the whole recursion */
- static void parser_exception(const char *str)
+ void parser_exception(const char *str)
{
sos_bochs_printf("Parser exception: %s\n", str);
sos_cpu_context_switch(& st_parser, st_main);
@@ -668,7 +667,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
/* Consume the current terminal "number" token and ask for a new
token */
- static int get_number()
+ int get_number()
{
int v;
if (data_lexer_to_parser.type != LEX_IS_NUMBER)
@@ -679,7 +678,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
}
/* Consume the current terminal "variable" token and ask for a new
token */
- static void get_str(char name[STR_VAR_MAXLEN])
+ void get_str(char name[STR_VAR_MAXLEN])
{
if (data_lexer_to_parser.type != LEX_IS_VAR)
parser_exception("Expected variable");
@@ -688,7 +687,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
}
/* Consume the current terminal "operator" token and ask for a new
token */
- static char get_op()
+ char get_op()
{
char op;
if (data_lexer_to_parser.type != LEX_IS_OPER)
@@ -699,7 +698,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
}
/* Consume the current terminal "parenthese" token and ask for a new
token */
- static void get_par()
+ void get_par()
{
if ( (data_lexer_to_parser.type != LEX_IS_OPENPAR)
&& (data_lexer_to_parser.type != LEX_IS_CLOSEPAR) )
@@ -708,13 +707,13 @@ static void func_parser(struct syntax_node ** syntax_tree)
}
/* Parse an Expression */
- static struct syntax_node * get_expr()
+ struct syntax_node * get_expr()
{
struct syntax_node *t = get_term();
return get_expr_lr(t);
}
/* Parse an Expr_lr */
- static struct syntax_node * get_expr_lr(struct syntax_node *n)
+ struct syntax_node * get_expr_lr(struct syntax_node *n)
{
if ( (data_lexer_to_parser.type == LEX_IS_OPER)
&& ( (data_lexer_to_parser.operator == '+')
@@ -728,13 +727,13 @@ static void func_parser(struct syntax_node ** syntax_tree)
return n;
}
/* Parse a Term */
- static struct syntax_node * get_term()
+ struct syntax_node * get_term()
{
struct syntax_node *f1 = get_factor();
return get_term_lr(f1);
}
/* Parse a Term_lr */
- static struct syntax_node * get_term_lr(struct syntax_node *n)
+ struct syntax_node * get_term_lr(struct syntax_node *n)
{
if ( (data_lexer_to_parser.type == LEX_IS_OPER)
&& ( (data_lexer_to_parser.operator == '*')
@@ -748,7 +747,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
return n;
}
/* Parse a Factor */
- static struct syntax_node * get_factor()
+ struct syntax_node * get_factor()
{
if ( (data_lexer_to_parser.type == LEX_IS_OPER)
&& ( (data_lexer_to_parser.operator == '-')
@@ -769,7 +768,7 @@ static void func_parser(struct syntax_node ** syntax_tree)
return get_scalar();
}
/* Parse a Scalar */
- static struct syntax_node * get_scalar()
+ struct syntax_node * get_scalar()
{
if (data_lexer_to_parser.type != LEX_IS_NUMBER)
{
@@ -780,7 +779,11 @@ static void func_parser(struct syntax_node ** syntax_tree)
return alloc_node_num(get_number());
}
+// END AUX FUNCTIONS
+
+static void func_parser(struct syntax_node ** syntax_tree)
+{
/*
* Body of the function
*/
@@ -841,7 +844,7 @@ static void func_eval(struct func_eval_params *parms)
{
/* The internal (recursive) nested function to evaluate each node of
the syntax tree */
- static int rec_eval(const struct syntax_node *n,
+ int rec_eval(const struct syntax_node *n,
const char* var_name[], int var_val[], int nb_vars)
{
switch (n->type)