Skip to content

Commit

Permalink
Add experimental/WIP unicorn emulation for linux kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Nov 8, 2024
1 parent 0907642 commit 6d4ffd5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
13 changes: 12 additions & 1 deletion deps/meson.build
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
if get_option('kernel') == 'linux'
kconfig = []

if get_option('engine') == 'asbestos'
kconfig += 'CONFIG_ISH_EMULATOR_ISHEMU=y'
elif get_option('engine') == 'unicorn'
kconfig += 'CONFIG_ISH_EMULATOR_UNICORN=y'
else
error('Engine "' + get_option('engine') + '" not supported for linux kernel')
endif

kconfig += get_option('kconfig')
meson_fragment = configure_file(
command: [
find_program('kconfig-fragment.sh'),
'@OUTPUT@',
] + get_option('kconfig'),
] + kconfig,
output: 'linux-meson.config',
)

Expand Down
40 changes: 23 additions & 17 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,20 @@ emu_src = [
'emu/float80.c',

]
if get_option('engine') == 'asbestos'
gadgets = 'asbestos/gadgets-' + host_machine.cpu_family()
emu_src += [
'asbestos/asbestos.c',
'asbestos/gen.c',
'asbestos/helpers.c',
gadgets+'/entry.S',
gadgets+'/memory.S',
gadgets+'/control.S',
gadgets+'/math.S',
gadgets+'/bits.S',
gadgets+'/string.S',
gadgets+'/misc.S',
offsets,
]
endif
gadgets = 'asbestos/gadgets-' + host_machine.cpu_family()
emu_src += [
'asbestos/asbestos.c',
'asbestos/gen.c',
'asbestos/helpers.c',
gadgets+'/entry.S',
gadgets+'/memory.S',
gadgets+'/control.S',
gadgets+'/math.S',
gadgets+'/bits.S',
gadgets+'/string.S',
gadgets+'/misc.S',
offsets,
]

libish_emu = library('ish_emu', emu_src, include_directories: includes)

Expand All @@ -78,6 +76,10 @@ libfakefs = library('fakefs',
subdir('deps')

if get_option('kernel') == 'ish'
if get_option('engine') != 'asbestos'
error('Only asbestos is supported with ish kernel')
endif

src = [
'kernel/init.c',
'kernel/errno.c',
Expand Down Expand Up @@ -168,6 +170,10 @@ elif get_option('kernel') == 'linux'
'linux/main.c',
'linux/fakefs.c',
], dependencies: [linux_headers, sqlite3])
emu_deps = []
if get_option('engine') == 'unicorn'
emu_deps += cc.find_library('unicorn', dirs: [meson.current_source_dir()+'/deps/unicorn/build'])
endif
executable('ish', [build_linux],
link_with: [libfakefs],
dependencies: [
Expand All @@ -176,7 +182,7 @@ elif get_option('kernel') == 'linux'
libdl,
threads,
declare_dependency(link_whole: modules),
])
] + emu_deps)
endif

subdir('tools')
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ option('log', type: 'string', value: '')
option('nolog', type: 'string', value: '')
option('log_handler', type: 'string', value: 'dprintf')

option('engine', type: 'combo', choices: ['asbestos'], value: 'asbestos')
option('engine', type: 'combo', choices: ['asbestos', 'unicorn'], value: 'asbestos')
option('kernel', type: 'combo', choices: ['ish', 'linux'], value: 'ish')
option('kconfig', type: 'array', value: [])

Expand Down

0 comments on commit 6d4ffd5

Please sign in to comment.