summaryrefslogtreecommitdiff
path: root/i386/i386at/model_dep.c
AgeCommit message (Collapse)Author
2020-03-09Set readtodc parameter 64bitv1.8+git20200309Samuel Thibault
In order to fix year 2038 limit. * i386/i386at/rtc.h (readtodc): Make tp parameter uint64_t *. * i386/i386at/rtc.c (readtodc): Likewise. * xen/time.c (readtodc): Likewise. * i386/i386at/model_dep.c (inittodr): Pass uint64_t pointer to readtodc.
2019-04-28Avoid calling biosmem with size 0Samuel Thibault
* i386/i386at/model_dep.c (register_boot_data): Register reserved biosmem areas only when they have a non-zero size.
2019-04-28Avoid calling biosmem with size 0Samuel Thibault
* i386/configfrag.ac (register_boot_data): Process modules only when their count is non-zero. (i386at_init): Likewise.
2018-07-28device: Fix d_mmap typeSamuel Thibault
* device/conf.h (dev_ops): Make d_mmap return vm_offset_t instead of int. (nomap): Update accordingly. * device/blkio.c (block_io_mmap): Likewise. * device/blkio.h (block_io_mmap): Likewise. * device/dev_name.c (nomap): Likewise. * i386/i386at/kd.c (kdmmap): Likewise. * i386/i386at/kd.h (kdmmap): Likewise. * i386/i386at/mem.c (memmmap): Likewise. * i386/i386at/mem.h (memmmap): Likewise. * i386/i386at/model_dep.c (timemmap): Likewise. * i386/i386at/model_dep.h (timemmap): Likewise.
2017-11-12Fix halt messageSamuel Thibault
* i386/i386at/model_dep.c (halt_all_cpus): Change halt message to better explain what happened.
2016-11-06Revert "i386: use ACPI to power off the machine"Justus Winter
This reverts commit c031b41b783cc99c0bd5aac7d14c1d6e34520397. Adding the ACPI parser from GRUB was a mistake as its license conflicts with the one used by the legacy Linux drivers. Furthermore, adding support for ACPI to the kernel violates the minimality principle.
2016-11-01i386: Use discontiguous page directories when using PAE.Justus Winter
Previously, we used contiguous page directories four pages in length when using PAE. To prevent physical memory fragmentation, we need to use virtual memory for objects spanning multiple pages. Virtual kernel memory, however, is a scarce commodity. * i386/intel/pmap.h (lin2pdenum): Never include the page directory pointer table index. (lin2pdenum_cont): New macro which does include said index. (struct pmap): Remove the directory base pointer when using PAE. * i386/intel/pmap.c (pmap_pde): Fix lookup. (pmap_pte): Fix check for uninitialized pmap. (pmap_bootstrap): Do not store the page directory base if PAE. (pmap_init): Reduce size of page directories to one page, use direct-mapped memory. (pmap_create): Allocate four page directories per pmap. (pmap_destroy): Adapt to the discontinuous directories. (pmap_collect): Likewise. * i386/i386/xen.h (hyp_mmu_update_la): Adapt code manipulating the kernels page directory. * i386/i386at/model_dep.c (i386at_init): Likewise.
2016-10-31Make multiboot cmdline and modules non-permanent reservationsSamuel Thibault
* i386/i386at/model_dep.c (register_boot_data): For multiboot cmdline, module structure, module data and module strings, set biosmem_register_boot_data temporary parameter to TRUE.
2016-09-21Remove phys_first_addr and phys_last_addr global variablesRichard Braun
The old assumption that all physical memory is directly mapped in kernel space is about to go away. Those variables are directly linked to that assumption. * i386/i386/model_dep.h (phys_first_addr): Remove extern declaration. (phys_last_addr): Likewise. * i386/i386/phys.c (pmap_zero_page): Use VM_PAGE_DIRECTMAP_LIMIT instead of phys_last_addr. (pmap_copy_page, copy_to_phys, copy_from_phys): Likewise. * i386/i386/trap.c (user_trap): Remove check against phys_last_addr. * i386/i386at/biosmem.c (biosmem_bootstrap_common): Don't set phys_last_addr. * i386/i386at/mem.c (memmmap): Use vm_page_lookup_pa to determine if a physical address references physical memory. * i386/i386at/model_dep.c (phys_first_addr): Remove variable. (phys_last_addr): Likewise. (pmap_free_pages, pmap_valid_page): Remove functions. * i386/intel/pmap.c: Include i386at/biosmem.h. (pa_index): Turn into an alias for vm_page_table_index. (pmap_bootstrap): Replace uses of phys_first_addr and phys_last_addr as appropriate. (pmap_virtual_space): Use vm_page_table_size instead of phys_first_addr and phys_last_addr to obtain the number of physical pages. (pmap_verify_free): Remove function. (valid_page): Turn this macro into an inline function and rewrite using vm_page_lookup_pa. (pmap_page_table_page_alloc): Build the pmap VM object using vm_page_table_size to determine its size. (pmap_remove_range, pmap_page_protect, phys_attribute_clear, phys_attribute_test): Turn page indexes into unsigned long integers. (pmap_enter): Likewise. In addition, use either vm_page_lookup_pa or biosmem_directmap_end to determine if a physical address references physical memory. * i386/xen/xen.c (hyp_p2m_init): Use vm_page_table_size instead of phys_last_addr to obtain the number of physical pages. * kern/startup.c (phys_first_addr): Remove extern declaration. (phys_last_addr): Likewise. * linux/dev/init/main.c (linux_init): Use vm_page_seg_end with the appropriate segment selector instead of phys_last_addr to determine where high memory starts. * vm/pmap.h: Update requirements description. (pmap_free_pages, pmap_valid_page): Remove declarations. * vm/vm_page.c (vm_page_seg_end, vm_page_boot_table_size, vm_page_table_size, vm_page_table_index): New functions. * vm/vm_page.h (vm_page_seg_end, vm_page_table_size, vm_page_table_index): New function declarations. * vm/vm_resident.c (vm_page_bucket_count, vm_page_hash_mask): Define as unsigned long integers. (vm_page_bootstrap): Compute VP table size based on the page table size instead of the value returned by pmap_free_pages.
2016-09-06Fix registration of strings from in boot dataRichard Braun
* i386/i386at/model_dep.c (register_boot_data): Use phystokv on strings when computing their length.
2016-09-06Make early physical page allocation truely reliableRichard Braun
Import upstream biosmem changes and adjust for local modifications. Specifically, this change makes the biosmem module reliably track all boot data by storing their addresses in a sorted array. This allows both the early page allocator and the biosmem_free_usable function to accurately find any range of free pages. * i386/i386at/biosmem.c: Remove inclusion of <i386at/elf.h>. (_start, _end): Remove variable declarations. (BIOSMEM_MAX_BOOT_DATA): New macro. (struct biosmem_boot_data): New type. (biosmem_boot_data_array, biosmem_nr_boot_data): New variables. (biosmem_heap_start, biosmem_heap_bottom, biosmem_heap_top, biosmem_heap_end): Change type to phys_addr_t. (biosmem_panic_inval_boot_data): New variable. (biosmem_panic_too_many_boot_data): Likewise. (biosmem_panic_toobig_msg): Variable renamed ... (biosmem_panic_too_big_msg): ... to this. (biosmem_register_boot_data): New function. (biosmem_unregister_boot_data): Likewise. (biosmem_map_adjust): Update reference to panic message. (biosmem_map_find_avail): Add detailed description. (biosmem_save_cmdline_sizes): Remove function. (biosmem_find_heap_clip): Likewise. (biosmem_find_heap): Likewise. (biosmem_find_avail_clip, biosmem_find_avail): New functions. (biosmem_setup_allocator): Receive const multiboot info, replace calls to biosmem_find_heap with calls to biosmem_find_avail and update accordingly. Register the heap as boot data. (biosmem_xen_bootstrap): Register the Xen boot info and the heap as boot data. (biosmem_bootstrap): Receive const multiboot information. Remove call to biosmem_save_cmdline_sizes. (biosmem_bootalloc): Remove assertion on the VM system state. (biosmem_type_desc, biosmem_map_show): Build only if DEBUG is true. (biosmem_unregister_temporary_boot_data): New function. (biosmem_free_usable_range): Change address range format. (biosmem_free_usable_entry): Rewrite to use biosmem_find_avail without abusing it. (biosmem_free_usable): Call biosmem_unregister_temporary_boot_data, update call to biosmem_free_usable_entry. * i386/i386at/biosmem.h (biosmem_register_boot_data): New function. (biosmem_bootalloc): Update description. (biosmem_bootstrap): Update description and declaration. (biosmem_free_usable): Likewise. * i386/i386at/model_dep.c: Include <i386at/elf.h>. (machine_init): Update call to biosmem_free_usable. (register_boot_data): New function. (i386at_init): Call register_boot_data where appropriate.
2016-09-03Fix early physical page allocationRichard Braun
Import upstream biosmem and vm_page changes, and adjust for local modifications. Specifically, the biosmem module was mistakenly loading physical segments that did not clip with the heap as completely available. This change makes it load them as completely unavailable during startup, and once the VM system is ready, additional pages are loaded. * i386/i386at/biosmem.c (DEBUG): New macro. (struct biosmem_segment): Remove members `avail_start' and `avail_end'. (biosmem_heap_cur): Remove variable. (biosmem_heap_bottom, biosmem_heap_top, biosmem_heap_topdown): New variables. (biosmem_find_boot_data_update, biosmem_find_boot_data): Remove functions. (biosmem_find_heap_clip, biosmem_find_heap): New functions. (biosmem_setup_allocator): Rewritten to use the new biosmem_find_heap function. (biosmem_bootalloc): Support both bottom-up and top-down allocations. (biosmem_directmap_size): Renamed to ... (biosmem_directmap_end): ... this function. (biosmem_load_segment): Fix segment loading. (biosmem_setup): Restrict usable memory to the directmap segment. (biosmem_free_usable_range): Add checks on input parameters. (biosmem_free_usable_update_start, biosmem_free_usable_start, biosmem_free_usable_reserved, biosmem_free_usable_end): Remove functions. (biosmem_free_usable_entry): Rewritten to use the new biosmem_find_heap function. (biosmem_free_usable): Restrict usable memory to the directmap segment. * i386/i386at/biosmem.h (biosmem_bootalloc): Update description. (biosmem_directmap_size): Renamed to ... (biosmem_directmap_end): ... this function. (biosmem_free_usable): Update declaration. * i386/i386at/model_dep.c (machine_init): Call biosmem_free_usable. * vm/vm_page.c (DEBUG): New macro. (struct vm_page_seg): New member `heap_present'. (vm_page_load): Remove heap related parameters. (vm_page_load_heap): New function. * vm/vm_page.h (vm_page_load): Remove heap related parameters. Update description. (vm_page_load_heap): New function.
2016-04-15i386: Fix error handlingJustus Winter
* i386/i386at/model_dep.c (i386at_init): Fix error handling. Signed-off-by: Justus Winter <justus@gnupg.org>
2016-02-02Stack the slab allocator directly on top of the physical allocatorRichard Braun
In order to increase the amount of memory available for kernel objects, without reducing the amount of memory available for user processes, a new allocation strategy is introduced in this change. Instead of allocating kernel objects out of kernel virtual memory, the slab allocator directly uses the direct mapping of physical memory as its backend. This largely increases the kernel heap, and removes the need for address translation updates. In order to allow this strategy, an assumption made by the interrupt code had to be removed. In addition, kernel stacks are now also allocated directly from the physical allocator. * i386/i386/db_trace.c: Include i386at/model_dep.h (db_i386_reg_value): Update stack check. * i386/i386/locore.S (trap_from_kernel, all_intrs, int_from_intstack): Update interrupt handling. * i386/i386at/model_dep.c: Include kern/macros.h. (int_stack, int_stack_base): New variables. (int_stack_high): Remove variable. (i386at_init): Update interrupt stack initialization. * i386/i386at/model_dep.h: Include i386/vm_param.h. (int_stack_top, int_stack_base): New extern declarations. (ON_INT_STACK): New macro. * kern/slab.c: Include vm/vm_page.h (KMEM_CF_NO_CPU_POOL, KMEM_CF_NO_RECLAIM): Remove macros. (kmem_pagealloc, kmem_pagefree, kalloc_pagealloc, kalloc_pagefree): Remove functions. (kmem_slab_create): Allocate slab pages directly from the physical allocator. (kmem_slab_destroy): Release slab pages directly to the physical allocator. (kmem_cache_compute_sizes): Update the slab size computation algorithm to return a power-of-two suitable for the physical allocator. (kmem_cache_init): Remove custom allocation function pointers. (kmem_cache_reap): Remove check on KMEM_CF_NO_RECLAIM. (slab_init, kalloc_init): Update calls to kmem_cache_init. (kalloc, kfree): Directly fall back on the physical allocator for big allocation sizes. (host_slab_info): Remove checks on defunct flags. * kern/slab.h (kmem_slab_alloc_fn_t, kmem_slab_free_fn_t): Remove types. (struct kmem_cache): Add `slab_order' member, remove `slab_alloc_fn' and `slab_free_fn' members. (KMEM_CACHE_NOCPUPOOL, KMEM_CACHE_NORECLAIM): Remove macros. (kmem_cache_init): Update prototype, remove custom allocation functions. * kern/thread.c (stack_alloc): Allocate stacks from the physical allocator. * vm/vm_map.c (vm_map_kentry_cache, kentry_data, kentry_data_size): Remove variables. (kentry_pagealloc): Remove function. (vm_map_init): Update calls to kmem_cache_init, remove initialization of vm_map_kentry_cache. (vm_map_create, _vm_map_entry_dispose, vm_map_copyout): Unconditionnally use vm_map_entry_cache. * vm/vm_map.h (kentry_data, kentry_data_size, kentry_count): Remove extern declarations. * vm/vm_page.h (VM_PT_STACK): New page type. * device/dev_lookup.c (dev_lookup_init): Update calls to kmem_cache_init. * device/dev_pager.c (dev_pager_hash_init, device_pager_init): Likewise. * device/ds_routines.c (mach_device_init, mach_device_trap_init): Likewise. * device/net_io.c (net_io_init): Likewise. * i386/i386/fpu.c (fpu_module_init): Likewise. * i386/i386/machine_task.c (machine_task_module_init): Likewise. * i386/i386/pcb.c (pcb_module_init): Likewise. * i386/intel/pmap.c (pmap_init): Likewise. * ipc/ipc_init.c (ipc_bootstrap): Likewise. * ipc/ipc_marequest.c (ipc_marequest_init): Likewise. * kern/act.c (global_act_init): Likewise. * kern/processor.c (pset_sys_init): Likewise. * kern/rdxtree.c (rdxtree_cache_init): Likewise. * kern/task.c (task_init): Likewise. * vm/memory_object_proxy.c (memory_object_proxy_init): Likewise. * vm/vm_external.c (vm_external_module_initialize): Likewise. * vm/vm_fault.c (vm_fault_init): Likewise. * vm/vm_object.c (vm_object_bootstrap): Likewise. * vm/vm_resident.c (vm_page_module_init): Likewise. (vm_page_bootstrap): Remove initialization of kentry_data.
2016-01-30Fix early page allocation on XenRichard Braun
The Xen target was completely ignored when porting the biosmem and vm_page physical memory allocators. Let's fix this. * i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386at/biosmem.{c,h}. * i386/i386/vm_page.h (VM_PAGE_MAX_SEGS, VM_PAGE_DIRECTMAP_LIMIT, VM_PAGE_HIGHMEM_LIMIT): Define for Xen. * i386/i386at/biosmem.c: Include mach/xen.h. (biosmem_panic_setup_msg): Comment out for Xen since it's unused. (biosmem_map_build, biosmem_map_build_simple, biosmem_save_cmdline_sizes, biosmem_find_boot_data_update, biosmem_find_boot_data, biosmem_setup_allocator): Likewise. (biosmem_bootstrap_common): New function. (biosmem_xen_bootstrap): Likewise, for Xen. (biosmem_bootalloc): Perform bottom-up allocations for Xen. * i386/i386at/biosmem.h (biosmem_xen_bootstrap): New prototype, for Xen. * i386/i386at/model_dep.c (i386at_init): Call biosmem_xen_bootstrap instead of biosmem_bootstrap on Xen. * i386/include/mach/i386/vm_types.h (phys_addr_t): Define as an unsigned 64-bits integer when PAE is enabled.
2016-01-23Use vm_page as the physical memory allocatorRichard Braun
This change replaces the historical page allocator with a buddy allocator implemented in vm/vm_page.c. This allocator allows easy contiguous allocations and also manages memory inside segments. In a future change, these segments will be used to service requests with special constraints, such as "usable for 16-bits DMA" or "must be part of the direct physical mapping". * Makefrag.am (libkernel_a_SOURCES): Add vm/vm_page.c. * i386/Makefrag.am (libkernel_a_SOURCES): Add i386/i386at/biosmem.{c,h}. * i386/i386/vm_param.h: Include kern/macros.h. (VM_PAGE_DMA_LIMIT, VM_PAGE_MAX_SEGS, VM_PAGE_DMA32_LIMIT, VM_PAGE_DIRECTMAP_LIMIT, VM_PAGE_HIGHMEM_LIMIT, VM_PAGE_SEG_DMA, VM_PAGE_SEG_DMA32, VM_PAGE_SEG_DIRECTMAP, VM_PAGE_SEG_HIGHMEM): New macros. * i386/i386at/model_dep.c: Include i386at/biosmem.h. (avail_next, avail_remaining): Remove variables. (mem_size_init): Remove function. (i386at_init): Initialize and use the biosmem module for early physical memory management. (pmap_free_pages): Return phys_last_addr instead of avail_remaining. (init_alloc_aligned): Turn into a wrapper for biosmem_bootalloc. (pmap_grab_page): Directly call init_alloc_aligned instead of pmap_next_page. * i386/include/mach/i386/vm_types.h (phys_addr_t): New type. * kern/bootstrap.c (free_bootstrap_pages): New function. (bootstrap_create): Call free_bootstrap_pages instead of vm_page_create. * kern/cpu_number.h (CPU_L1_SIZE): New macro. * kern/slab.h: Include kern/cpu_number.h. (CPU_L1_SIZE): Remove macro, moved to kern/cpu_number.h. * kern/startup.c (setup_main): Change the value of machine_info.memory_size. * linux/dev/glue/glue.h (alloc_contig_mem, free_contig_mem): Update prototypes. * linux/dev/glue/kmem.c (linux_kmem_init): Don't use defunct page queue. * linux/dev/init/main.c (linux_init): Don't free unused memory. (alloc_contig_mem, free_contig_mem): Turn into wrappers for the vm_page allocator. * linux/pcmcia-cs/glue/ds.c (PAGE_SHIFT): Don't undefine. * vm/pmap.h (pmap_startup, pmap_next_page): Remove prototypes. * vm/vm_fault.c (vm_fault_page): Update calls to vm_page_convert. * vm/vm_init.c (vm_mem_init): Call vm_page_info_all. * vm/vm_object.c (vm_object_page_map): Update call to vm_page_init. * vm/vm_page.h (vm_page_queue_free): Remove variable declaration. (vm_page_create, vm_page_release_fictitious, vm_page_release): Remove declarations. (vm_page_convert, vm_page_init): Update prototypes. (vm_page_grab_contig, vm_page_free_contig): New prototypes. * vm/vm_resident.c (vm_page_template, vm_page_queue_free, vm_page_big_pagenum): Remove variables. (vm_page_bootstrap): Update and call vm_page_setup. (pmap_steal_memory): Update and call vm_page_bootalloc. (pmap_startup, vm_page_create, vm_page_grab_contiguous_pages): Remove functions. (vm_page_init_template, vm_page_grab_contig, vm_page_free_contig): New functions. (vm_page_init): Update and call vm_page_init_template. (vm_page_release_fictitious): Make static. (vm_page_more_fictitious): Update call to vm_page_init. (vm_page_convert): Rewrite to comply with vm_page. (vm_page_grab): Update and call vm_page_alloc_pa. (vm_page_release): Update and call vm_page_free_pa.
2015-08-31Reserve 64k at beginning of memory, not just 4kSamuel Thibault
Linux does this to be extra careful with some BIOSes which apparently spuriously write between 4k and 64k. * i386/i386at/model_dep.c (RESERVED_BIOS): New macro. (avail_next, mem_size_init, init_alloc_aligned): Use RESERVED_BIOS instead of hardcoded 0x1000.
2015-06-28i386: improve the immediate consoleJustus Winter
Improve the immediate console to the point that it can be enabled and display e.g. assertion failures from very early on (i.e. from `c_boot_entry'). * device/cons.h (romgetc, romputc): New declarations. * i386/configfrag.ac: Add configuration variable. * i386/i386at/conf.c (dev_name_list): Add entry. * i386/i386at/cons_conf.c (constab): Add entry. * i386/i386at/immc.c: Add missing includes. (immc_cnprobe, immc_cninit, immc_cngetc, immc_romputc): New functions. (immc_cnputc): Fix signature, use virtual addresses. * i386/i386at/immc.h: New file. * i386/i386at/kd.c: Use `#if ENABLE_IMMEDIATE_CONSOLE'. * i386/i386at/kd.h (kd_setpos): Add missing declaration. * i386/i386at/model_dep.c (c_boot_entry): Install immediate console as early boot console.
2015-06-26i386: add commentJustus Winter
* i386/i386at/model_dep.c (rebootflag): Explain flag.
2014-09-17ddb: add support for ELF symbol tablesJustus Winter
* ddb/db_elf.c: New file. * ddb/db_elf.h: Likewise. * Makefrag.am (libkernel_a_SOURCES): Add db_elf.{c,h}. * ddb/db_sym.c (dummy_db_sym_init): New stub db_sym_init function. (db_sym_switch): Add ELF functions. * ddb/db_sym.h (SYMTAB_ELF): New macro. (elf_db_sym_init): New declaration. * i386/i386at/model_dep.c (c_boot_entry): Get ELF section header information from the multiboot structure, and call elf_db_sym_init.
2014-07-06Do not unmap page 0 when not neededSamuel Thibault
Since we need it to access some BIOS information, e.g. at ACPI shutdown. When the kernel VM is not starting at 0, there is already nothing mapped there in user tasks, anyway. * i386/i386at/model_dep.c (machine_init) [VM_MIN_KERNEL_ADDRESS != 0]: Do not call pmap_unmap_page_zero. * i386/intel/pmap.c (pmap_unmap_page_zero): Warn that unmapping page zero may break some BIOS functions.
2014-07-06i386: use ACPI to power off the machineJustus Winter
This is a mostly verbatim copy of acpihalt.c from GRUB2 with a little bit of glue code. * i386/Makefrag.am (libkernel_a_SOURCES): Add the new files. * i386/grub/acpi.h: Verbatim copy from GRUB2. * i386/grub/compiler.h: Likewise. * i386/grub/cpu/io.h: Likewise. * i386/grub/cpu/time.h: Likewise. * i386/grub/cpu/types.h: Likewise. * i386/grub/err.h: Likewise. * i386/grub/misc.h: Likewise. * i386/grub/mm.h: Likewise. * i386/grub/symbol.h: Likewise. * i386/grub/time.h: Likewise. * i386/grub/types.h: Likewise. * i386/i386at/acpi.c: Likewise. * i386/i386at/acpihalt.c: Likewise. (grub_acpi_halt): Map physical addresses. * i386/i386at/acpihalt.h: New file. * i386/grub/glue.h: Some glue macros. * i386/grub/i18n.h: Stub out i18n. * i386/i386at/grub_glue.c: Some glue code. * i386/i386at/model_dep.c (halt_all_cpus): Use grub_acpi_halt.
2014-05-03ddb: add "halt" commandJustus Winter
* ddb/db_command.c (db_command_table): Add "halt" command. * i386/i386/db_interface.h (db_halt_cpu): New declaration. * i386/i386at/model_dep.c (db_halt_cpu): New function.
2014-04-04Convert from K&R to ANSIMarin Ramesa
Convert from K&R style function definitions to ANSI style function definitions. * ddb/db_access.c: Convert function prototypes from K&R to ANSI. * ddb/db_aout.c: Likewise. * ddb/db_break.c: Likewise. * ddb/db_command.c: Likewise. * ddb/db_cond.c: Likewise. * ddb/db_examine.c: Likewise. * ddb/db_expr.c: Likewise. * ddb/db_ext_symtab.c: Likewise. * ddb/db_input.c: Likewise. * ddb/db_lex.c: Likewise. * ddb/db_macro.c: Likewise. * ddb/db_mp.c: Likewise. * ddb/db_output.c: Likewise. * ddb/db_print.c: Likewise. * ddb/db_run.c: Likewise. * ddb/db_sym.c: Likewise. * ddb/db_task_thread.c: Likewise. * ddb/db_trap.c: Likewise. * ddb/db_variables.c: Likewise. * ddb/db_watch.c: Likewise. * device/blkio.c: Likewise. * device/chario.c: Likewise. * device/dev_lookup.c: Likewise. * device/dev_name.c: Likewise. * device/dev_pager.c: Likewise. * device/ds_routines.c: Likewise. * device/net_io.c: Likewise. * device/subrs.c: Likewise. * i386/i386/db_interface.c: Likewise. * i386/i386/fpu.c: Likewise. * i386/i386/io_map.c: Likewise. * i386/i386/loose_ends.c: Likewise. * i386/i386/mp_desc.c: Likewise. * i386/i386/pcb.c: Likewise. * i386/i386/phys.c: Likewise. * i386/i386/trap.c: Likewise. * i386/i386/user_ldt.c: Likewise. * i386/i386at/com.c: Likewise. * i386/i386at/kd.c: Likewise. * i386/i386at/kd_event.c: Likewise. * i386/i386at/kd_mouse.c: Likewise. * i386/i386at/kd_queue.c: Likewise. * i386/i386at/lpr.c: Likewise. * i386/i386at/model_dep.c: Likewise. * i386/i386at/rtc.c: Likewise. * i386/intel/pmap.c: Likewise. * i386/intel/read_fault.c: Likewise. * ipc/ipc_entry.c: Likewise. * ipc/ipc_hash.c: Likewise. * ipc/ipc_kmsg.c: Likewise. * ipc/ipc_marequest.c: Likewise. * ipc/ipc_mqueue.c: Likewise. * ipc/ipc_notify.c: Likewise. * ipc/ipc_port.c: Likewise. * ipc/ipc_right.c: Likewise. * ipc/mach_debug.c: Likewise. * ipc/mach_msg.c: Likewise. * ipc/mach_port.c: Likewise. * ipc/mach_rpc.c: Likewise. * kern/act.c: Likewise. * kern/exception.c: Likewise. * kern/ipc_mig.c: Likewise. * kern/ipc_tt.c: Likewise. * kern/lock_mon.c: Likewise. * kern/mach_clock.c: Likewise. * kern/machine.c: Likewise. * kern/printf.c: Likewise. * kern/priority.c: Likewise. * kern/startup.c: Likewise. * kern/syscall_emulation.c: Likewise. * kern/syscall_subr.c: Likewise. * kern/thread_swap.c: Likewise. * kern/time_stamp.c: Likewise. * kern/timer.c: Likewise. * kern/xpr.c: Likewise. * vm/memory_object.c: Likewise. * vm/vm_debug.c: Likewise. * vm/vm_external.c: Likewise. * vm/vm_fault.c: Likewise. * vm/vm_kern.c: Likewise. * vm/vm_map.c: Likewise. * vm/vm_pageout.c: Likewise. * vm/vm_user.c: Likewise.
2014-04-04Use explicit prototypes for struct dev_ops fieldsMarin Ramesa
* device/conf.h: Include <sys/types.h>, <mach/port.h>, <mach/vm_prot.h>. Predefine struct io_req, io_req_t and io_return_t. (dev_ops): Add explicit prototypes for d_open, d_close, d_read, d_write, d_getstat, d_setstat, d_mmap, d_port_death. (nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath): Add prototypes. (nomap): Fix prototype. * device/dev_name.c (nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath): New functions. (nomap): Fix prototype. * device/ds_routines.c (dev_close): Pass 0 as flag parameter. * device/kmsg.c (kmsgclose): Drop return value. * device/kmsg.h (kmsgclose): Fix prototype. * i386/i386at/com.c (comopen): Fix prototype. (comclose): Fix prototype, drop return value. (comread, comwrite): Fix prototype. * i386/i386at/com.h (comopen, comclose, comread, comwrite): Fix prototype. * i386/i386at/conf.c (dev_ops): Use nulldev_open, nulldev_close, nulldev_read, nulldev_write, nulldev_getstat, nulldev_setstat, nulldev_portdeath where appropriate. * i386/i386at/kd.c (kdclose, kdread, kdwrite, kdmmap): Fix prototype. * i386/i386at/kd.h (kdclose, kdread, kdwrite, kdmmap): Likewise. * i386/i386at/kd_event.c (kbdopen): Likewise. * i386/i386at/kd_event.h (kbdopen): Likewise. * i386/i386at/kd_mouse.c (mouseopen): Likewise. * i386/i386at/kd_mouse.h (mouseopen): Likewise. * i386/i386at/lpr.c (lpropen, lprclose, lprread, lprwrite): Likewise. * i386/i386at/lpr.h (lpropen, lprclose, lprread, lprwrite): Likewise. * i386/i386at/mem.c (memmmap): Likewise. * i386/i386at/mem.h (memmmap): Likewise. * i386/i386at/model_dep.c (timemmap): Likewise. * i386/i386at/model_dep.h (timemmap): Likewise. * kern/mach_clock.c (timeopen, timeclose): Likewise. * kern/mach_clock.h: Include <sys/types.h>, predefine struct io_req and io_req_t. (timeopen, timeclose): Fix prototype.
2013-12-15Declare void argument listsMarin Ramesa
2013-12-11Cleanup of the memcpy(), memmove(), memcmp() and memset() callsMarin Ramesa
Addresses were cast to (void *). Pointers uncasted. * device/ds_routines.c (ds_read_done) (memset) (start_sent): Cast to (void *) instead to (char *). Argument is an address. (ds_read_done) (memset) (end_data): Likewise. * i386/i386/pcb.c (thread_getstatus) (memcpy) (pm): Don't cast. Argument is a pointer. (thread_getstatus) (memcpy) (iopb): Likewise. * i386/i386at/immc.c (immc_cnputc) (memmove): Cast first argument to (void *). Argument is an address. (immc_cnputc) (memmove): Cast second argument to (void *). Argument is an address. (immc_cnputc) (memset): Cast first argument to (void *). Argument is an address. * i386/i386at/model_dep.c (i386at_init) (memcpy) (phystokv): Cast to (void *) instead to (char *). Argument is an address. * i386/intel/pmap.c (pmap_init) (memset) (addr): Likewise. * ipc/mach_debug.c (mach_port_space_info) (memset) (table_addr + size_used): Likewise. (mach_port_space_info) (memset) (tree_addr + size_used): Likewise. * kern/host.c (host_processor_sets) (memcpy) (newaddr): Likewise. (host_processor_sets) (memcpy) (addr): Likewise. * kern/xpr.c (xprbootstrap) (memset) (addr): Likewise. * vm/vm_debug.c (mach_vm_object_pages) (memset) (addr + size_used): Likewise.
2013-12-09i386/i386at/model_dep.c: fix argument listMarin Ramesa
* i386/i386at/model_dep.c (timemmap): Fix argument list.
2013-12-09i386/i386at/model_dep.c, kd.c: use boolean instead of an intMarin Ramesa
* i386/i386at/kd.c (rebootflag): Use boolean instead of an int. Remove duplicate variable declaration. * i386/i386at/model_dep.c (rebootflag): Use boolean instead of an int.
2013-12-05i386/i386at/model_dep.c: remove forward declarationMarin Ramesa
* i386/i386at/model_dep.c (init_alloc_aligned): Remove forward declaration. * i386/i386at/model_dep.h (init_alloc_aligned): Add prototype.
2013-12-05i386/i386at: remove forward declarationsMarin Ramesa
* Makefrag.am: Include kern/startup.h. * i386/i386at/model_dep.c: Include kern/startup.h. Include i386at/model_dep.h. (setup_main, halt_all_cpus, halt_cpu, inittodr): Remove forward declarations. * i386/i386at/model_dep.h (halt_all_cpus, halt_cpu, inittodr): Add prototypes. * kern/startup.h: New file. Add copyright. [_KERN_STARTUP_H_]: Add ifndef. (setup_main): Add prototype.
2013-12-05i386/i386at/conf.c: remove forward declarationsMarin Ramesa
* i386/Makefrag.am: Include i386/i386at/model_dep.h and i386/i386at/mem.h. * i386/i386at/com.h (comgetstat, comsetstat): Declare as extern. (comopen, comclose, comread, comwrite, comportdeath): Add prototypes. * i386/i386at/conf.c: Include kern/mach_clock.h and i386at/model_dep.h. (timeopen, timeclose, timemmap): Remove forward declarations. (kdopen, kdclose, kdread, kdwrite, kdgetstat, kdsetstat, kdportdeath, kdmmap): Likewise. (comopen, comclose, comread, comwrite, comportdeath, comgetstat, comsetstat): Likewise. (lpropen, lprclose, lprread, lprwrite, lprportdeath, lprgetstat, lprsetstat): Likewise. (kbdopen, kbdclose, kbdread, kbdgetstat, kbdsetstat): Likewise. (mouseopen, mouseclose, mouseread, mousegetstat): Likewise. (memmmap): Likewise. (kmsgopen, kmsgclose, kmsgread, kmsggetstat): Likewise. (hypcnopen, hypcnclose, hypcnread, hypcnwrite, hypcnportdeath, hypcngetstat, hypcnsetstat): Likewise. Include i386at/kd.h. Include i386at/com.h. Include i386at/lpr.h. Include i386at/kd_event.h. Include i386at/kd_mouse.h. Include i386at/mem.h. Include device/kmsg.h. Include xen/console.h. * i386/i386at/kd.h: Include device/io_req.h. (kdopen, kdclose, kdread, kdwrite, kdgetstat, kdsetstat, kdportdeath, kdmmap): Add prototypes. * i386/i386at/kd_event.h (kbdopen, kbdclose, kbdread, kbdgetstat, kbdsetstat): Likewise. * i386/i386at/kd_mouse.h (mouseopen, mouseclose, mouseread, mousegetstat): Likewise. * i386/i386at/lpr.h (lpropen, lprclose, lprread, lprwrite, lprportdeath): Likewise. (lprgetstat, lprsetstat): Declare as extern. * i386/i386at/mem.h: New file. Add copyright. [_MEM_H_]: Add ifndef. (memmmap): Add prototype. * i386/i386at/model_dep.c: Include i386/i386at/model_dep.h. (timemmap): Fix argument list. * i386/i386at/model_dep.h: New file. Add copyright. [_MODEL_DEP_H_]: Add ifndef. (timemmap): Add prototype. * kern/mach_clock.h (timeopen, timeclose): Add prototypes. * xen/console.h (hypcnopen, hypcnclose, hypcnread, hypcnwrite, hypcnportdeath, hypcngetstat, hypcnsetstat): Add prototypes.
2013-12-05ddb/db_command.c: remove forward declarationMarin Ramesa
* ddb/db_command.c (db_reset_cpu): Remove forward declaration. * i386/i386/db_interface.h (db_reset_cpu): Add prototype. * i386/i386at/model_dep.c: Include i386/db_interface.h.
2013-11-20Fix implicit declaration of functionMarin Ramesa
* ddb/db_sym.c (aout_db_sym_init): Remove forward declaration. * ddb/db_sym.h (aout_db_sym_init): Add prototype. * i386/i386at/model_dep.c (aout_db_sym_init): Fix call. [MACH_KDB]: Include ddb/db_sym.h. [MACH_KDB]: Add comment after else and endif.
2013-11-09Remove lint codeMarin Ramesa
2013-06-10Add missing 4KiB memorySamuel Thibault
* i386/i386at/model_dep.c (init_alloc_aligned): Let allocated area last until end of memory map.
2013-06-10Add non-contiguous mmap supportSamuel Thibault
* i386/include/mach/i386/multiboot.h (multiboot_mmap): New structure * i386/i386at/model_dep.c (mem_size_init): Parse boot_info.mmap_addr if available. (init_alloc_aligned): Likewise.
2013-01-28Add initial code for disabling PV pagetablesSamuel Thibault
* xen/configfrag.ac (--disable-pv-pagetables): Add option. * i386/xen/xen_boothdr.S (XEN_ELFNOTE_FEATURES) [!MACH_PV_PAGETABLES]: Add writable_page_tables. * i386/i386/gdt.c: Turn appropriate MACH_XEN/MACH_HYP tests into MACH_PV_PAGETABLES tests. * i386/i386/i386asm.sym: Likewise * i386/i386/ldt.c: Likewise * i386/i386/locore.S: Likewise * i386/i386/proc_reg.h: Likewise * i386/i386/user_ldt.c: Likewise * i386/i386/vm_param.h: Likewise * i386/i386/xen.h: Likewise * i386/i386at/model_dep.c: Likewise * i386/intel/pmap.h: Likewise * include/mach/xen.h: Likewise * xen/console.c: Likewise * xen/store.c: Likewise * i386/intel/pmap.c: Likewise. Define pmap_map_mfn as TODO stub.
2012-03-24Make sure BIOS area is mapped in kernel threadsSamuel Thibault
* i386/i386at/model_dep.c (i386at_init): Map BIOS memory at 0. * i386/intel/pmap.c (pmap_create): Do not map BIOS memory in user tasks.
2012-03-24Separate INIT_VM_MIN_KERNEL_ADDRESS from VM_MIN_KERNEL_ADDRESSSamuel Thibault
The former is the initial value set by the bootloader. It may not be the same as what Mach will set up. * i386/i386/vm_param.h (INIT_VM_MIN_KERNEL_ADDRESS): New macro. * i386/i386at/model_dep.c (i386at_init): Use INIT_VM_MIN_KERNEL_ADDRESS instead of VM_MIN_KERNEL_ADDRESS.
2012-03-24Add missing phystokv/kvtophys callsSamuel Thibault
* i386/i386/vm_param.h [!MACH_XEN]: Do not include <xen/public/xen.h>. * i386/i386at/model_dep.c (init_alloc_aligned): Use phystokv to compare physical memory addresses with kernel start, end, and symbol table. * i386/intel/pmap.c (pmap_enter): Use kvtophys to convert ptp pointer to pte entry. * linux/dev/init/main.c (alloc_contig_mem, linux_init): Use phystokv to convert allocated pages to virtual pointer. * linux/src/include/asm-i386/io.h: Include <machine/vm_param.h>. (virt_to_phys): Call _kvtophys. (phys_to_virt): Call phystokv. * linux/src/include/linux/compatmac.h: Include <asm/io.h>. (ioremap): Use phys_to_virt to convert physical address to virtual pointer. (my_iounmap): Likewise. * linux/dev/include/asm-i386/page.h: Include <mach/vm_param.h>. (PAGE_SHIFT, PAGE_SIZE, PAGE_MASK): Remove macros. * linux/src/drivers/scsi/ncr53c8xx.c (vm_size_t): Remove type. * linux/dev/glue/net.c: Include <machine/vm_param.h> (device_write): Call phystokv to convert from physical page address to virtual pointer. * linux/dev/glue/block.c (alloc_buffer, free_buffer, rdwr_full): Likewise.
2012-03-23Fix boot with big values of _startSamuel Thibault
When _start is not close to 0, just using init_alloc_aligned() is not enough to know how much should be duplicated between linear and virtual mappings. Just mapping everything that can be is not very costly and should just work when it can work. * i386/i386at/model_dep.c (i386at_init) [VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS]: Extend `nb_direct' to VM_MIN_KERNEL_ADDRESS - LINEAR_MIN_KERNEL_ADDRESS.
2012-03-14Simplify i386at_initSamuel Thibault
* i386/i386at/model_dep.c (i386at_init): Do not copy linear into virtual kernel mapping when they are equal, and do not drop the former either. Use the function `i' variable.
2012-03-09Use unsigned long for addresses and sizesSamuel Thibault
TODO: remonter formats * i386/include/mach/i386/vm_types.h (vm_offset_t): Define to unsigned long. (signed32_t): Define to signed int. (unsigned32_t): Define to unsigned int. * i386/include/mach/sa/stdarg.h (__va_size): Use sizeof(unsigned long)-1 instead of 3. * include/mach/port.h (mach_port_t): Define to vm_offset_t instead of natural_t. * include/sys/types.h (size_t): Define to unsigned long instead of natural_t. * linux/src/include/asm-i386/posix_types.h (__kernel_size_t): Define to unsigned long. (__kernel_ssize_t): Define to long. * linux/src/include/linux/stddef.h (size_t): Define to unsigned long. * device/dev_pager.c (dev_pager_hash): Cast port to vm_offset_t insted of natural_t. (device_pager_data_request): Fix format. * device/ds_routines.c (ds_no_senders): Fix format. * i386/i386/io_map.c (io_map): Likewise. * i386/i386at/autoconf.c (take_dev_irq): Likewise. * i386/i386at/com.c (comattach): Likewise. * i386/i386at/lpr.c (lprattach): Likewise. * i386/i386at/model_dep.c (mem_size_init, mem_size_init, c_boot_entry): Likewise. * i386/intel/pmap.c (pmap_enter): Likewise. * ipc/ipc_notify.c (ipc_notify_port_deleted, ipc_notify_msg_accepted, ipc_notify_dead_name): Likewise. * ipc/mach_port.c (mach_port_destroy, mach_port_deallocate): Likewise. * kern/ipc_kobject.c (ipc_kobject_destroy): Likewise. * kern/slab.c (kalloc_init): Likewise. * vm/vm_fault.c (vm_fault_page): Likewise. * vm/vm_map.c (vm_map_pmap_enter): Likewise. * xen/block.c (device_read): Likewise. * device/net_io.c (bpf_match): Take unsigned long * instead of unsigned int *. (bpf_do_filter): Make mem unsigned long instead of long. * i386/i386/ktss.c (ktss_init): Cast pointer to unsigned long instead of unsigned. * i386/i386/pcb.c (stack_attach, switch_ktss): Cast pointers to long instead of int. * i386/i386/trap.c (dump_ss): Likewise. * ipc/ipc_hash.c (IH_LOCAL_HASH): Cast object to vm_offset_t. * ipc/mach_msg.c (mach_msg_receive, mach_msg_receive_continue): Cast kmsg to vm_offset_t instead of natural_t. * kern/pc_sample.c (take_pc_sample): Cast to vm_offset_t instead of natural_t. * kern/boot_script.c (sym, arg): Set type of `val' field to long instead of int. (create_task, builtin_symbols, boot_script_parse_line, boot_script_define_function): Cast to long instead of int. * kern/bootstrap.c (bootstrap_create): Likewise. * kern/sched_prim.c (decl_simple_lock_data): Likewise. * kern/printf.c (vsnprintf): Set size type to size_t. * kern/printf.h (vsnprintf): Likewise. * vm/vm_map.h (kentry_data_size): Fix type to vm_size_t. * vm/vm_object.c (vm_object_pmap_protect_by_page): Fix size parameter type to vm_size_t.
2012-02-19Fix format for string printSamuel Thibault
* i386/i386at/model_dep.c (c_boot_entry): Use %s format for printing a mere string, not the string.
2011-08-28Rework memory mapping reservationSamuel Thibault
* i386/i386/vm_param.h (VM_KERNEL_MAP_SIZE): Define to 192MiB. * i386/i386at/model_dep.c (mem_size_init): Use VM_KERNEL_MAP_SIZE instead of 1/6 factor. * i386/intel/pmap.c (morevm): Remove. (pmap_bootstrap): Use VM_KERNEL_MAP_SIZE instead of morevm.
2011-08-27Add prototypes for locore functionsGuillem Jover
* i386/i386at/model_dep.c (discover_x86_cpu_type): Move ... * i386/i386/locore.h: ... here. (inst_fetch, cpu_shutdown): New prototypes. * i386/i386at/kd.c: Include <i386/locore.h>.
2011-04-23Enable all cachesSamuel Thibault
* i386/i386at/model_dep.c (i386at_init): Set CR0_CD and CR0_NW in CR0 register.
2011-03-06Enable global pages after enabling pagingSamuel Thibault
* i386/i386at/model_dep.c (i386at_init): Enable CR4_PGE after enabling CR0_PG.
2011-03-05Fix temporary direct mapping during page table enablingSamuel Thibault
* i386/i386at/model_dep.c (i386at_init): Count the number of actually needed temporary L1 direct mapping by getting the last used address from init_alloc_aligned(), instead of hardcoding it to 1 or 3, and then use a for loop.