Merge branch 'fb-driver' of github.com:justinian/jsix into fb-driver
This commit is contained in:
@@ -19,15 +19,19 @@ def parse_syms(infile):
|
|||||||
representing the symbols in the text segment of the binary. Returns
|
representing the symbols in the text segment of the binary. Returns
|
||||||
a list of (address, symbol_name)."""
|
a list of (address, symbol_name)."""
|
||||||
|
|
||||||
from cxxfilt import demangle
|
from cxxfilt import demangle, InvalidName
|
||||||
|
|
||||||
syms = []
|
syms = []
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
addr, t, mangled = line.split()
|
addr, t, mangled = line.split()
|
||||||
if t not in "tTvVwW": continue
|
if t not in "tTvVwW": continue
|
||||||
|
|
||||||
addr = int(addr, base=16)
|
try:
|
||||||
name = demangle(mangled)
|
name = demangle(mangled)
|
||||||
|
except InvalidName:
|
||||||
|
continue
|
||||||
|
|
||||||
|
addr = int(addr, base=16)
|
||||||
syms.append((addr, name))
|
syms.append((addr, name))
|
||||||
|
|
||||||
return sorted(syms)
|
return sorted(syms)
|
||||||
|
|||||||
@@ -193,16 +193,12 @@ build $builddir/fatroot/nulldrv.elf : cp $builddir/user/nulldrv.elf
|
|||||||
build $builddir/fatroot/fb.elf : cp $builddir/user/fb.elf
|
build $builddir/fatroot/fb.elf : cp $builddir/user/fb.elf
|
||||||
name = fb driver to FAT image
|
name = fb driver to FAT image
|
||||||
|
|
||||||
build $builddir/fatroot/terminal.elf : cp $builddir/user/nulldrv.elf
|
|
||||||
name = terminal driver to FAT image
|
|
||||||
|
|
||||||
build ${builddir}/fatroot/symbol_table.dat : makest ${builddir}/jsix.elf
|
build ${builddir}/fatroot/symbol_table.dat : makest ${builddir}/jsix.elf
|
||||||
|
|
||||||
build $builddir/jsix.img : makefat | $
|
build $builddir/jsix.img : makefat | $
|
||||||
$builddir/fatroot/symbol_table.dat $
|
$builddir/fatroot/symbol_table.dat $
|
||||||
$builddir/fatroot/nulldrv.elf $
|
$builddir/fatroot/nulldrv.elf $
|
||||||
$builddir/fatroot/fb.elf $
|
$builddir/fatroot/fb.elf $
|
||||||
$builddir/fatroot/terminal.elf $
|
|
||||||
$builddir/fatroot/jsix.elf $
|
$builddir/fatroot/jsix.elf $
|
||||||
$builddir/fatroot/efi/boot/bootx64.efi
|
$builddir/fatroot/efi/boot/bootx64.efi
|
||||||
name = jsix.img
|
name = jsix.img
|
||||||
|
|||||||
@@ -97,13 +97,8 @@ load_program(
|
|||||||
void *src_start = offset_ptr<void>(data.data, pheader->offset);
|
void *src_start = offset_ptr<void>(data.data, pheader->offset);
|
||||||
void *dest_start = offset_ptr<void>(pages, pheader->vaddr - prog_base);
|
void *dest_start = offset_ptr<void>(pages, pheader->vaddr - prog_base);
|
||||||
bs->copy_mem(dest_start, src_start, pheader->file_size);
|
bs->copy_mem(dest_start, src_start, pheader->file_size);
|
||||||
|
|
||||||
console::print(L" section %d phys: 0x%lx\r\n", i, pages);
|
|
||||||
console::print(L" section %d virt: 0x%lx\r\n", i, pheader->vaddr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console::print(L" entrypoint: 0x%lx\r\n", header->entrypoint);
|
|
||||||
|
|
||||||
program.phys_addr = reinterpret_cast<uintptr_t>(pages);
|
program.phys_addr = reinterpret_cast<uintptr_t>(pages);
|
||||||
program.size = total_size;
|
program.size = total_size;
|
||||||
program.virt_addr = prog_base;
|
program.virt_addr = prog_base;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
scrollback::scrollback(unsigned lines, unsigned cols, unsigned margin) :
|
scrollback::scrollback(unsigned lines, unsigned cols, unsigned margin) :
|
||||||
m_rows {lines},
|
m_rows {lines},
|
||||||
m_cols {cols},
|
m_cols {cols},
|
||||||
m_start {0},
|
|
||||||
m_count {0},
|
m_count {0},
|
||||||
m_margin {margin}
|
m_margin {margin}
|
||||||
{
|
{
|
||||||
@@ -23,24 +22,20 @@ scrollback::scrollback(unsigned lines, unsigned cols, unsigned margin) :
|
|||||||
void
|
void
|
||||||
scrollback::add_line(const char *line, size_t len)
|
scrollback::add_line(const char *line, size_t len)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = m_count++ % m_rows;
|
||||||
if (m_count < m_rows)
|
|
||||||
i = m_count++;
|
|
||||||
else
|
|
||||||
i = m_start++;
|
|
||||||
|
|
||||||
if (len > m_cols)
|
if (len > m_cols)
|
||||||
len = m_cols;
|
len = m_cols;
|
||||||
|
|
||||||
memcpy(m_lines[i % m_rows], line, len);
|
memcpy(m_lines[i], line, len);
|
||||||
if (len < m_cols)
|
if (len < m_cols)
|
||||||
memset(m_lines[i % m_rows]+len, ' ', m_cols - len);
|
memset(m_lines[i]+len, ' ', m_cols - len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
scrollback::get_line(unsigned i)
|
scrollback::get_line(unsigned i)
|
||||||
{
|
{
|
||||||
return m_lines[(i+m_start)%m_rows];
|
return m_lines[(i+m_count)%m_rows];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ typedef uint64_t j6_signal_t;
|
|||||||
typedef uint64_t j6_tag_t;
|
typedef uint64_t j6_tag_t;
|
||||||
|
|
||||||
#define j6_tag_system_flag 0x8000000000000000
|
#define j6_tag_system_flag 0x8000000000000000
|
||||||
|
#define j6_tag_invalid 0x0000000000000000
|
||||||
|
|
||||||
/// If all high bits except the last 16 are set, then the tag represents
|
/// If all high bits except the last 16 are set, then the tag represents
|
||||||
/// an IRQ.
|
/// an IRQ.
|
||||||
|
|||||||
@@ -21,13 +21,16 @@ process::process() :
|
|||||||
m_state {state::running}
|
m_state {state::running}
|
||||||
{
|
{
|
||||||
s_processes.append(this);
|
s_processes.append(this);
|
||||||
|
|
||||||
|
j6_handle_t self = add_handle(this);
|
||||||
|
kassert(self == self_handle(), "Process self-handle is not 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The "kernel process"-only constructor
|
// The "kernel process"-only constructor
|
||||||
process::process(page_table *kpml4) :
|
process::process(page_table *kpml4) :
|
||||||
kobject {kobject::type::process},
|
kobject {kobject::type::process},
|
||||||
m_space {kpml4},
|
m_space {kpml4},
|
||||||
m_next_handle {0},
|
m_next_handle {self_handle()+1},
|
||||||
m_state {state::running}
|
m_state {state::running}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -117,6 +120,7 @@ process::thread_exited(thread *th)
|
|||||||
kassert(&th->m_parent == this, "Process got thread_exited for non-child!");
|
kassert(&th->m_parent == this, "Process got thread_exited for non-child!");
|
||||||
uint32_t status = th->m_return_code;
|
uint32_t status = th->m_return_code;
|
||||||
m_threads.remove_swap(th);
|
m_threads.remove_swap(th);
|
||||||
|
remove_handle(th->self_handle());
|
||||||
delete th;
|
delete th;
|
||||||
|
|
||||||
if (m_threads.count() == 0) {
|
if (m_threads.count() == 0) {
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ public:
|
|||||||
/// \returns True if this thread ending has ended the process
|
/// \returns True if this thread ending has ended the process
|
||||||
bool thread_exited(thread *th);
|
bool thread_exited(thread *th);
|
||||||
|
|
||||||
|
/// Get the handle for this process to refer to itself
|
||||||
|
inline j6_handle_t self_handle() const { return 0; }
|
||||||
|
|
||||||
/// Get the process object that owns kernel threads and the
|
/// Get the process object that owns kernel threads and the
|
||||||
/// kernel address space
|
/// kernel address space
|
||||||
static process & kernel_process();
|
static process & kernel_process();
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ thread::thread(process &parent, uint8_t pri, uintptr_t rsp0) :
|
|||||||
setup_kernel_stack();
|
setup_kernel_stack();
|
||||||
else
|
else
|
||||||
m_tcb.rsp0 = rsp0;
|
m_tcb.rsp0 = rsp0;
|
||||||
|
|
||||||
|
m_self_handle = parent.add_handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread::~thread()
|
thread::~thread()
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ public:
|
|||||||
/// \arg rip The address to return to, must be user space
|
/// \arg rip The address to return to, must be user space
|
||||||
void add_thunk_user(uintptr_t rip);
|
void add_thunk_user(uintptr_t rip);
|
||||||
|
|
||||||
|
/// Get the handle representing this thread to its process
|
||||||
|
j6_handle_t self_handle() const { return m_self_handle; }
|
||||||
|
|
||||||
/// Create the kernel idle thread
|
/// Create the kernel idle thread
|
||||||
/// \arg kernel The process object that owns kernel tasks
|
/// \arg kernel The process object that owns kernel tasks
|
||||||
/// \arg pri The idle thread priority value
|
/// \arg pri The idle thread priority value
|
||||||
@@ -175,4 +178,6 @@ private:
|
|||||||
uint64_t m_wait_data;
|
uint64_t m_wait_data;
|
||||||
j6_status_t m_wait_result;
|
j6_status_t m_wait_result;
|
||||||
j6_koid_t m_wait_obj;
|
j6_koid_t m_wait_obj;
|
||||||
|
|
||||||
|
j6_handle_t m_self_handle;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,11 +116,11 @@ load_process_image(uintptr_t phys, uintptr_t virt, size_t bytes, TCB *tcb)
|
|||||||
|
|
||||||
initv = push<j6_init_value>(tcb->rsp3);
|
initv = push<j6_init_value>(tcb->rsp3);
|
||||||
initv->type = j6_init_handle_process;
|
initv->type = j6_init_handle_process;
|
||||||
initv->value = static_cast<uint64_t>(proc.add_handle(&proc));
|
initv->value = static_cast<uint64_t>(proc.self_handle());
|
||||||
|
|
||||||
initv = push<j6_init_value>(tcb->rsp3);
|
initv = push<j6_init_value>(tcb->rsp3);
|
||||||
initv->type = j6_init_handle_thread;
|
initv->type = j6_init_handle_thread;
|
||||||
initv->value = static_cast<uint64_t>(proc.add_handle(&th));
|
initv->value = static_cast<uint64_t>(th.self_handle());
|
||||||
|
|
||||||
initv = push<j6_init_value>(tcb->rsp3);
|
initv = push<j6_init_value>(tcb->rsp3);
|
||||||
initv->type = j6_init_handle_space;
|
initv->type = j6_init_handle_space;
|
||||||
|
|||||||
@@ -35,7 +35,12 @@ endpoint_receive(j6_handle_t handle, j6_tag_t *tag, size_t *len, void *data)
|
|||||||
endpoint *e = get_handle<endpoint>(handle);
|
endpoint *e = get_handle<endpoint>(handle);
|
||||||
if (!e) return j6_err_invalid_arg;
|
if (!e) return j6_err_invalid_arg;
|
||||||
|
|
||||||
return e->receive(tag, len, data);
|
j6_tag_t out_tag = j6_tag_invalid;
|
||||||
|
size_t out_len = 0;
|
||||||
|
j6_status_t s = e->receive(&out_tag, &out_len, data);
|
||||||
|
*tag = out_tag;
|
||||||
|
*len = out_len;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
j6_status_t
|
j6_status_t
|
||||||
@@ -51,7 +56,12 @@ endpoint_sendrecv(j6_handle_t handle, j6_tag_t *tag, size_t *len, void *data)
|
|||||||
if (status != j6_status_ok)
|
if (status != j6_status_ok)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
return e->receive(tag, len, data);
|
j6_tag_t out_tag = j6_tag_invalid;
|
||||||
|
size_t out_len = 0;
|
||||||
|
j6_status_t s = e->receive(&out_tag, &out_len, data);
|
||||||
|
*tag = out_tag;
|
||||||
|
*len = out_len;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace syscalls
|
} // namespace syscalls
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ thread_create(void *rip, j6_handle_t *handle)
|
|||||||
|
|
||||||
thread *child = p.create_thread();
|
thread *child = p.create_thread();
|
||||||
child->add_thunk_user(reinterpret_cast<uintptr_t>(rip));
|
child->add_thunk_user(reinterpret_cast<uintptr_t>(rip));
|
||||||
*handle = p.add_handle(child);
|
*handle = p.self_handle();
|
||||||
child->clear_state(thread::state::loading);
|
child->clear_state(thread::state::loading);
|
||||||
child->set_state(thread::state::ready);
|
child->set_state(thread::state::ready);
|
||||||
|
|
||||||
|
|||||||
@@ -45,20 +45,6 @@ struct hash_node
|
|||||||
inline uint64_t hash() const { return h; }
|
inline uint64_t hash() const { return h; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename V>
|
|
||||||
struct hash_node <uint64_t, V>
|
|
||||||
{
|
|
||||||
uint64_t key;
|
|
||||||
V val;
|
|
||||||
|
|
||||||
hash_node(hash_node &&o) : key(std::move(o.key)), val(std::move(o.val)) {}
|
|
||||||
hash_node(uint64_t h, uint64_t &&k, V &&v) : key(std::move(k)), val(std::move(v)) {}
|
|
||||||
~hash_node() {}
|
|
||||||
|
|
||||||
inline uint64_t & hash() { return key; }
|
|
||||||
inline uint64_t hash() const { return key; }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Base class for hash maps
|
/// Base class for hash maps
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
class base_map
|
class base_map
|
||||||
|
|||||||
Reference in New Issue
Block a user