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"
27 STATIC_INITIALIZE_P(Jdb_tbuf_init, JDB_MODULE_INIT_PRIO);
31 void Jdb_tbuf_init::init()
33 //static Irq_sender tbuf_irq(Config::Tbuf_irq);
43 unsigned want_entries = Config::tbuf_entries;
45 if ( (c = strstr(Cmdline::cmdline(), " -tbuf_entries="))
46 ||(c = strstr(Cmdline::cmdline(), " -tbuf_entries ")))
47 want_entries = strtol(c+15, 0, 0);
49 // minimum: 8KB ( 2 pages), maximum: 2MB (512 pages)
50 // must be a power of 2 (for performance reasons)
51 for (n = Config::PAGE_SIZE/sizeof(Tb_entry);
52 n < want_entries && n*sizeof(Tb_entry)<0x200000;
57 panic("Cannot allocate more than %d entries for tracebuffer\n", n);
60 unsigned size = n*sizeof(Tb_entry);
62 if (! Vmem_alloc::page_alloc((void*) status(), Vmem_alloc::ZERO_FILL, Vmem_alloc::User))
63 panic("jdb_tbuf: alloc status page at "L4_PTR_FMT" failed",
64 (Address)Mem_layout::Tbuf_status_page);
66 Address va = (Address) buffer();
67 for (unsigned i=0; i<size/Config::PAGE_SIZE; i++)
69 if (! Vmem_alloc::page_alloc((void*)va, Vmem_alloc::NO_ZERO_FILL, Vmem_alloc::User))
70 panic("jdb_tbuf: alloc buffer at "L4_PTR_FMT" failed", va);
72 va += Config::PAGE_SIZE;
75 status()->window[0].tracebuffer = (Address)Mem_layout::Tbuf_ubuffer_area;
76 status()->window[1].tracebuffer = (Address)Mem_layout::Tbuf_ubuffer_area + size/2;
77 status()->window[0].size =
78 status()->window[1].size = size / 2;
79 status()->window[0].version =
80 status()->window[1].version = 0;
83 status()->scaler_tsc_to_ns = Cpu::boot_cpu()->get_scaler_tsc_to_ns();
84 status()->scaler_tsc_to_us = Cpu::boot_cpu()->get_scaler_tsc_to_us();
85 status()->scaler_ns_to_tsc = Cpu::boot_cpu()->get_scaler_ns_to_tsc();
87 _tbuf_max = buffer() + max_entries();
88 _count_mask1 = max_entries() - 1;
89 _count_mask2 = (max_entries())/2 - 1;