5 class Jdb_tbuf_init : public Jdb_tbuf
19 #include "boot_info.h"
23 #include "jdb_ktrace.h"
24 #include "mem_layout.h"
25 #include "vmem_alloc.h"
28 STATIC_INITIALIZE_P(Jdb_tbuf_init, JDB_MODULE_INIT_PRIO);
32 void Jdb_tbuf_init::init()
34 static Virq tbuf_irq(Config::Tbuf_irq);
44 unsigned want_entries = Config::tbuf_entries;
46 if ( (c = strstr(Cmdline::cmdline(), " -tbuf_entries="))
47 ||(c = strstr(Cmdline::cmdline(), " -tbuf_entries ")))
48 want_entries = strtol(c+15, 0, 0);
50 // minimum: 8KB ( 2 pages), maximum: 2MB (512 pages)
51 // must be a power of 2 (for performance reasons)
52 for (n = Config::PAGE_SIZE/sizeof(Tb_entry);
53 n < want_entries && n*sizeof(Tb_entry)<0x200000;
58 panic("Cannot allocate more than %d entries for tracebuffer\n", n);
61 unsigned size = n*sizeof(Tb_entry);
63 if (! Vmem_alloc::page_alloc((void*) status(), Vmem_alloc::ZERO_FILL, Vmem_alloc::User))
64 panic("jdb_tbuf: alloc status page at "L4_PTR_FMT" failed",
65 (Address)Mem_layout::Tbuf_status_page);
67 Address va = (Address) buffer();
68 for (unsigned i=0; i<size/Config::PAGE_SIZE; i++)
70 if (! Vmem_alloc::page_alloc((void*)va, Vmem_alloc::NO_ZERO_FILL, Vmem_alloc::User))
71 panic("jdb_tbuf: alloc buffer at "L4_PTR_FMT" failed", va);
73 va += Config::PAGE_SIZE;
76 status()->window[0].tracebuffer = (Address)Mem_layout::Tbuf_ubuffer_area;
77 status()->window[1].tracebuffer = (Address)Mem_layout::Tbuf_ubuffer_area + size/2;
78 status()->window[0].size =
79 status()->window[1].size = size / 2;
80 status()->window[0].version =
81 status()->window[1].version = 0;
84 status()->scaler_tsc_to_ns = Cpu::boot_cpu()->get_scaler_tsc_to_ns();
85 status()->scaler_tsc_to_us = Cpu::boot_cpu()->get_scaler_tsc_to_us();
86 status()->scaler_ns_to_tsc = Cpu::boot_cpu()->get_scaler_ns_to_tsc();
88 _tbuf_max = buffer() + max_entries();
89 _count_mask1 = max_entries() - 1;
90 _count_mask2 = (max_entries())/2 - 1;