Mercurial > hg > Members > menikon > CbC_xv6
changeset 301:1ed4d93e5cec
impl update_implheader.pl
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 05 Feb 2020 12:57:07 +0900 |
parents | bf844742a7a4 |
children | 06665ec9e2a0 |
files | src/gearsTools/update_implheader.pl src/impl/vm_impl.h |
diffstat | 2 files changed, 61 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gearsTools/update_implheader.pl Tue Feb 04 21:15:06 2020 +0900 +++ b/src/gearsTools/update_implheader.pl Wed Feb 05 12:57:07 2020 +0900 @@ -14,11 +14,15 @@ find_codes_from_cbc(shift @ARGV, $interface_name, \%cbc_code_names); } -map { push(@{$cbc_code_names{order_list}}, [$_,$cbc_code_names{codes}->{$_}->{order}])} +map { push(@{$cbc_code_names{order_list}}, $_)} sort { $cbc_code_names{codes}->{$a}->{order} <=> $cbc_code_names{codes}->{$b}->{order} } keys %{$cbc_code_names{codes}}; -p $header_con; -p %cbc_code_names; + #p $header_con; + #p %cbc_code_names; + +my $write_codes = create_new_header_codes($header_con,\%cbc_code_names); +exit unless $write_codes; +update_header($header_file,$write_codes); sub search_slurp_header_file { my $header_file = shift; @@ -43,7 +47,7 @@ } close $fh; my @order_code_names; - map { push(@order_code_names, [$_,$order{$_}])} sort { $order{$a} <=> $order{$b} } keys %order; + map { push(@order_code_names, $_)} sort { $order{$a} <=> $order{$b} } keys %order; return { codes => \%contents, order => \@order_code_names }, $interface_name; } @@ -55,7 +59,7 @@ chomp $line; if ($line =~ /\A\s*__code (\w+)\(/) { my $cg_name = $1; - $line =~ s/\s+{\s*/;/; + $line =~ s/\s*{\s*[\w\/\:]*/;/; $line =~ s/struct $inter_name/Type/g; $ccn->{codes}->{$cg_name} = { line =>$line, file => $cbc_file, order => $ccn->{order} }; $ccn->{order}++; @@ -66,7 +70,36 @@ sub create_new_header_codes { my ($header_con, $cbc_con) = @_; - while (@{$header_con->{order}}) { - my ($header_cg_name, $hader_cg_order) = @{$header_con->{order}->[0]}; + return 0 if (@{$header_con->{order}} == $cbc_con->{order}); + + my @res; + my @hcodes = @{$header_con->{order}}; + my %cbc_codes = %{$cbc_con->{codes}}; + for my $hc (@hcodes) { + if (exists $cbc_codes{$hc}) { + push(@res, $cbc_codes{$hc}->{line}); + delete $cbc_codes{$hc}; + } + } + + push(@res, ""); + if (%cbc_codes) { + map { push(@res, $cbc_codes{$_}->{line})} sort { $cbc_codes{$a}->{order} <=> $cbc_codes{$b}->{order}} keys %cbc_codes; } + return \@res; } + +sub update_header { + my ($header_file,$write_codes) = @_; + open my $fh, '+<', $header_file; + my $def_impl = <$fh>; + my ($impl, $interface); + if ($def_impl =~ /typedef\s*struct\s*(\w+)\s*<[\w\s,]+>\s*impl\s*(\w+)\s*{/) { + $impl = $1; + $interface = $2; + } + + map { print $fh " $_\n"} @$write_codes; + print $fh "} $impl;\n"; + close $fh; +}
--- a/src/impl/vm_impl.h Tue Feb 04 21:15:06 2020 +0900 +++ b/src/impl/vm_impl.h Wed Feb 05 12:57:07 2020 +0900 @@ -1,22 +1,27 @@ typedef struct vm_impl<Impl, Isa> impl vm{ __code kpt_alloc_check_impl(Type* vm_impl, __code next(...)); - __code loaduvm_ptesize_checkvm_impl(Type* vm_impl, char* addr, __code next(...)); - __code loaduvm_ptesize_check(Type* vm_impl, __code next(int ret, ...)); - __code loaduvm_loop(Type* vm_impl, uint i, pte_t* pte, uint sz, __code next(int ret, ...)); - __code loaduvm_check_PTE_SZ(Type* vm_impl, uint sz, uint i, uint n, struct inode* ip, uint pa, uint offset, __code next(int ret, ...)); - __code allocuvm_check_newsz(Type* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, __code next(...)); - __code allocuvm_loop(Type* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, uint a, __code next(...)); - __code copyuvm_check_null(Type* vm_impl, pde_t* pgdir, uint sz, __code next(...)); + __code loaduvm_ptesize_checkvm_impl(Type* vm_impl, __code next(int ret, ...)); + __code loaduvm_check_PTE_SZ(Type* vm_impl, __code next(int ret, ...)); __code copyout_loop_check_n(Type* vm_impl, pde_t* pgdir, uint va, void* pp, uint len, uint va0, char* pa0, uint n, char* buf, __code next(...)); - __code copyuvm_loop(Type* vm_impl,pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); - __code clearpteu_check_ptevm_impl(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); - __code uva2ka_check_pe_types(Type* vm_impl, pde_t* pgdir, char* uva, __code next(...)); - __code paging_intvm_impl(Type* vm_impl, uint phy_low, uint phy_hi, __code next(...)); - __code copyout_loopvm_impl(Type* vm_impl, pde_t* pgdir, uint va, void* pp, uint len, __code next(...)); + __code clearpteu_check_ptevm_impl(Type* vm_impl, pde_t* pgdir, char* uva, __code next(int ret, ...)); + __code uva2ka_check_pe_types(Type* vm, pde_t* pgdir, char* uva, __code next(int ret, ...)); + __code copyout_loopvm_impl(Type* vm_impl, pde_t* pgdir, uint va, void* pp, uint len, uint va0, char* pa0, __code next(int ret, ...)); __code switchuvm_check_pgdirvm_impl(Type* vm_impl, proc_struct* p, __code next(...)); __code init_inituvm_check_sz(Type* vm_impl, pde_t* pgdir, char* init, uint sz, __code next(...)); - __code void_ret(Type* vm_impl); - __code next(...); + + __code loaduvm_loopvm_impl(Type* vm_impl, __code next(int ret, ...)); + __code loaduvm_check_pgdir(Type* vm_impl, __code next(int ret, ...)); + __code loaduvm_exit(Type* vm_impl, __code next(int ret, ...)); + __code allocuvm_check_newszvm_impl(Type* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, __code next(int ret, ...)); + __code allocuvm_loopvm_impl(Type* vm_impl, pde_t* pgdir, uint oldsz, uint newsz, char* mem, uint a, __code next(int ret, ...)); + __code copyuvm_check_nullvm_impl(Type* vm_impl, pde_t* pgdir, uint sz, __code next(int ret, ...)); + __code copyuvm_loopvm_impl(Type* vm_impl, pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); + __code copyuvm_loop_check_walkpgdir(Type* vm_impl, pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); + __code copyuvm_loop_check_pte(Type* vm_impl, pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); + __code copyuvm_loop_check_mem(Type* vm_impl, pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); + __code copyuvm_loop_check_mappages(Type* vm_impl, pde_t* pgdir, uint sz, pde_t* d, pte_t* pte, uint pa, uint i, uint ap, char* mem, __code next(int ret, ...)); + __code copyuvm_loop_bad(Type* vm_impl, pde_t* d, __code next(int ret, ...)); + __code uva2ka_check_pte_ap(Type* vm, pde_t* pgdir, char* uva, pte_t* pte, __code next(int ret, ...)); + __code paging_intvmvm_impl(Type* vm_impl, uint phy_low, uint phy_hi, __code next(...)); + __code copyout_loop_check_pa0(Type* vm_impl, pde_t* pgdir, uint va, void* pp, uint len, uint va0, char* pa0, uint n, __code next(int ret, ...)); } vm_impl; - -