Commit Graph

425 Commits

Author SHA1 Message Date
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
f2c140dc41 Make better use of <stdio.h> 2018-04-06 00:58:42 +02:00
524ae76303 Avoid some compilation warnings 2018-04-06 00:56:43 +02:00
d0a4284250 Import printf(3) into libuKernel 2018-04-06 00:18:16 +02:00
bae76e2a62 Bring the 64-bit kernel closer to reality 2018-04-05 20:20:13 +02:00
f6d7587066 Generate a smaller version of libuKernel for the loader
This will also help build the 64-bit version of the kernel.
2018-04-05 19:45:23 +02:00
5084948028 Obtain the entrypoint for the kernel 2018-04-05 19:30:25 +02:00
e0c575856b Register the u{Kernel,Loader}.bin targets 2018-04-05 04:39:32 +02:00
e94b1124da Remove the multiboot header for the 64-bit kernel 2018-04-05 04:41:36 +02:00
a34543e1df Fix the build 2018-04-05 04:40:55 +02:00
2e65f87140 Provide the correct compilation flags for an amd64 kernel 2018-04-05 04:24:25 +02:00
0ccbbe5a03 Detect the ELF class of the kernel 2018-04-05 04:09:51 +02:00
b2f2cf4131 Code cleanup 2018-04-05 03:47:53 +02:00
54ee4ecadd Let the i386 kernel possibly boot on its own 2018-04-05 03:47:17 +02:00
beff2a1007 Report errors when missing the kernel 2018-04-05 03:37:19 +02:00
7562b69ed5 Let the console be located by name 2018-04-05 03:24:14 +02:00
861e03c019 Use puts(9) to print to the console 2018-04-05 03:09:27 +02:00
186cfff0f1 Introduce <stdio.h> 2018-04-05 03:08:56 +02:00
cbe0064bac Avoid potential crashes in the console 2018-04-05 03:08:04 +02:00
eeff2ec519 Let shipping architecture-dependent files be easier 2018-04-05 02:25:01 +02:00
18db76ca5a Move code around for better isolation 2018-04-05 02:15:30 +02:00
58bb9a5124 Code cleanup 2018-04-05 01:20:57 +02:00
4aac25ed3c Fix the build 2018-04-05 01:19:53 +02:00
ca7fa1fac5 Turn the current kernel into a Multiboot loader 2018-04-05 01:10:08 +02:00
286d2aba01 Add strlen() to <string.h> 2018-04-05 01:08:07 +02:00
1a8cf835fb Let the default bus be configured 2018-04-04 23:45:40 +02:00
6b9ec3f30b Add strcmp() to <string.h> 2018-04-04 23:45:09 +02:00
75087533be Rework cursor management for the "vga" console 2018-04-04 05:18:58 +02:00
31bd71852a Rename the "stdio" bus to "tty"
This will help disambiguate from the console driver of the same name.
2018-04-04 03:58:20 +02:00
7416dcb8ac Avoid some compilation warnings 2018-04-04 03:54:49 +02:00
edbfc3602a Consider the address as the file descriptor 2018-04-04 03:46:34 +02:00
cfe8938f38 Also ship the "stdio" bus driver 2018-04-04 03:45:42 +02:00
5e2ba55f86 Also ship the "stdio" console driver 2018-04-04 03:45:20 +02:00
ca9dc4bb53 Use buses for the userland implementation as well 2018-04-04 03:29:15 +02:00
7bb329e41a Migrate the console driver to a class 2018-04-04 02:43:48 +02:00
9bd6b85451 Code cleanup 2018-04-04 02:12:00 +02:00
202e0bb0ce Add a prefix to kernel classes 2018-04-04 02:11:01 +02:00
0ef750cd7e Migrate the bus driver to a class 2018-04-04 02:04:09 +02:00
e938588d31 Always report success from outb() 2018-04-04 02:00:17 +02:00
520baba815 Add support for moving the cursor 2018-04-04 01:47:03 +02:00
d67fe7e2f0 Introduce the "ioport" bus 2018-04-04 01:46:35 +02:00
00360e361d Introduce <errno.h> 2018-04-04 01:37:36 +02:00
61dd856d6c Really disable the stack protector on OpenBSD 2018-03-28 06:25:39 +02:00
f46f70cc18 Fix importing crt{begin,end}.o
This may not bring the right versions of the object files though
(missing flags to $(CC)).
2018-03-28 05:52:45 +02:00
7a4342dfba Determine the {C,LD}FLAGS from a shell script
This should simplify targeting specific architectures for the moment.
2018-03-28 05:20:30 +02:00
5ca17648bf Begin a port on the amd64 architecture
This is still far from working.
2018-03-27 00:11:45 +02:00
8d00697ed8 Add copyright information 2018-03-27 00:04:18 +02:00
335a0e4395 Code cleanup 2018-03-27 00:03:20 +02:00
d07ee6b951 No longer build with -m32 by default
This is currently correct, since only i386 is supported. To
cross-compile from amd64, it is still possible to use CC="gcc -m32".
2018-03-27 00:02:17 +02:00
e7113a8b49 Build libuKernel with -fPIC by default 2018-03-27 00:01:17 +02:00
5e6d68106b Move libuKernel to a subdirectory 2018-03-23 02:43:26 +01:00
6bd4ff4773 Also link with crt{begin,end}.o 2018-03-23 02:34:57 +01:00
c5addb33f4 Add support for the global constructors 2018-03-23 02:28:54 +01:00
195bd77aa6 Register more object types 2018-03-23 02:07:22 +01:00
9a2cf8af5c Introduce libuKernel 2018-03-21 22:45:11 +01:00
22b23c8521 Register some dependencies 2018-03-21 03:17:51 +01:00
3a0315f9aa Implement abort() with exit() 2018-03-21 03:15:28 +01:00
2d55e05bfc Add support for stack-smashing protection (SSP) 2018-03-21 03:04:45 +01:00
c9245359ef Add memset() 2018-03-21 02:30:12 +01:00
532ac8f131 Implement screen scrolling (untested) 2018-03-21 02:28:45 +01:00
1a773d7ab2 Print a message while booting 2018-03-21 02:08:31 +01:00
00ef683c6b Move definitions into vga.h 2018-03-21 01:59:28 +01:00
5678808c6f Introduce <stddef.h> and <stdint.h> 2018-03-21 01:57:33 +01:00
3403f067df Code cleanup 2018-03-20 03:41:35 +01:00
8adfbfbabd Code cleanup 2018-03-20 03:35:45 +01:00
9d1ba0a978 Clear the VGA console upon initialization 2018-03-20 03:32:31 +01:00
0f259d551b Move the console code to a separate driver 2018-03-20 03:20:19 +01:00
f6d38bf5fa Force the kernel to be built in 32-bits mode
Focus on the 32-bits architecture for the moment.
2018-03-20 02:58:33 +01:00
527a5e783f Use CFLAGS in ASFLAGS when using cc(1) as as(1) 2018-03-20 02:38:36 +01:00
c289b6e529 Register some targets and intermediate files 2018-03-19 00:40:56 +01:00
972e977ef7 Initial import
This is directly inspired by https://wiki.osdev.org/Bare_Bones.
2018-03-19 00:40:47 +01:00