diff --git a/arch/x86/real_mode_func.c b/arch/x86/real_mode_func.c new file mode 100644 index 00000000..c1755b67 --- /dev/null +++ b/arch/x86/real_mode_func.c @@ -0,0 +1,36 @@ +/* + * Copyright © 2020 Amazon.com, Inc. or its affiliates. + * 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 OWNER 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. + */ +#include +#include +#include + +extern void _long_to_real(void); + +/* FIXME: add real mode calling functionality */ +void long_to_real(void) { + dprintk("%s: Before call\n", __func__); + _long_to_real(); + dprintk("%s: After call\n", __func__); +} diff --git a/common/kernel.c b/common/kernel.c index 693c1fa1..84bc0c00 100644 --- a/common/kernel.c +++ b/common/kernel.c @@ -34,8 +34,6 @@ #include #endif -extern void _long_to_real(void); - extern int usermode_call_asm(user_func_t fn, void *fn_arg, unsigned long ret2kern_sp, unsigned long user_stack); @@ -61,14 +59,10 @@ void __naked kernel_main(void) { display_memory_map(); display_multiboot_mmap(); - if (opt_debug) { - _long_to_real(); - printk("\n After long_to_real\n"); - } - #ifdef KTF_PMU pfm_initialize(); #endif + test_main(); printk("All tasks done.\n"); diff --git a/include/arch/x86/real_mode.h b/include/arch/x86/real_mode.h new file mode 100644 index 00000000..acff7c38 --- /dev/null +++ b/include/arch/x86/real_mode.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2020 Amazon.com, Inc. or its affiliates. + * 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 OWNER 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. + */ +#ifndef KTF_REAL_MODE_H +#define KTF_REAL_MODE_H + +#ifndef __ASSEMBLY__ + +extern void long_to_real(void); + +#endif /* __ASSEMBLY__ */ + +#endif /* KTF_REAL_MODE_H */ diff --git a/tests/test.c b/tests/test.c index 48c023ea..c6b24d91 100644 --- a/tests/test.c +++ b/tests/test.c @@ -24,6 +24,7 @@ */ #include #include +#include #include #ifdef KTF_UNIT_TEST @@ -136,6 +137,9 @@ static int ktf_unit_tests(void) { cpu_freq_expect("Prototyp Amazing Foo One @ 1GHz", 1000000000); cpu_freq_expect("Prototyp Amazing Foo Two @ 1.00GHz", 1000000000); + printk("Long mode to real mode transition:\n"); + long_to_real(); + return 0; } #else