Commit Graph

420 Commits

Author SHA1 Message Date
f42e325785 Generate C code in OBJDIR
This should allow merging in the project without breaking "make dist"
after "make distclean".

This currently requires GCC though (for "-include").
2018-09-17 00:59:20 +02:00
c101f525d0 Let each architecture initialize its own platform 2018-09-17 00:38:35 +02:00
c9e099f0c2 Generate platform code from configuration 2018-09-16 17:29:08 +02:00
4139059c02 Avoid a couple divisions in the kernel
This helps compiling the kernel on NetBSD/amd64.
2018-08-25 02:00:21 +02:00
f139e583a8 Fix "make dist" 2018-08-23 21:44:49 +02:00
1c83f25941 Add get{pid,ppid}() 2018-08-23 21:44:34 +02:00
d14a72fd1d Update some dependencies 2018-08-23 02:09:24 +02:00
2085957927 Also mention QEMU's debug console I/O port 2018-08-23 01:56:06 +02:00
26c8bb115c Link every executable binary with crt{i,n}.o 2018-08-22 02:30:22 +02:00
d5d96defdd Allow year 2000 to have 366 days as it did 2018-08-14 19:05:16 +02:00
34dec8f44a Optimize a loop away 2018-08-14 19:05:00 +02:00
7a372859b8 Avoid signedness issues in a comparison 2018-08-13 23:27:57 +02:00
d3fbcb0886 Rework the epoch calculation 2018-08-13 23:21:42 +02:00
b0f8c18858 Avoid a couple compilation warnings 2018-08-09 03:02:06 +02:00
2a7370468a Minor optimization 2018-08-09 02:48:21 +02:00
47f78af238 Minor optimization 2018-08-09 02:47:16 +02:00
d337ec5e10 Divide with constants when possible
This may also help optimize a division away.
2018-08-09 02:13:27 +02:00
46275340ad Use crt{begin,end}.o again
This is instead of crt{begin,end}S.o. It seems to work fine with the
regular toolchain from NetBSD, and should help when building with
cross-compilers.
2018-08-09 02:07:31 +02:00
4a94984f78 Reduce the diff with DeforaOS libc 2018-08-04 02:25:40 +02:00
1e03411484 Import fixes for memory allocation from DeforaOS libc 2018-08-04 01:58:43 +02:00
c24f2d44a1 Code cleanup 2018-08-04 01:58:39 +02:00
295b7b4afe Always print to a valid console 2018-08-03 03:03:44 +02:00
bbca21b808 Code cleanup 2018-08-03 03:03:35 +02:00
4f8536876a Always use clock drivers with a valid instance 2018-08-03 02:17:38 +02:00
7af49989ec Do not compile _multiboot_start when not used 2018-08-03 01:53:06 +02:00
c7944c91da Code cleanup 2018-08-03 01:51:07 +02:00
018cdae162 Import realloc() in libuKernel 2018-08-02 23:38:41 +02:00
b5f0cf9f88 Avoid a few compilation warnings 2018-08-02 23:16:23 +02:00
447dcd6494 Code cleanup 2018-07-27 03:20:58 +02:00
2927b26d74 Separate the bus code from the VGA display driver 2018-07-27 03:15:40 +02:00
0b8a38ca45 Fix building the UART console driver 2018-07-21 05:30:43 +02:00
b6f3407b7d Import missing file 2018-07-21 05:23:53 +02:00
e16d7923ec Consider VGA and VESA as display drivers 2018-07-21 05:20:45 +02:00
c833a991c4 Remove unused header 2018-07-21 03:47:28 +02:00
a56ae53260 Define and use a few more constants 2018-07-21 03:50:59 +02:00
9f7b7dd810 Remove explicit casts 2018-07-21 03:50:59 +02:00
f23e59a8cb Add support for '\r' on VGA displays 2018-07-21 03:50:59 +02:00
c70d1748ba Add the usual base addresses for further serial ports 2018-07-19 02:04:51 +02:00
94d410d834 Unify the search path for includes 2018-07-17 14:37:55 +02:00
3b08127954 Expose CMOS bus commands to potential users 2018-07-17 13:38:47 +02:00
fcbbdfa986 Describe and use one more constant 2018-07-17 13:33:41 +02:00
0ca35efa15 Describe and use more constants 2018-07-17 02:16:59 +02:00
96398850bc Code cleanup 2018-07-17 02:12:03 +02:00
4ffeb920c2 Substract 1970 to the date guessed for the Epoch 2018-07-17 02:08:16 +02:00
513623335e Convert the date obtained to decimal if necessary 2018-07-17 02:06:13 +02:00
8901252c74 Code cleanup 2018-07-17 02:02:07 +02:00
f0834c0d76 Keep errno when devices fail to attach 2018-07-16 02:00:01 +02:00
7a20a906ad Remove debugging information 2018-07-16 01:38:58 +02:00
00069745d9 Improve the messages when initializing drivers 2018-07-16 01:40:49 +02:00
c2c5d522cd Add commands to enable or disable NMI
NMI stands for Non Maskable Interrupts.
2018-07-16 01:40:49 +02:00
f41d41e6e3 Change the order of arguments when getting the time 2018-07-16 01:40:43 +02:00
b6e22cac7f Remove the CMOS weekday register
It is apparently notoriously unreliable, and should not be used.
2018-07-16 01:40:11 +02:00
90c7f9eb0e Add a delay when reading from the CMOS bus 2018-07-16 01:40:11 +02:00
e935772f91 Code cleanup 2018-07-16 01:40:11 +02:00
2e71212695 Code cleanup 2018-07-15 23:37:33 +02:00
582a537575 Enable interrupts again 2018-07-15 05:49:05 +02:00
b5e6e07701 Set the IDT more like the GDT
This makes its initialization easier.
2018-07-15 05:46:34 +02:00
655e39736c Code cleanup 2018-07-15 03:58:31 +02:00
f59ea7131e Do not enable interrupts yet
This requires an interrupt handler to be configured first.
2018-07-15 03:56:00 +02:00
9a4e58760f Initialize the PIC 2018-07-15 03:55:08 +02:00
1d5a7a558b Initialize the clock 2018-07-15 03:54:42 +02:00
9480761ca2 Import a driver for the 8259a PIC
This is specific to Intel x86 platforms.
Not tested yet.
2018-07-15 03:47:33 +02:00
702497e79b Also build the PIC framework helper 2018-07-15 03:44:15 +02:00
758a0673a4 Compare the results obtained for consistency 2018-07-15 03:43:02 +02:00
915ab5828d Check if the clock data is available 2018-07-15 03:40:47 +02:00
c6672662af Code cleanup 2018-07-15 03:38:36 +02:00
644d3ce68e Code cleanup 2018-07-15 03:36:53 +02:00
bc9aaf9fc8 Code cleanup 2018-07-15 03:36:28 +02:00
164fc9c5d5 Let bus drivers handle custom commands 2018-07-15 03:35:59 +02:00
67f9ed2698 Add iowait() to the I/O port operations 2018-07-15 03:34:25 +02:00
5f4514de4f Import a framework to program PICs 2018-07-15 01:21:54 +02:00
3f044e4d09 Register a missing dependency on src/arch/i386/intr.S 2018-07-15 01:09:04 +02:00
9465401609 Move the CMOS clock constants to a dedicated file 2018-07-15 01:07:38 +02:00
f96504400a Code cleanup 2018-07-15 01:07:12 +02:00
b2d68c57b5 Do not ship stdio.c twice 2018-07-15 00:52:35 +02:00
cf919577c7 Use the relocatable versions of crt{begin,end}.o 2018-07-06 01:35:38 +02:00
7ace62c040 Let configure handle $(OBJDIR) for crt{begin,end}.o
This should be the appropriate way now that configure uses $(OBJDIR) by
default for non-phony commands.
2018-07-06 01:33:52 +02:00
2052b79c37 Avoid a compilation warning 2018-06-25 02:18:55 +02:00
d890ba8541 Correct some dependencies 2018-06-25 02:24:05 +02:00
e5bc6ea415 Import a crude CMOS clock driver
This still does not work though.
2018-06-25 02:23:40 +02:00
2e9b282606 Import missing file 2018-06-25 01:04:52 +02:00
08c1c42390 Code cleanup 2018-06-25 01:03:00 +02:00
edc3e1a83c Add a destructor to console drivers 2018-06-25 01:02:49 +02:00
a9ec1310f4 Constify 2018-06-25 01:02:11 +02:00
aff1004829 Code cleanup 2018-06-25 01:00:57 +02:00
af1af88c21 Code cleanup 2018-06-24 16:21:36 +02:00
a0b876e70b Code cleanup 2018-06-24 13:39:03 +02:00
d1cd8f96cc Send kernel messages to the error stream 2018-06-24 03:28:00 +02:00
e8cb79a6a5 Let the boot messages be slightly clearer 2018-06-24 03:26:44 +02:00
ce05b955bb Add support for mmap() in the loader
This is required when relocating the kernel.
2018-06-24 03:20:10 +02:00
09bdd96f2d Initialize the CMOS bus driver in the kernel
Unfortunately this code currently has to be added in the loader, without
it being strictly necessary.
2018-06-24 03:20:10 +02:00
d541a1984c Register the CMOS bus driver 2018-06-24 03:20:10 +02:00
31df610b47 Import an initial driver for the CMOS 2018-06-24 03:20:10 +02:00
175f908c86 Import an initial framework to manage interrupts 2018-06-24 03:20:10 +02:00
fca52ca94f Check the program header for consistency 2018-06-24 03:20:10 +02:00
914e11e95e Import a basic implementation of mmap() and munmap() 2018-06-23 01:21:09 +02:00
a0b6928ca8 Exit upon errors when multibooting 2018-06-21 02:13:19 +02:00
47ba6fe99e Implement a basic malloc() in the kernel 2018-06-21 02:08:59 +02:00
1020b7c0fb Allow kernels without modules to start 2018-06-21 02:04:47 +02:00
b05c58c8f8 Also provide the command line to the kernel 2018-06-21 00:41:25 +02:00
a0f9602d67 Import most of the memory allocator from the libc
This still requires implementing _brk() in the kernel.
2018-06-21 00:24:18 +02:00
9948eb7a7a Build STDIOConsole like a regular console driver 2018-06-21 00:02:14 +02:00
81a378c9fe Add a couple comments 2018-06-21 00:00:38 +02:00
4ac899b883 Avoid a compilation warning 2018-06-20 21:57:01 +02:00
ca6c413f37 Code cleanup 2018-06-20 21:50:21 +02:00
0297043898 Use the correct type to access the bus 2018-06-19 08:24:27 +02:00
77041ec310 Use uintptr_t for bus addresses
This currently drastically reduces the amount of compilation warnings.
2018-06-19 08:20:05 +02:00
a42b74fa4f Remove unused variable 2018-06-12 09:20:55 -04:00
df3398286b Include missing header <stdio.h> 2018-06-12 09:20:41 -04:00
6a1bae7da1 Create a separate file for the IDT on amd64 2018-06-11 18:15:54 -04:00
8db00b35a7 Register missing dependencies 2018-06-08 23:54:45 -04:00
d5516fa810 Buffer the output of the console until it is available 2018-06-08 12:09:26 -04:00
c208a2f427 Import strncpy() into the library 2018-06-08 12:08:26 -04:00
5fada57d6a Add driver names to ukConsole drivers 2018-06-08 11:33:50 -04:00
64451ae791 Rework the bus attachment 2018-06-08 11:21:57 -04:00
0f4f39e067 Rework the bus drivers 2018-06-08 00:24:55 -04:00
bac9bd3bf2 Import strncmp() 2018-06-08 00:23:14 -04:00
ffdc7343f4 Import placeholders for free() and malloc() 2018-06-07 23:56:26 -04:00
8214751336 Import abs() for consistency
Since labs() and llabs() are already there, it only makes sense.
2018-06-07 23:56:26 -04:00
377f7b9b67 Rename _end to end
This matches the libc more closely.
2018-06-07 23:52:27 -04:00
01870ca892 Implement fprintf() 2018-06-07 17:02:44 -04:00
6d171d207d Align assembly operands 2018-06-07 11:53:39 -04:00
58e0cad31a Simplify kernel code down to a userland lookalike 2018-06-07 11:35:01 -04:00
ba760161d8 Also build the UART console 2018-06-07 11:32:29 -04:00
cd15ac2ff9 Code cleanup 2018-06-07 11:28:51 -04:00
d1aaccd305 Fix output in the UART console 2018-06-07 11:28:51 -04:00
c500384fba Do not ask the kernel to load itself again 2018-06-07 11:28:51 -04:00
7cf4f96ff4 Constify 2018-06-07 11:28:51 -04:00
556142e0b5 Implement a placeholder for read() 2018-06-07 11:28:51 -04:00
87ce51d15e Default to three file descriptors opened 2018-06-07 11:28:51 -04:00
076b9bc577 Add support for setting the mode in serial consoles 2018-06-07 11:28:51 -04:00
355a4b613a Also pass envp and auxv to main() 2018-06-07 11:28:51 -04:00
ffdf050544 Allow the UART console to be loaded 2018-06-07 11:28:51 -04:00
ad22b10aa3 Clarify that reaching the bootloader means failure 2018-06-07 11:28:51 -04:00
91cde21c72 Pass the command line over to the bootloader 2018-06-07 11:28:51 -04:00
8f959e7569 Perform relocations relative to the existing address
This helps support relocations with Elf_Rel and embedded addend values.
2018-06-07 11:28:51 -04:00
95a5f15947 Register more dependencies 2018-06-07 11:28:51 -04:00
fd88fad441 Restore the stack state after calls as expected 2018-06-07 11:28:51 -04:00
9535d422c6 Import a driver for the console on serial ports 2018-06-07 11:28:51 -04:00
9a1d3ccdf7 Code cleanup 2018-06-07 11:28:51 -04:00
b508738c45 Link the kernel and loader with libgcc
It is currently required for a division.
2018-06-07 11:28:51 -04:00
21470a46af Work on relocations 2018-06-07 11:28:51 -04:00
6d687d0959 Verify if the target symbol is valid 2018-06-07 11:28:51 -04:00
3c70509368 Fixing chaining Multiboot support to the kernel
This still requires removing the kernel itself from the list of modules.
2018-06-07 11:28:51 -04:00
9fda20ad21 Mention which module is loaded as the kernel 2018-06-07 11:28:51 -04:00
b01e31219e Register a dependency 2018-06-07 11:28:51 -04:00
d321277d80 Abort when failing to relocate 2018-06-07 11:28:51 -04:00
23761d3dc7 Code cleanup 2018-06-07 11:28:51 -04:00
5d078a4094 Restore the stack state after calling multiboot() 2018-06-07 11:28:51 -04:00
70b9a70645 Import missing files 2018-06-07 11:28:51 -04:00
81623ef3a5 Import missing file 2018-06-07 11:28:51 -04:00
f35f4ed986 Add support for 64-bit relocations 2018-06-07 11:28:51 -04:00
5338c6143b Avoid some compilation warnings 2018-06-07 11:28:51 -04:00
b2d2221cd5 Add support for relocating 32-bit modules 2018-06-07 11:28:51 -04:00
00d9486b53 Align the kernel's Multiboot on the loader 2018-06-07 11:28:51 -04:00
a4f1f00c1e Also set the IDT in the i386 kernel 2018-06-07 11:28:51 -04:00
4c91f5ecb0 Code cleanup 2018-06-07 11:28:51 -04:00
5ee403dafd Fully re-use the IDT code from i386 2018-06-07 11:28:51 -04:00
790d3fb627 Allow re-using the Multiboot constants 2018-06-07 11:28:51 -04:00
9b6b86802f Let consoles be resized 2018-06-07 11:28:51 -04:00
2c71a23bb2 Detect when the VESA console driver should be in use 2018-06-07 11:28:51 -04:00
1e925e249f Prepare support for non-ELF modules 2018-06-07 11:28:51 -04:00
e9265d0fc7 No longer assume the console may be NULL 2018-06-07 11:28:51 -04:00
c094f968b7 Import missing include "drivers/console.h" 2018-06-07 11:28:51 -04:00
f037cd0996 Add a few comments 2018-06-07 11:28:51 -04:00
41bdc2fba2 Also include <string.h> as required 2018-06-07 11:28:51 -04:00
33aab60b09 Fix a return value 2018-06-07 11:28:51 -04:00
9e30bc0315 Reorganize the whole thing 2018-06-07 11:28:51 -04:00
89f9b74a83 Import more code to jump in 64-bit kernels 2018-06-07 11:28:51 -04:00
ccfc53af83 Use errno to store the error 2018-06-07 11:26:00 -04:00
3873e014e6 Clear the last lines when scrolling 2018-06-01 03:18:55 +02:00
8f493d836a Correct the VBE information in Multiboot 2018-05-30 00:46:40 +02:00
4e1048e71a Actually clear the stack after calling functions 2018-05-30 00:29:28 +02:00
1228db3c42 Use the correct flags for ukBootMultibootInfo 2018-05-27 20:15:36 +02:00
fbbaa8f17c Add constants for ukBootMultibootInfo's flags 2018-05-27 20:10:32 +02:00
1f9de79442 Fix building out of tree with object files already present 2018-05-27 20:07:16 +02:00
6e5f6d9fc8 Fix scrolling the console 2018-05-27 19:48:53 +02:00
fda77da39a Fix the optimization when scrolling the console 2018-05-27 19:48:07 +02:00
01befa0359 Import <ctype.h> into libuKernel 2018-05-27 16:17:14 +02:00
7c68d824e3 Actually clear the stack after calling functions 2018-05-27 15:53:02 +02:00
754e16241d Add the _edata symbol to the loader 2018-04-12 05:53:15 +02:00
eaf8800d78 Add the _end symbol to the loader 2018-04-12 05:53:05 +02:00
5c353eb5a7 Import memcmp() into <string.h> 2018-04-12 03:02:31 +02:00
ad36f07999 Correct some types in the bus API 2018-04-12 02:41:46 +02:00
a9aae10b39 Fix some instructions when starting and exiting the kernel 2018-04-11 07:14:47 +02:00
a1705d2c38 Code cleanup 2018-04-08 05:26:36 +02:00
43c67c0889 Fix setting the GDT 2018-04-08 05:25:09 +02:00
c8ba11c219 Import another linker script for 64-bit kernels 2018-04-08 00:48:55 +02:00
db320f41bd Fix finding the entrypoint for 64-bit kernels 2018-04-08 00:35:38 +02:00
3369ba4ac6 Correct the entrypoint for 32-bit kernels 2018-04-07 07:26:55 +02:00
27ae6780e0 Really try to locate the entrypoint for 64-bit kernels 2018-04-07 07:25:55 +02:00
b9ff984718 Look harder for the kernel's entrypoint 2018-04-07 07:13:06 +02:00
0aa13f90b3 Correct setting the size of the GDT descriptor 2018-04-07 06:21:58 +02:00
e160aa08be Print the amount of memory available 2018-04-07 06:08:30 +02:00
14a418a3a2 Make the .bss section bigger for the i386 loader 2018-04-07 05:54:00 +02:00
fdd310cb0c Attempt to jump into 32-bit kernels 2018-04-07 05:40:21 +02:00
ec663f4669 Allow booting 64-bit kernels 2018-04-07 05:05:15 +02:00
e3859505d0 Setup the GDT on i386 2018-04-07 05:00:34 +02:00
2912fe790e Pass the Multiboot information on to the kernel 2018-04-07 03:14:42 +02:00
a44261a91c Code cleanup 2018-04-07 03:14:28 +02:00