mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
Initial commit
This commit is contained in:
commit
ddac1a791e
132 changed files with 11491 additions and 0 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
676
LICENSE
Normal file
676
LICENSE
Normal file
|
|
@ -0,0 +1,676 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright(C) Chris (boreddevnl) 2024-2026
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
122
Makefile
Normal file
122
Makefile
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
# BrewOS Makefile
|
||||
# Target Architecture: x86_64
|
||||
# Host: macOS
|
||||
|
||||
# Toolchain Definitions
|
||||
CC = x86_64-elf-gcc
|
||||
LD = x86_64-elf-ld
|
||||
NASM = nasm
|
||||
XORRISO = xorriso
|
||||
|
||||
# Directories
|
||||
SRC_DIR = src/kernel
|
||||
BUILD_DIR = build
|
||||
ISO_DIR = iso_root
|
||||
|
||||
# Output
|
||||
KERNEL_ELF = $(BUILD_DIR)/brewos.elf
|
||||
ISO_IMAGE = brewos.iso
|
||||
|
||||
# Source Files
|
||||
C_SOURCES = $(wildcard $(SRC_DIR)/*.c)
|
||||
CLI_APP_SOURCES = $(wildcard $(SRC_DIR)/cli_apps/*.c)
|
||||
ASM_SOURCES = $(wildcard $(SRC_DIR)/*.asm)
|
||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES)) \
|
||||
$(patsubst $(SRC_DIR)/cli_apps/%.c, $(BUILD_DIR)/cli_apps/%.o, $(CLI_APP_SOURCES)) \
|
||||
$(patsubst $(SRC_DIR)/%.asm, $(BUILD_DIR)/%.o, $(ASM_SOURCES))
|
||||
|
||||
# Flags
|
||||
CFLAGS = -g -O2 -pipe -Wall -Wextra -std=gnu11 -ffreestanding \
|
||||
-fno-stack-protector -fno-stack-check -fno-lto -fPIE \
|
||||
-m64 -march=x86-64 -mno-80387 -mno-mmx -mno-sse -mno-sse2 -mno-red-zone \
|
||||
-I$(SRC_DIR) -I$(SRC_DIR)/cli_apps
|
||||
|
||||
LDFLAGS = -m elf_x86_64 -nostdlib -static -pie --no-dynamic-linker \
|
||||
-z text -z max-page-size=0x1000 -T linker.ld
|
||||
|
||||
NASMFLAGS = -f elf64
|
||||
|
||||
# Limine Version
|
||||
LIMINE_VERSION = 7.0.0
|
||||
LIMINE_URL_BASE = https://github.com/limine-bootloader/limine/raw/v$(LIMINE_VERSION)
|
||||
|
||||
.PHONY: all clean run limine-setup
|
||||
|
||||
all: $(ISO_IMAGE)
|
||||
|
||||
# Ensure build directories exist
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
mkdir -p $(BUILD_DIR)/cli_apps
|
||||
|
||||
# Download Limine Binaries via Git
|
||||
limine-setup:
|
||||
@if [ ! -f limine/limine-bios.sys ]; then \
|
||||
echo "Limine binaries missing or invalid. Cloning v$(LIMINE_VERSION)-binary..."; \
|
||||
rm -rf limine; \
|
||||
git clone https://github.com/limine-bootloader/limine.git --branch=v$(LIMINE_VERSION)-binary --depth=1 limine; \
|
||||
fi
|
||||
@if [ ! -f $(SRC_DIR)/limine.h ]; then \
|
||||
echo "Copying limine.h..."; \
|
||||
cp limine/limine.h $(SRC_DIR)/limine.h; \
|
||||
fi
|
||||
@echo "Building Limine host utility..."; \
|
||||
$(MAKE) -C limine
|
||||
|
||||
# Compile C Sources
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR) limine-setup
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Compile CLI Apps C Sources
|
||||
$(BUILD_DIR)/cli_apps/%.o: $(SRC_DIR)/cli_apps/%.c | $(BUILD_DIR) limine-setup
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Assemble ASM Sources
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.asm | $(BUILD_DIR)
|
||||
$(NASM) $(NASMFLAGS) $< -o $@
|
||||
|
||||
# Link Kernel
|
||||
$(KERNEL_ELF): $(OBJ_FILES)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJ_FILES)
|
||||
|
||||
# Create ISO
|
||||
$(ISO_IMAGE): $(KERNEL_ELF) limine.cfg limine-setup
|
||||
rm -rf $(ISO_DIR)
|
||||
mkdir -p $(ISO_DIR)
|
||||
mkdir -p $(ISO_DIR)/EFI/BOOT
|
||||
|
||||
# Copy Kernel and Config
|
||||
cp $(KERNEL_ELF) $(ISO_DIR)/
|
||||
cp limine.cfg $(ISO_DIR)/
|
||||
|
||||
# Copy README
|
||||
cp README.md $(ISO_DIR)/
|
||||
|
||||
# Copy Wallpaper (if it exists)
|
||||
@if [ -f src/kernel/wallpaper.ppm ]; then cp src/kernel/wallpaper.ppm $(ISO_DIR)/; fi
|
||||
|
||||
# Copy Limine Bootloader Files (flat structure in binary branch)
|
||||
cp limine/limine-bios.sys $(ISO_DIR)/
|
||||
cp limine/limine-bios-cd.bin $(ISO_DIR)/
|
||||
cp limine/limine-uefi-cd.bin $(ISO_DIR)/
|
||||
|
||||
# Create EFI Boot Files
|
||||
cp limine/BOOTX64.EFI $(ISO_DIR)/EFI/BOOT/
|
||||
cp limine/BOOTIA32.EFI $(ISO_DIR)/EFI/BOOT/
|
||||
|
||||
# Generate ISO
|
||||
$(XORRISO) -as mkisofs -b limine-bios-cd.bin \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
--efi-boot limine-uefi-cd.bin \
|
||||
-efi-boot-part --efi-boot-image --protective-msdos-label \
|
||||
$(ISO_DIR) -o $(ISO_IMAGE)
|
||||
|
||||
# Install Limine to ISO (for BIOS boot)
|
||||
./limine/limine bios-install $(ISO_IMAGE)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(ISO_DIR) $(ISO_IMAGE)
|
||||
|
||||
run: $(ISO_IMAGE)
|
||||
qemu-system-x86_64 -m 2G -serial stdio -cdrom $(ISO_IMAGE) -boot d \
|
||||
-audiodev coreaudio,id=audio0 -machine pcspk-audiodev=audio0
|
||||
148
README.md
Normal file
148
README.md
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
# Brew OS 1.01 Alpha
|
||||
|
||||
## Brewkernel is now BrewOS!
|
||||
Brewkernel will from now on be deprecated as it's core became too messy. I have built a less bloated kernel and wrote a DE above it, which is why it is now an OS instead of a kernel (in my opinion).
|
||||
|
||||
|
||||
<img src="asciiart.png" width="200" /> </br>
|
||||
Brew Kernel is a simple x86_64 hobbyist operating system.
|
||||
It features a DE (and WM), a FAT32 filesystem, customizable UI and much much more!
|
||||
|
||||
## Features
|
||||
- Brew WM
|
||||
- Fat 32 FS
|
||||
- 64-bit long mode support
|
||||
- Multiboot2 compliant
|
||||
- Text editor
|
||||
- IDT
|
||||
- Ability to run on actual x86_64 hardware
|
||||
- CLI
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To build BrewOS, you'll need the following tools installed:
|
||||
|
||||
- **x86_64 ELF Toolchain**: `x86_64-elf-gcc`, `x86_64-elf-ld`
|
||||
- **NASM**: Netwide Assembler for compiling assembly code
|
||||
- **xorriso**: For creating bootable ISO images
|
||||
- **QEMU** (optional): For testing the kernel in an emulator
|
||||
|
||||
On macOS, you can install these using Homebrew:
|
||||
```sh
|
||||
brew install x86_64-elf-binutils x86_64-elf-gcc nasm xorriso qemu
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
Simply run `make` from the project root:
|
||||
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Compile all kernel C sources and assembly files
|
||||
2. Link the kernel ELF binary
|
||||
3. Generate a bootable ISO image (`brewos.iso`)
|
||||
|
||||
The build output is organized as follows:
|
||||
- Compiled object files: `build/`
|
||||
- ISO root filesystem: `iso_root/`
|
||||
- Final ISO image: `brewos.iso`
|
||||
|
||||
## Running
|
||||
|
||||
### QEMU Emulation
|
||||
|
||||
Run the kernel in QEMU:
|
||||
|
||||
```sh
|
||||
make run
|
||||
```
|
||||
|
||||
Or manually:
|
||||
```sh
|
||||
qemu-system-x86_64 -m 2G -serial stdio -cdrom brewos.iso -boot d
|
||||
```
|
||||
|
||||
### Running on Real Hardware
|
||||
|
||||
*Warning: This is at YOUR OWN RISK. This software comes with ZERO warranty and may break your system.*
|
||||
|
||||
1. **Create bootable USB**: Use [Balena Etcher](https://www.balena.io/etcher/) to flash `brewos.iso` to a USB drive
|
||||
|
||||
2. **Prepare the system**:
|
||||
- Enable legacy (BIOS) boot in your system BIOS/UEFI settings
|
||||
- Disable Secure Boot if needed
|
||||
|
||||
3. **Boot**: Insert the USB drive and select it in the boot menu during startup
|
||||
|
||||
4. **Tested Hardware**:
|
||||
- HP EliteDesk 705 G4 DM (AMD Ryzen 5 PRO 2400G, Radeon Vega)
|
||||
- Lenovo ThinkPad A475 20KL002VMH (AMD Pro A12-8830B, Radeon R7)
|
||||
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `src/kernel/` - Main kernel implementation
|
||||
- `boot.asm` - Boot assembly code
|
||||
- `main.c` - Kernel entry point
|
||||
- `*.c / *.h` - Core kernel modules (graphics, interrupts, filesystem, etc.)
|
||||
- `cli_apps/` - Command-line applications
|
||||
- `wallpaper.ppm` - Default desktop wallpaper
|
||||
- `build/` - Compiled object files (generated during build)
|
||||
- `iso_root/` - ISO filesystem layout (generated during build)
|
||||
- `limine/` - Limine bootloader files (downloaded automatically)
|
||||
- `linker.ld` - Linker script for x86_64 ELF
|
||||
- `limine.cfg` - Limine bootloader configuration
|
||||
- `Makefile` - Build configuration and targets
|
||||
|
||||
|
||||
|
||||
|
||||
###
|
||||
###
|
||||
|
||||
<h2 align="left">Help me brew some coffee! ☕️</h2>
|
||||
|
||||
###
|
||||
|
||||
<p align="left">
|
||||
If you enjoy this project, and like what i'm doing here, consider buying me a coffee!
|
||||
<br><br>
|
||||
<a href="https://buymeacoffee.com/boreddevnl" target="_blank">
|
||||
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="50" style="border-radius: 8px;" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
###
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Copyright (C) 2024-2026 boreddevnl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
NOTICE
|
||||
------
|
||||
|
||||
This product includes software developed by Chris ("boreddevnl") as part of the BrewKernel project.
|
||||
|
||||
Copyright (C) 2024–2026 Chris / boreddevnl (previously boreddevhq)
|
||||
|
||||
All source files in this repository contain copyright and license
|
||||
headers that must be preserved in redistributions and derivative works.
|
||||
|
||||
If you distribute or modify this project (in whole or in part),
|
||||
you MUST:
|
||||
|
||||
- Retain all copyright and license headers at the top of each file.
|
||||
- Include this NOTICE file along with any redistributions or
|
||||
derivative works.
|
||||
- Provide clear attribution to the original author in documentation
|
||||
or credits where appropriate.
|
||||
|
||||
The above attribution requirements are informational and intended to
|
||||
ensure proper credit is given. They do not alter or supersede the
|
||||
terms of the GNU General Public License (GPL), which governs this work.
|
||||
BIN
asciiart.png
Normal file
BIN
asciiart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
brewos.iso
Normal file
BIN
brewos.iso
Normal file
Binary file not shown.
BIN
build/about.o
Normal file
BIN
build/about.o
Normal file
Binary file not shown.
BIN
build/boot.o
Normal file
BIN
build/boot.o
Normal file
Binary file not shown.
BIN
build/brewos.elf
Executable file
BIN
build/brewos.elf
Executable file
Binary file not shown.
BIN
build/calculator.o
Normal file
BIN
build/calculator.o
Normal file
Binary file not shown.
BIN
build/cli_apps/about.o
Normal file
BIN
build/cli_apps/about.o
Normal file
Binary file not shown.
BIN
build/cli_apps/beep.o
Normal file
BIN
build/cli_apps/beep.o
Normal file
Binary file not shown.
BIN
build/cli_apps/blind.o
Normal file
BIN
build/cli_apps/blind.o
Normal file
Binary file not shown.
BIN
build/cli_apps/clear.o
Normal file
BIN
build/cli_apps/clear.o
Normal file
Binary file not shown.
BIN
build/cli_apps/cli_utils.o
Normal file
BIN
build/cli_apps/cli_utils.o
Normal file
Binary file not shown.
BIN
build/cli_apps/cowsay.o
Normal file
BIN
build/cli_apps/cowsay.o
Normal file
Binary file not shown.
BIN
build/cli_apps/date.o
Normal file
BIN
build/cli_apps/date.o
Normal file
Binary file not shown.
BIN
build/cli_apps/exit.o
Normal file
BIN
build/cli_apps/exit.o
Normal file
Binary file not shown.
BIN
build/cli_apps/fs_commands.o
Normal file
BIN
build/cli_apps/fs_commands.o
Normal file
Binary file not shown.
BIN
build/cli_apps/help.o
Normal file
BIN
build/cli_apps/help.o
Normal file
Binary file not shown.
BIN
build/cli_apps/license.o
Normal file
BIN
build/cli_apps/license.o
Normal file
Binary file not shown.
BIN
build/cli_apps/man.o
Normal file
BIN
build/cli_apps/man.o
Normal file
Binary file not shown.
BIN
build/cli_apps/math.o
Normal file
BIN
build/cli_apps/math.o
Normal file
Binary file not shown.
BIN
build/cli_apps/memcmd.o
Normal file
BIN
build/cli_apps/memcmd.o
Normal file
Binary file not shown.
BIN
build/cli_apps/meminfo.o
Normal file
BIN
build/cli_apps/meminfo.o
Normal file
Binary file not shown.
BIN
build/cli_apps/readtheman.o
Normal file
BIN
build/cli_apps/readtheman.o
Normal file
Binary file not shown.
BIN
build/cli_apps/reboot.o
Normal file
BIN
build/cli_apps/reboot.o
Normal file
Binary file not shown.
BIN
build/cli_apps/shutdown.o
Normal file
BIN
build/cli_apps/shutdown.o
Normal file
Binary file not shown.
BIN
build/cli_apps/txtedit.o
Normal file
BIN
build/cli_apps/txtedit.o
Normal file
Binary file not shown.
BIN
build/cli_apps/uptime.o
Normal file
BIN
build/cli_apps/uptime.o
Normal file
Binary file not shown.
BIN
build/cmd.o
Normal file
BIN
build/cmd.o
Normal file
Binary file not shown.
BIN
build/control_panel.o
Normal file
BIN
build/control_panel.o
Normal file
Binary file not shown.
BIN
build/editor.o
Normal file
BIN
build/editor.o
Normal file
Binary file not shown.
BIN
build/explorer.o
Normal file
BIN
build/explorer.o
Normal file
Binary file not shown.
BIN
build/fat32.o
Normal file
BIN
build/fat32.o
Normal file
Binary file not shown.
BIN
build/graphics.o
Normal file
BIN
build/graphics.o
Normal file
Binary file not shown.
BIN
build/idt.o
Normal file
BIN
build/idt.o
Normal file
Binary file not shown.
BIN
build/interrupts.o
Normal file
BIN
build/interrupts.o
Normal file
Binary file not shown.
BIN
build/licensewr.o
Normal file
BIN
build/licensewr.o
Normal file
Binary file not shown.
BIN
build/main.o
Normal file
BIN
build/main.o
Normal file
Binary file not shown.
BIN
build/memory_manager.o
Normal file
BIN
build/memory_manager.o
Normal file
Binary file not shown.
BIN
build/minesweeper.o
Normal file
BIN
build/minesweeper.o
Normal file
Binary file not shown.
BIN
build/notepad.o
Normal file
BIN
build/notepad.o
Normal file
Binary file not shown.
BIN
build/ps2.o
Normal file
BIN
build/ps2.o
Normal file
Binary file not shown.
BIN
build/rtc.o
Normal file
BIN
build/rtc.o
Normal file
Binary file not shown.
BIN
build/wm.o
Normal file
BIN
build/wm.o
Normal file
Binary file not shown.
BIN
iso_root/EFI/BOOT/BOOTIA32.EFI
Normal file
BIN
iso_root/EFI/BOOT/BOOTIA32.EFI
Normal file
Binary file not shown.
BIN
iso_root/EFI/BOOT/BOOTX64.EFI
Normal file
BIN
iso_root/EFI/BOOT/BOOTX64.EFI
Normal file
Binary file not shown.
148
iso_root/README.md
Normal file
148
iso_root/README.md
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
# Brew OS 1.01 Alpha
|
||||
|
||||
## Brewkernel is now BrewOS!
|
||||
Brewkernel will from now on be deprecated as it's core became too messy. I have built a less bloated kernel and wrote a DE above it, which is why it is now an OS instead of a kernel (in my opinion).
|
||||
|
||||
|
||||
<img src="asciiart.png" width="200" /> </br>
|
||||
Brew Kernel is a simple x86_64 hobbyist operating system.
|
||||
It features a DE (and WM), a FAT32 filesystem, customizable UI and much much more!
|
||||
|
||||
## Features
|
||||
- Brew WM
|
||||
- Fat 32 FS
|
||||
- 64-bit long mode support
|
||||
- Multiboot2 compliant
|
||||
- Text editor
|
||||
- IDT
|
||||
- Ability to run on actual x86_64 hardware
|
||||
- CLI
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To build BrewOS, you'll need the following tools installed:
|
||||
|
||||
- **x86_64 ELF Toolchain**: `x86_64-elf-gcc`, `x86_64-elf-ld`
|
||||
- **NASM**: Netwide Assembler for compiling assembly code
|
||||
- **xorriso**: For creating bootable ISO images
|
||||
- **QEMU** (optional): For testing the kernel in an emulator
|
||||
|
||||
On macOS, you can install these using Homebrew:
|
||||
```sh
|
||||
brew install x86_64-elf-binutils x86_64-elf-gcc nasm xorriso qemu
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
Simply run `make` from the project root:
|
||||
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Compile all kernel C sources and assembly files
|
||||
2. Link the kernel ELF binary
|
||||
3. Generate a bootable ISO image (`brewos.iso`)
|
||||
|
||||
The build output is organized as follows:
|
||||
- Compiled object files: `build/`
|
||||
- ISO root filesystem: `iso_root/`
|
||||
- Final ISO image: `brewos.iso`
|
||||
|
||||
## Running
|
||||
|
||||
### QEMU Emulation
|
||||
|
||||
Run the kernel in QEMU:
|
||||
|
||||
```sh
|
||||
make run
|
||||
```
|
||||
|
||||
Or manually:
|
||||
```sh
|
||||
qemu-system-x86_64 -m 2G -serial stdio -cdrom brewos.iso -boot d
|
||||
```
|
||||
|
||||
### Running on Real Hardware
|
||||
|
||||
*Warning: This is at YOUR OWN RISK. This software comes with ZERO warranty and may break your system.*
|
||||
|
||||
1. **Create bootable USB**: Use [Balena Etcher](https://www.balena.io/etcher/) to flash `brewos.iso` to a USB drive
|
||||
|
||||
2. **Prepare the system**:
|
||||
- Enable legacy (BIOS) boot in your system BIOS/UEFI settings
|
||||
- Disable Secure Boot if needed
|
||||
|
||||
3. **Boot**: Insert the USB drive and select it in the boot menu during startup
|
||||
|
||||
4. **Tested Hardware**:
|
||||
- HP EliteDesk 705 G4 DM (AMD Ryzen 5 PRO 2400G, Radeon Vega)
|
||||
- Lenovo ThinkPad A475 20KL002VMH (AMD Pro A12-8830B, Radeon R7)
|
||||
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `src/kernel/` - Main kernel implementation
|
||||
- `boot.asm` - Boot assembly code
|
||||
- `main.c` - Kernel entry point
|
||||
- `*.c / *.h` - Core kernel modules (graphics, interrupts, filesystem, etc.)
|
||||
- `cli_apps/` - Command-line applications
|
||||
- `wallpaper.ppm` - Default desktop wallpaper
|
||||
- `build/` - Compiled object files (generated during build)
|
||||
- `iso_root/` - ISO filesystem layout (generated during build)
|
||||
- `limine/` - Limine bootloader files (downloaded automatically)
|
||||
- `linker.ld` - Linker script for x86_64 ELF
|
||||
- `limine.cfg` - Limine bootloader configuration
|
||||
- `Makefile` - Build configuration and targets
|
||||
|
||||
|
||||
|
||||
|
||||
###
|
||||
###
|
||||
|
||||
<h2 align="left">Help me brew some coffee! ☕️</h2>
|
||||
|
||||
###
|
||||
|
||||
<p align="left">
|
||||
If you enjoy this project, and like what i'm doing here, consider buying me a coffee!
|
||||
<br><br>
|
||||
<a href="https://buymeacoffee.com/boreddevnl" target="_blank">
|
||||
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="50" style="border-radius: 8px;" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
###
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Copyright (C) 2024-2026 boreddevnl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
NOTICE
|
||||
------
|
||||
|
||||
This product includes software developed by Chris ("boreddevnl") as part of the BrewKernel project.
|
||||
|
||||
Copyright (C) 2024–2026 Chris / boreddevnl (previously boreddevhq)
|
||||
|
||||
All source files in this repository contain copyright and license
|
||||
headers that must be preserved in redistributions and derivative works.
|
||||
|
||||
If you distribute or modify this project (in whole or in part),
|
||||
you MUST:
|
||||
|
||||
- Retain all copyright and license headers at the top of each file.
|
||||
- Include this NOTICE file along with any redistributions or
|
||||
derivative works.
|
||||
- Provide clear attribution to the original author in documentation
|
||||
or credits where appropriate.
|
||||
|
||||
The above attribution requirements are informational and intended to
|
||||
ensure proper credit is given. They do not alter or supersede the
|
||||
terms of the GNU General Public License (GPL), which governs this work.
|
||||
BIN
iso_root/brewos.elf
Executable file
BIN
iso_root/brewos.elf
Executable file
Binary file not shown.
BIN
iso_root/limine-bios-cd.bin
Normal file
BIN
iso_root/limine-bios-cd.bin
Normal file
Binary file not shown.
BIN
iso_root/limine-bios.sys
Normal file
BIN
iso_root/limine-bios.sys
Normal file
Binary file not shown.
BIN
iso_root/limine-uefi-cd.bin
Normal file
BIN
iso_root/limine-uefi-cd.bin
Normal file
Binary file not shown.
14
iso_root/limine.cfg
Normal file
14
iso_root/limine.cfg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Timeout in seconds that Limine will wait before automatically booting.
|
||||
TIMEOUT=3
|
||||
|
||||
# The entry name that will be displayed in the boot menu.
|
||||
:BrewOS
|
||||
# We use the Limine boot protocol.
|
||||
PROTOCOL=limine
|
||||
|
||||
# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
|
||||
KERNEL_PATH=boot:///brewos.elf
|
||||
|
||||
# Set screen resolution to 1920x1080
|
||||
FRAMEBUFFER_WIDTH=1920
|
||||
FRAMEBUFFER_HEIGHT=1080
|
||||
14
limine.cfg
Normal file
14
limine.cfg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Timeout in seconds that Limine will wait before automatically booting.
|
||||
TIMEOUT=3
|
||||
|
||||
# The entry name that will be displayed in the boot menu.
|
||||
:BrewOS
|
||||
# We use the Limine boot protocol.
|
||||
PROTOCOL=limine
|
||||
|
||||
# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
|
||||
KERNEL_PATH=boot:///brewos.elf
|
||||
|
||||
# Set screen resolution to 1920x1080
|
||||
FRAMEBUFFER_WIDTH=1920
|
||||
FRAMEBUFFER_HEIGHT=1080
|
||||
43
linker.ld
Normal file
43
linker.ld
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* Tell the linker that we want an x86_64 ELF64 output file */
|
||||
OUTPUT_FORMAT(elf64-x86-64)
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
||||
/* We want the symbol _start to be our entry point */
|
||||
ENTRY(_start)
|
||||
|
||||
/* Define the memory layout for the kernel */
|
||||
SECTIONS
|
||||
{
|
||||
/* We want to be loaded in the upper half of memory */
|
||||
. = 0xffffffff80000000;
|
||||
|
||||
.text : {
|
||||
*(.text*)
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
*(.rodata*)
|
||||
}
|
||||
|
||||
.data : {
|
||||
*(.data*)
|
||||
}
|
||||
|
||||
.bss : {
|
||||
*(COMMON)
|
||||
*(.bss*)
|
||||
}
|
||||
|
||||
/* Limine requests section */
|
||||
.requests : {
|
||||
KEEP(*(.requests_start))
|
||||
KEEP(*(.requests))
|
||||
KEEP(*(.requests_end))
|
||||
}
|
||||
|
||||
/* Discard unnecessary sections */
|
||||
/DISCARD/ : {
|
||||
*(.eh_frame)
|
||||
*(.note .note.*)
|
||||
}
|
||||
}
|
||||
65
src/kernel/about.c
Normal file
65
src/kernel/about.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include "about.h"
|
||||
#include "graphics.h"
|
||||
#include "wm.h"
|
||||
#include <stddef.h>
|
||||
|
||||
Window win_about;
|
||||
|
||||
// Color definitions
|
||||
#define COLOR_BLUE_LOGO 0xFF1E8AF5
|
||||
#define COLOR_GREEN_LOGO 0xFF6DD651
|
||||
#define COLOR_YELLOW_LOGO 0xFFF5BE34
|
||||
#define COLOR_RED_LOGO 0xFFF05456
|
||||
#define COLOR_PURPLE_LOGO 0xFFA65DC2
|
||||
#define COLOR_CYAN_LOGO 0xFF368DF7
|
||||
|
||||
static void about_paint(Window *win) {
|
||||
// Background
|
||||
draw_rect(win->x + 4, win->y + 24, win->w - 8, win->h - 28, COLOR_LTGRAY);
|
||||
|
||||
int offset_x = win->x + 15;
|
||||
int offset_y = win->y + 35;
|
||||
|
||||
// Draw brewkernel ASCII logo
|
||||
draw_string(offset_x, offset_y, "( (", COLOR_BLUE_LOGO);
|
||||
|
||||
draw_string(offset_x, offset_y + 15, " ) )", COLOR_GREEN_LOGO);
|
||||
|
||||
draw_string(offset_x, offset_y + 30, " ........", COLOR_YELLOW_LOGO);
|
||||
|
||||
draw_string(offset_x, offset_y + 45, " | |]", COLOR_RED_LOGO);
|
||||
|
||||
draw_string(offset_x, offset_y + 60, " \\ /", COLOR_PURPLE_LOGO);
|
||||
|
||||
draw_string(offset_x, offset_y + 75, " `----'", COLOR_CYAN_LOGO);
|
||||
|
||||
// Version info
|
||||
draw_string(offset_x, offset_y + 105, "BrewOS", COLOR_BLACK);
|
||||
draw_string(offset_x, offset_y + 120, "Version 1.0", COLOR_BLACK);
|
||||
|
||||
// Copyright
|
||||
draw_string(offset_x, offset_y + 150, "(C) 2026 boreddevnl.", COLOR_BLACK);
|
||||
draw_string(offset_x, offset_y + 165, "All rights reserved.", COLOR_BLACK);
|
||||
}
|
||||
|
||||
static void about_click(Window *win, int x, int y) {
|
||||
(void)win;
|
||||
(void)x;
|
||||
(void)y;
|
||||
// No interactive elements needed for About dialog
|
||||
}
|
||||
|
||||
void about_init(void) {
|
||||
win_about.title = "About BrewOS";
|
||||
win_about.x = 250;
|
||||
win_about.y = 180;
|
||||
win_about.w = 185;
|
||||
win_about.h = 240;
|
||||
win_about.visible = false;
|
||||
win_about.focused = false;
|
||||
win_about.z_index = 0;
|
||||
win_about.paint = about_paint;
|
||||
win_about.handle_click = about_click;
|
||||
win_about.handle_right_click = NULL;
|
||||
win_about.handle_key = NULL;
|
||||
}
|
||||
10
src/kernel/about.h
Normal file
10
src/kernel/about.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef ABOUT_H
|
||||
#define ABOUT_H
|
||||
|
||||
#include "wm.h"
|
||||
|
||||
extern Window win_about;
|
||||
|
||||
void about_init(void);
|
||||
|
||||
#endif
|
||||
23
src/kernel/boot.asm
Normal file
23
src/kernel/boot.asm
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
; brew-os/src/kernel/boot.asm
|
||||
; 64-bit Entry Point for BrewOS
|
||||
|
||||
section .text
|
||||
global _start
|
||||
extern kmain
|
||||
|
||||
bits 64
|
||||
|
||||
_start:
|
||||
; Ensure interrupts are disabled
|
||||
cli
|
||||
|
||||
; Setup stack is handled by Limine, but we can re-align if paranoid
|
||||
; (Limine guarantees 16-byte alignment)
|
||||
|
||||
; Call the C kernel entry point
|
||||
call kmain
|
||||
|
||||
; Halt if kmain returns
|
||||
hlt
|
||||
.loop:
|
||||
jmp .loop
|
||||
170
src/kernel/calculator.c
Normal file
170
src/kernel/calculator.c
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
#include "calculator.h"
|
||||
#include "graphics.h"
|
||||
#include "wm.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
Window win_calculator;
|
||||
|
||||
static long long calc_acc = 0;
|
||||
static long long calc_curr = 0;
|
||||
static char calc_op = 0;
|
||||
static bool calc_new_entry = true;
|
||||
static bool calc_error = false;
|
||||
|
||||
// Helper to convert int to string
|
||||
static void int_to_str(long long n, char *buf) {
|
||||
if (n == 0) {
|
||||
buf[0] = '0'; buf[1] = 0; return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
bool neg = n < 0;
|
||||
if (neg) n = -n;
|
||||
|
||||
char temp[32];
|
||||
while (n > 0) {
|
||||
temp[i++] = '0' + (n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
if (neg) temp[i++] = '-';
|
||||
|
||||
int j = 0;
|
||||
while (i > 0) {
|
||||
buf[j++] = temp[--i];
|
||||
}
|
||||
buf[j] = 0;
|
||||
}
|
||||
|
||||
static void update_display(Window *win) {
|
||||
if (calc_error) {
|
||||
char *err = "Error";
|
||||
int i = 0; while(err[i]) { win->buffer[i] = err[i]; i++; }
|
||||
win->buffer[i] = 0;
|
||||
} else {
|
||||
int_to_str(calc_curr, win->buffer);
|
||||
}
|
||||
win->buf_len = 0; while(win->buffer[win->buf_len]) win->buf_len++;
|
||||
}
|
||||
|
||||
static void calculator_paint(Window *win) {
|
||||
// Background
|
||||
draw_rect(win->x + 4, win->y + 24, win->w - 8, win->h - 28, COLOR_LTGRAY);
|
||||
|
||||
// Display Area
|
||||
draw_bevel_rect(win->x + 10, win->y + 30, win->w - 20, 25, true);
|
||||
// Right align text
|
||||
int text_w = win->buf_len * 8;
|
||||
int text_x = win->x + win->w - 15 - text_w;
|
||||
draw_string(text_x, win->y + 38, win->buffer, COLOR_BLACK);
|
||||
|
||||
// Buttons
|
||||
const char *labels[] = {
|
||||
"7", "8", "9", "/",
|
||||
"4", "5", "6", "*",
|
||||
"1", "2", "3", "-",
|
||||
"0", "C", "=", "+"
|
||||
};
|
||||
|
||||
int bw = 30;
|
||||
int bh = 25;
|
||||
int gap = 5;
|
||||
int start_x = win->x + 10;
|
||||
int start_y = win->y + 65;
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int r = i / 4;
|
||||
int c = i % 4;
|
||||
draw_button(start_x + c*(bw+gap), start_y + r*(bh+gap), bw, bh, labels[i], false);
|
||||
}
|
||||
}
|
||||
|
||||
static void do_op(void) {
|
||||
if (calc_op == '+') calc_acc += calc_curr;
|
||||
else if (calc_op == '-') calc_acc -= calc_curr;
|
||||
else if (calc_op == '*') calc_acc *= calc_curr;
|
||||
else if (calc_op == '/') {
|
||||
if (calc_curr == 0) calc_error = true;
|
||||
else calc_acc /= calc_curr;
|
||||
} else {
|
||||
calc_acc = calc_curr;
|
||||
}
|
||||
}
|
||||
|
||||
static void calculator_click(Window *win, int x, int y) {
|
||||
int bw = 30;
|
||||
int bh = 25;
|
||||
int gap = 5;
|
||||
int start_x = 10;
|
||||
int start_y = 65;
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int r = i / 4;
|
||||
int c = i % 4;
|
||||
int bx = start_x + c*(bw+gap);
|
||||
int by = start_y + r*(bh+gap);
|
||||
|
||||
if (x >= bx && x < bx + bw && y >= by && y < by + bh) {
|
||||
// Clicked button i
|
||||
const char *labels[] = {
|
||||
"7", "8", "9", "/",
|
||||
"4", "5", "6", "*",
|
||||
"1", "2", "3", "-",
|
||||
"0", "C", "=", "+"
|
||||
};
|
||||
char lbl = labels[i][0];
|
||||
|
||||
if (lbl >= '0' && lbl <= '9') {
|
||||
if (calc_new_entry || calc_curr == 0) {
|
||||
calc_curr = lbl - '0';
|
||||
calc_new_entry = false;
|
||||
} else {
|
||||
calc_curr = calc_curr * 10 + (lbl - '0');
|
||||
}
|
||||
calc_error = false;
|
||||
} else if (lbl == 'C') {
|
||||
calc_curr = 0;
|
||||
calc_acc = 0;
|
||||
calc_op = 0;
|
||||
calc_new_entry = true;
|
||||
calc_error = false;
|
||||
} else if (lbl == '=') {
|
||||
do_op();
|
||||
calc_curr = calc_acc;
|
||||
calc_op = 0;
|
||||
calc_new_entry = true;
|
||||
} else {
|
||||
if (!calc_new_entry) {
|
||||
if (calc_op) do_op();
|
||||
else calc_acc = calc_curr;
|
||||
}
|
||||
calc_op = lbl;
|
||||
calc_new_entry = true;
|
||||
}
|
||||
|
||||
update_display(win);
|
||||
wm_paint(); // Request repaint
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void calculator_init(void) {
|
||||
win_calculator.title = "Calculator";
|
||||
win_calculator.x = 200;
|
||||
win_calculator.y = 200;
|
||||
win_calculator.w = 160;
|
||||
win_calculator.h = 200;
|
||||
win_calculator.visible = false;
|
||||
win_calculator.focused = false;
|
||||
win_calculator.z_index = 0;
|
||||
win_calculator.paint = calculator_paint;
|
||||
win_calculator.handle_click = calculator_click;
|
||||
win_calculator.handle_right_click = NULL;
|
||||
|
||||
calc_curr = 0;
|
||||
calc_acc = 0;
|
||||
calc_op = 0;
|
||||
calc_new_entry = true;
|
||||
update_display(&win_calculator);
|
||||
}
|
||||
10
src/kernel/calculator.h
Normal file
10
src/kernel/calculator.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef CALCULATOR_H
|
||||
#define CALCULATOR_H
|
||||
|
||||
#include "wm.h"
|
||||
|
||||
extern Window win_calculator;
|
||||
|
||||
void calculator_init(void);
|
||||
|
||||
#endif
|
||||
6
src/kernel/cli_apps/about.c
Normal file
6
src/kernel/cli_apps/about.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
void cli_cmd_about(char *args) {
|
||||
(void)args;
|
||||
cli_write("BrewOS Desktop v0.01 Alpha\n");
|
||||
}
|
||||
16
src/kernel/cli_apps/beep.c
Normal file
16
src/kernel/cli_apps/beep.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "cli_utils.h"
|
||||
#include "io.h"
|
||||
|
||||
void cli_cmd_beep(char *args) {
|
||||
(void)args;
|
||||
cli_write("BEEP!\n");
|
||||
outb(0x43, 0xB6);
|
||||
int freq = 1000;
|
||||
int div = 1193180 / freq;
|
||||
outb(0x42, div & 0xFF);
|
||||
outb(0x42, (div >> 8) & 0xFF);
|
||||
|
||||
outb(0x61, inb(0x61) | 0x03);
|
||||
cli_delay(10000000);
|
||||
outb(0x61, inb(0x61) & 0xFC);
|
||||
}
|
||||
8
src/kernel/cli_apps/blind.c
Normal file
8
src/kernel/cli_apps/blind.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
void cli_cmd_blind(char *args) {
|
||||
(void)args;
|
||||
cli_write("Woah.. is this heaven?\n");
|
||||
cli_write("no.\n");
|
||||
cli_write("This isn't TempleOS you fucking retard.\n");
|
||||
}
|
||||
9
src/kernel/cli_apps/clear.c
Normal file
9
src/kernel/cli_apps/clear.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Public declaration from cmd.c
|
||||
extern void cmd_screen_clear(void);
|
||||
|
||||
void cli_cmd_clear(char *args) {
|
||||
(void)args;
|
||||
cmd_screen_clear();
|
||||
}
|
||||
39
src/kernel/cli_apps/cli_apps.h
Normal file
39
src/kernel/cli_apps/cli_apps.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef CLI_APPS_H
|
||||
#define CLI_APPS_H
|
||||
|
||||
// All CLI command function declarations
|
||||
void cli_cmd_help(char *args);
|
||||
void cli_cmd_date(char *args);
|
||||
void cli_cmd_math(char *args);
|
||||
void cli_cmd_beep(char *args);
|
||||
void cli_cmd_cowsay(char *args);
|
||||
void cli_cmd_reboot(char *args);
|
||||
void cli_cmd_shutdown(char *args);
|
||||
void cli_cmd_uptime(char *args);
|
||||
void cli_cmd_man(char *args);
|
||||
void cli_cmd_license(char *args);
|
||||
void cli_cmd_txtedit(char *args);
|
||||
void cli_cmd_blind(char *args);
|
||||
void cli_cmd_readtheman(char *args);
|
||||
void cli_cmd_about(char *args);
|
||||
void cli_cmd_clear(char *args);
|
||||
void cli_cmd_exit(char *args);
|
||||
|
||||
// Filesystem commands
|
||||
void cli_cmd_cd(char *args);
|
||||
void cli_cmd_pwd(char *args);
|
||||
void cli_cmd_ls(char *args);
|
||||
void cli_cmd_mkdir(char *args);
|
||||
void cli_cmd_rm(char *args);
|
||||
void cli_cmd_echo(char *args);
|
||||
void cli_cmd_cat(char *args);
|
||||
|
||||
// Memory management commands
|
||||
void cli_cmd_meminfo(char *args);
|
||||
void cli_cmd_malloc(char *args);
|
||||
void cli_cmd_free_mem(char *args);
|
||||
void cli_cmd_memblock(char *args);
|
||||
void cli_cmd_memvalid(char *args);
|
||||
void cli_cmd_memtest(char *args);
|
||||
|
||||
#endif
|
||||
22
src/kernel/cli_apps/cli_command.h
Normal file
22
src/kernel/cli_apps/cli_command.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CLI_COMMAND_H
|
||||
#define CLI_COMMAND_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// Standard interface for CLI command output
|
||||
// Commands should call these functions to write to the terminal
|
||||
extern void cli_write(const char *str);
|
||||
extern void cli_write_int(int n);
|
||||
extern void cli_putchar(char c);
|
||||
|
||||
// Callback function type for command execution
|
||||
typedef void (*cmd_callback_t)(char *args);
|
||||
|
||||
// Command entry in dispatch table
|
||||
typedef struct {
|
||||
const char *name;
|
||||
cmd_callback_t callback;
|
||||
const char *help_text;
|
||||
} CLI_Command;
|
||||
|
||||
#endif
|
||||
80
src/kernel/cli_apps/cli_utils.c
Normal file
80
src/kernel/cli_apps/cli_utils.c
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Forward declarations - these will be provided by cmd.c
|
||||
extern void cmd_putchar(char c);
|
||||
extern void cmd_write(const char *str);
|
||||
extern void cmd_write_int(int n);
|
||||
|
||||
void cli_memset(void *dest, int val, size_t len) {
|
||||
unsigned char *ptr = dest;
|
||||
while (len-- > 0) *ptr++ = val;
|
||||
}
|
||||
|
||||
size_t cli_strlen(const char *str) {
|
||||
size_t len = 0;
|
||||
while (str[len]) len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
int cli_strcmp(const char *s1, const char *s2) {
|
||||
while (*s1 && (*s1 == *s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
|
||||
}
|
||||
|
||||
void cli_strcpy(char *dest, const char *src) {
|
||||
while (*src) *dest++ = *src++;
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
int cli_atoi(const char *str) {
|
||||
int res = 0;
|
||||
int sign = 1;
|
||||
if (*str == '-') { sign = -1; str++; }
|
||||
while (*str >= '0' && *str <= '9') {
|
||||
res = res * 10 + (*str - '0');
|
||||
str++;
|
||||
}
|
||||
return res * sign;
|
||||
}
|
||||
|
||||
void cli_itoa(int n, char *buf) {
|
||||
if (n == 0) {
|
||||
buf[0] = '0'; buf[1] = 0; return;
|
||||
}
|
||||
int i = 0;
|
||||
int sign = n < 0;
|
||||
if (sign) n = -n;
|
||||
while (n > 0) {
|
||||
buf[i++] = (n % 10) + '0';
|
||||
n /= 10;
|
||||
}
|
||||
if (sign) buf[i++] = '-';
|
||||
buf[i] = 0;
|
||||
// Reverse
|
||||
for (int j = 0; j < i / 2; j++) {
|
||||
char t = buf[j];
|
||||
buf[j] = buf[i - 1 - j];
|
||||
buf[i - 1 - j] = t;
|
||||
}
|
||||
}
|
||||
|
||||
void cli_write(const char *str) {
|
||||
cmd_write(str);
|
||||
}
|
||||
|
||||
void cli_write_int(int n) {
|
||||
cmd_write_int(n);
|
||||
}
|
||||
|
||||
void cli_putchar(char c) {
|
||||
cmd_putchar(c);
|
||||
}
|
||||
|
||||
void cli_delay(int iterations) {
|
||||
for (volatile int i = 0; i < iterations; i++) {
|
||||
__asm__ __volatile__("nop");
|
||||
}
|
||||
}
|
||||
27
src/kernel/cli_apps/cli_utils.h
Normal file
27
src/kernel/cli_apps/cli_utils.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef CLI_UTILS_H
|
||||
#define CLI_UTILS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// String utilities
|
||||
void cli_memset(void *dest, int val, size_t len);
|
||||
size_t cli_strlen(const char *str);
|
||||
int cli_strcmp(const char *s1, const char *s2);
|
||||
void cli_strcpy(char *dest, const char *src);
|
||||
int cli_atoi(const char *str);
|
||||
void cli_itoa(int n, char *buf);
|
||||
|
||||
// IO utilities
|
||||
void cli_write(const char *str);
|
||||
void cli_write_int(int n);
|
||||
void cli_putchar(char c);
|
||||
|
||||
// Timing utility
|
||||
void cli_delay(int iterations);
|
||||
|
||||
// CLI Command declarations
|
||||
void cli_cmd_shutdown(char *args);
|
||||
void cli_cmd_reboot(char *args);
|
||||
|
||||
#endif
|
||||
17
src/kernel/cli_apps/cowsay.c
Normal file
17
src/kernel/cli_apps/cowsay.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
void cli_cmd_cowsay(char *args) {
|
||||
if (!args || !*args) args = (char*)"Brew!";
|
||||
size_t len = cli_strlen(args);
|
||||
|
||||
cli_write(" ");
|
||||
for(size_t i=0; i<len+2; i++) cli_write("_");
|
||||
cli_write("\n< "); cli_write(args); cli_write(" >\n ");
|
||||
for(size_t i=0; i<len+2; i++) cli_write("-");
|
||||
cli_write("\n");
|
||||
cli_write(" \\ ^__^\n");
|
||||
cli_write(" \\ (oo)\\_______\n");
|
||||
cli_write(" (__)\\ )\\/\\\n");
|
||||
cli_write(" ||----w |\n");
|
||||
cli_write(" || ||\n\n");
|
||||
}
|
||||
15
src/kernel/cli_apps/date.c
Normal file
15
src/kernel/cli_apps/date.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Forward declaration from cmd.c
|
||||
extern void rtc_get_datetime(int *y, int *m, int *d, int *h, int *min, int *s);
|
||||
|
||||
void cli_cmd_date(char *args) {
|
||||
(void)args;
|
||||
int y, m, d, h, min, s;
|
||||
rtc_get_datetime(&y, &m, &d, &h, &min, &s);
|
||||
cli_write("Current Date: ");
|
||||
cli_write_int(y); cli_write("-"); cli_write_int(m); cli_write("-"); cli_write_int(d);
|
||||
cli_write(" ");
|
||||
cli_write_int(h); cli_write(":"); cli_write_int(min); cli_write(":"); cli_write_int(s);
|
||||
cli_write("\n");
|
||||
}
|
||||
9
src/kernel/cli_apps/exit.c
Normal file
9
src/kernel/cli_apps/exit.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Public declaration from cmd.c
|
||||
extern void cmd_window_exit(void);
|
||||
|
||||
void cli_cmd_exit(char *args) {
|
||||
(void)args;
|
||||
cmd_window_exit();
|
||||
}
|
||||
241
src/kernel/cli_apps/fs_commands.c
Normal file
241
src/kernel/cli_apps/fs_commands.c
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
#include "cli_utils.h"
|
||||
#include "fat32.h"
|
||||
|
||||
void cli_cmd_cd(char *args) {
|
||||
if (!args || args[0] == 0) {
|
||||
// No argument - show current directory
|
||||
char cwd[256];
|
||||
fat32_get_current_dir(cwd, sizeof(cwd));
|
||||
cli_write("Current directory: ");
|
||||
cli_write(cwd);
|
||||
cli_write("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse argument
|
||||
char path[256];
|
||||
int i = 0;
|
||||
while (args[i] && args[i] != ' ' && args[i] != '\t') {
|
||||
path[i] = args[i];
|
||||
i++;
|
||||
}
|
||||
path[i] = 0;
|
||||
|
||||
if (fat32_chdir(path)) {
|
||||
char cwd[256];
|
||||
fat32_get_current_dir(cwd, sizeof(cwd));
|
||||
cli_write("Changed to: ");
|
||||
cli_write(cwd);
|
||||
cli_write("\n");
|
||||
} else {
|
||||
cli_write("Error: Cannot change to directory: ");
|
||||
cli_write(path);
|
||||
cli_write("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void cli_cmd_pwd(char *args) {
|
||||
(void)args;
|
||||
char cwd[256];
|
||||
fat32_get_current_dir(cwd, sizeof(cwd));
|
||||
cli_write(cwd);
|
||||
cli_write("\n");
|
||||
}
|
||||
|
||||
void cli_cmd_ls(char *args) {
|
||||
char path[256];
|
||||
|
||||
if (!args || args[0] == 0) {
|
||||
// List current directory
|
||||
fat32_get_current_dir(path, sizeof(path));
|
||||
} else {
|
||||
// Parse argument
|
||||
int i = 0;
|
||||
while (args[i] && args[i] != ' ' && args[i] != '\t') {
|
||||
path[i] = args[i];
|
||||
i++;
|
||||
}
|
||||
path[i] = 0;
|
||||
}
|
||||
|
||||
FAT32_FileInfo entries[256];
|
||||
int count = fat32_list_directory(path, entries, 256);
|
||||
|
||||
if (count < 0) {
|
||||
cli_write("Error: Cannot list directory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
cli_write(entries[i].name);
|
||||
if (entries[i].is_directory) {
|
||||
cli_write("/");
|
||||
}
|
||||
cli_write(" (");
|
||||
cli_write_int(entries[i].size);
|
||||
cli_write(" bytes)\n");
|
||||
}
|
||||
|
||||
cli_write("\n");
|
||||
cli_write("Total: ");
|
||||
cli_write_int(count);
|
||||
cli_write(" items\n");
|
||||
}
|
||||
|
||||
void cli_cmd_mkdir(char *args) {
|
||||
if (!args || args[0] == 0) {
|
||||
cli_write("Usage: mkdir <dirname>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char dirname[256];
|
||||
int i = 0;
|
||||
while (args[i] && args[i] != ' ' && args[i] != '\t') {
|
||||
dirname[i] = args[i];
|
||||
i++;
|
||||
}
|
||||
dirname[i] = 0;
|
||||
|
||||
if (fat32_mkdir(dirname)) {
|
||||
cli_write("Created directory: ");
|
||||
cli_write(dirname);
|
||||
cli_write("\n");
|
||||
} else {
|
||||
cli_write("Error: Cannot create directory\n");
|
||||
}
|
||||
}
|
||||
|
||||
void cli_cmd_rm(char *args) {
|
||||
if (!args || args[0] == 0) {
|
||||
cli_write("Usage: rm <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char filename[256];
|
||||
int i = 0;
|
||||
while (args[i] && args[i] != ' ' && args[i] != '\t') {
|
||||
filename[i] = args[i];
|
||||
i++;
|
||||
}
|
||||
filename[i] = 0;
|
||||
|
||||
if (fat32_delete(filename)) {
|
||||
cli_write("Deleted: ");
|
||||
cli_write(filename);
|
||||
cli_write("\n");
|
||||
} else {
|
||||
cli_write("Error: Cannot delete file\n");
|
||||
}
|
||||
}
|
||||
|
||||
void cli_cmd_echo(char *args) {
|
||||
if (!args || args[0] == 0) {
|
||||
cli_write("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for redirection operators
|
||||
char *redirect_ptr = NULL;
|
||||
char redirect_mode = 0; // '>' for write, 'a' for append
|
||||
char output_file[256] = {0};
|
||||
char echo_text[512] = {0};
|
||||
|
||||
// Find > or >>
|
||||
for (int i = 0; args[i]; i++) {
|
||||
if (args[i] == '>' && args[i+1] == '>') {
|
||||
redirect_ptr = args + i + 2;
|
||||
redirect_mode = 'a'; // append
|
||||
// Copy text before redirection
|
||||
for (int j = 0; j < i; j++) {
|
||||
echo_text[j] = args[j];
|
||||
}
|
||||
echo_text[i] = 0;
|
||||
break;
|
||||
} else if (args[i] == '>') {
|
||||
redirect_ptr = args + i + 1;
|
||||
redirect_mode = '>'; // write
|
||||
// Copy text before redirection
|
||||
for (int j = 0; j < i; j++) {
|
||||
echo_text[j] = args[j];
|
||||
}
|
||||
echo_text[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no redirection, just print the text
|
||||
if (!redirect_ptr) {
|
||||
cli_write(args);
|
||||
cli_write("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse output filename
|
||||
int i = 0;
|
||||
while (redirect_ptr[i] && (redirect_ptr[i] == ' ' || redirect_ptr[i] == '\t')) {
|
||||
i++;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
while (redirect_ptr[i] && redirect_ptr[i] != ' ' && redirect_ptr[i] != '\t') {
|
||||
output_file[j++] = redirect_ptr[i++];
|
||||
}
|
||||
output_file[j] = 0;
|
||||
|
||||
if (!output_file[0]) {
|
||||
cli_write("Error: No output file specified\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Open file
|
||||
const char *mode = (redirect_mode == 'a') ? "a" : "w";
|
||||
FAT32_FileHandle *fh = fat32_open(output_file, mode);
|
||||
if (!fh) {
|
||||
cli_write("Error: Cannot open file for writing\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Write text
|
||||
int text_len = 0;
|
||||
while (echo_text[text_len]) text_len++;
|
||||
|
||||
fat32_write(fh, echo_text, text_len);
|
||||
fat32_write(fh, "\n", 1);
|
||||
fat32_close(fh);
|
||||
|
||||
cli_write("Wrote to: ");
|
||||
cli_write(output_file);
|
||||
cli_write("\n");
|
||||
}
|
||||
|
||||
void cli_cmd_cat(char *args) {
|
||||
if (!args || args[0] == 0) {
|
||||
cli_write("Usage: cat <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
char filename[256];
|
||||
int i = 0;
|
||||
while (args[i] && args[i] != ' ' && args[i] != '\t') {
|
||||
filename[i] = args[i];
|
||||
i++;
|
||||
}
|
||||
filename[i] = 0;
|
||||
|
||||
FAT32_FileHandle *fh = fat32_open(filename, "r");
|
||||
if (!fh) {
|
||||
cli_write("Error: Cannot open file\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Read and display file
|
||||
char buffer[4096];
|
||||
int bytes_read;
|
||||
while ((bytes_read = fat32_read(fh, buffer, sizeof(buffer))) > 0) {
|
||||
for (int j = 0; j < bytes_read; j++) {
|
||||
cli_putchar(buffer[j]);
|
||||
}
|
||||
}
|
||||
|
||||
fat32_close(fh);
|
||||
}
|
||||
18
src/kernel/cli_apps/help.c
Normal file
18
src/kernel/cli_apps/help.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
void cli_cmd_help(char *args) {
|
||||
(void)args;
|
||||
cli_write("Available commands:\n");
|
||||
cli_write(" HELP - Display this help message\n");
|
||||
cli_write(" DATE - Display current date and time\n");
|
||||
cli_write(" CLEAR - Clear the screen\n");
|
||||
cli_write(" ABOUT - System info\n");
|
||||
cli_write(" MATH - math <op> <a> <b> (e.g. math + 1 2)\n");
|
||||
cli_write(" MAN - Show user manual (interactive)\n");
|
||||
cli_write(" LICENSE - Show license (interactive)\n");
|
||||
cli_write(" UPTIME - System uptime\n");
|
||||
cli_write(" BEEP - Make a sound\n");
|
||||
cli_write(" COWSAY - cowsay <msg>\n");
|
||||
cli_write(" REBOOT - Reboot system\n");
|
||||
cli_write(" SHUTDOWN- Shutdown system\n");
|
||||
}
|
||||
21
src/kernel/cli_apps/license.c
Normal file
21
src/kernel/cli_apps/license.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Forward declaration from cmd.c
|
||||
extern void pager_wrap_content(const char **lines, int count);
|
||||
extern void pager_set_mode(void);
|
||||
|
||||
const char* license_pages[] = {
|
||||
" GNU GENERAL PUBLIC LICENSE",
|
||||
" Version 3, 29 June 2007",
|
||||
" Copyright (C) 2024-2026 boreddevnl",
|
||||
"",
|
||||
" (License text abbreviated for build size. See https://www.gnu.org/licenses/gpl-3.0.txt)",
|
||||
"--- End of License ---"
|
||||
};
|
||||
const int license_num_lines = sizeof(license_pages) / sizeof(char*);
|
||||
|
||||
void cli_cmd_license(char *args) {
|
||||
(void)args;
|
||||
pager_wrap_content(license_pages, license_num_lines);
|
||||
pager_set_mode();
|
||||
}
|
||||
46
src/kernel/cli_apps/man.c
Normal file
46
src/kernel/cli_apps/man.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Forward declaration from cmd.c
|
||||
extern void pager_wrap_content(const char **lines, int count);
|
||||
extern void pager_set_mode(void);
|
||||
|
||||
const char* manual_pages[] = {
|
||||
"BrewKernel User Manual",
|
||||
"----------------------",
|
||||
"",
|
||||
"Welcome to the BrewKernel.",
|
||||
"",
|
||||
"== Features ==",
|
||||
"* Ramdisk-based Filesystem: A simple in-memory filesystem.",
|
||||
"* VGA Text Mode Driver: Full control over text/colors.",
|
||||
"* PS/2 Keyboard Driver: Handles key presses.",
|
||||
"* Simple CLI: A basic shell.",
|
||||
"",
|
||||
"== Available Commands ==",
|
||||
"HELP: Displays a short list of available commands.",
|
||||
"MAN: Shows this detailed user manual.",
|
||||
"ABOUT: Displays information about the kernel.",
|
||||
"MATH: A simple calculator.",
|
||||
"DATE: Displays the current date and time.",
|
||||
"TXTEDIT: A simple text editor with file path support.",
|
||||
" USAGE: txtedit <filename>",
|
||||
" EXAMPLES:",
|
||||
" txtedit file.txt (relative path in current directory)",
|
||||
" txtedit /file.txt (absolute path in root)",
|
||||
" txtedit /docs/note.txt (absolute path with subdirectories)",
|
||||
" FEATURES: Create/Edit files, Save (to RAM), Navigation.",
|
||||
"CLEAR: Clears the entire screen.",
|
||||
"EXIT: Exits the CLI mode.",
|
||||
"LICENSE: Displays the full GNU GPL v3.",
|
||||
"COWSAY: Moo!",
|
||||
"UPTIME: Shows how long the system has been running.",
|
||||
"BEEP: Makes a beep sound.",
|
||||
"--- End of Manual ---"
|
||||
};
|
||||
const int manual_num_lines = sizeof(manual_pages) / sizeof(char*);
|
||||
|
||||
void cli_cmd_man(char *args) {
|
||||
(void)args;
|
||||
pager_wrap_content(manual_pages, manual_num_lines);
|
||||
pager_set_mode();
|
||||
}
|
||||
34
src/kernel/cli_apps/math.c
Normal file
34
src/kernel/cli_apps/math.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
void cli_cmd_math(char *args) {
|
||||
while (*args == ' ') args++;
|
||||
if (!*args) {
|
||||
cli_write("Usage: math <op> <n1> <n2>\n");
|
||||
return;
|
||||
}
|
||||
char op = *args;
|
||||
args++;
|
||||
while (*args == ' ') args++;
|
||||
|
||||
char *end = args;
|
||||
while (*end && *end != ' ') end++;
|
||||
int saved = *end;
|
||||
*end = 0;
|
||||
int n1 = cli_atoi(args);
|
||||
if (saved) *end = saved;
|
||||
|
||||
args = end;
|
||||
while (*args == ' ') args++;
|
||||
|
||||
int n2 = cli_atoi(args);
|
||||
|
||||
int res = 0;
|
||||
switch(op) {
|
||||
case '+': res = n1 + n2; break;
|
||||
case '-': res = n1 - n2; break;
|
||||
case '*': res = n1 * n2; break;
|
||||
case '/': if(n2!=0) res = n1/n2; else { cli_write("Div by zero\n"); return; } break;
|
||||
default: cli_write("Invalid op.\n"); return;
|
||||
}
|
||||
cli_write("Result: "); cli_write_int(res); cli_write("\n");
|
||||
}
|
||||
143
src/kernel/cli_apps/memcmd.c
Normal file
143
src/kernel/cli_apps/memcmd.c
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
#include "cli_utils.h"
|
||||
#include "../memory_manager.h"
|
||||
|
||||
#define MAX_TEST_ALLOCS 64
|
||||
static void *test_allocs[MAX_TEST_ALLOCS];
|
||||
static int test_alloc_count = 0;
|
||||
|
||||
void cli_cmd_malloc(char *args) {
|
||||
if (!args || !args[0]) {
|
||||
cli_write("Usage: malloc <size_in_kb>\n");
|
||||
cli_write("Example: malloc 10\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse size in KB
|
||||
int size_kb = cli_atoi(args);
|
||||
if (size_kb <= 0 || size_kb > 1024) {
|
||||
cli_write("Invalid size. Use 1-1024 KB\n");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t size = size_kb * 1024;
|
||||
void *ptr = kmalloc(size);
|
||||
|
||||
if (ptr == NULL) {
|
||||
cli_write("Allocation failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Track allocation for later freeing
|
||||
if (test_alloc_count < MAX_TEST_ALLOCS) {
|
||||
test_allocs[test_alloc_count++] = ptr;
|
||||
}
|
||||
|
||||
cli_write("Allocated ");
|
||||
cli_write_int(size_kb);
|
||||
cli_write("KB at address 0x");
|
||||
cli_write_int((uintptr_t)ptr / 1024);
|
||||
cli_write("\n");
|
||||
cli_write("Test allocation index: ");
|
||||
cli_write_int(test_alloc_count - 1);
|
||||
cli_write("\n");
|
||||
|
||||
memory_print_stats();
|
||||
}
|
||||
|
||||
void cli_cmd_free_mem(char *args) {
|
||||
if (!args || !args[0]) {
|
||||
cli_write("Usage: freemem <index>\n");
|
||||
cli_write("Specify the allocation index from malloc output\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = cli_atoi(args);
|
||||
if (idx < 0 || idx >= test_alloc_count) {
|
||||
cli_write("Invalid index. Must be 0-");
|
||||
cli_write_int(test_alloc_count - 1);
|
||||
cli_write("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
void *ptr = test_allocs[idx];
|
||||
if (ptr == NULL) {
|
||||
cli_write("Allocation at index ");
|
||||
cli_write_int(idx);
|
||||
cli_write(" is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
kfree(ptr);
|
||||
test_allocs[idx] = NULL;
|
||||
|
||||
cli_write("Freed allocation at index ");
|
||||
cli_write_int(idx);
|
||||
cli_write("\n");
|
||||
|
||||
memory_print_stats();
|
||||
}
|
||||
|
||||
void cli_cmd_memblock(char *args) {
|
||||
(void)args;
|
||||
|
||||
cli_write("Detailed block information:\n");
|
||||
memory_print_detailed();
|
||||
}
|
||||
|
||||
void cli_cmd_memvalid(char *args) {
|
||||
(void)args;
|
||||
|
||||
cli_write("Validating memory integrity...\n");
|
||||
memory_validate();
|
||||
}
|
||||
|
||||
void cli_cmd_memtest(char *args) {
|
||||
(void)args;
|
||||
|
||||
cli_write("\n=== MEMORY STRESS TEST ===\n");
|
||||
|
||||
// Allocate multiple blocks
|
||||
cli_write("Allocating 10 blocks of 256KB each...\n");
|
||||
void *test_ptrs[10];
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
test_ptrs[i] = kmalloc(256 * 1024);
|
||||
if (test_ptrs[i] == NULL) {
|
||||
cli_write("Allocation ");
|
||||
cli_write_int(i);
|
||||
cli_write(" failed\n");
|
||||
|
||||
// Free previous allocations
|
||||
for (int j = 0; j < i; j++) {
|
||||
kfree(test_ptrs[j]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
cli_write("Allocated block ");
|
||||
cli_write_int(i);
|
||||
cli_write("\n");
|
||||
}
|
||||
|
||||
memory_print_stats();
|
||||
|
||||
// Free every other block (create fragmentation)
|
||||
cli_write("\nFreeing alternate blocks to create fragmentation...\n");
|
||||
for (int i = 0; i < 10; i += 2) {
|
||||
kfree(test_ptrs[i]);
|
||||
cli_write("Freed block ");
|
||||
cli_write_int(i);
|
||||
cli_write("\n");
|
||||
}
|
||||
|
||||
memory_print_stats();
|
||||
|
||||
// Free remaining blocks
|
||||
cli_write("\nFreeing remaining blocks...\n");
|
||||
for (int i = 1; i < 10; i += 2) {
|
||||
kfree(test_ptrs[i]);
|
||||
}
|
||||
|
||||
memory_print_stats();
|
||||
|
||||
cli_write("=== TEST COMPLETE ===\n\n");
|
||||
}
|
||||
9
src/kernel/cli_apps/meminfo.c
Normal file
9
src/kernel/cli_apps/meminfo.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "cli_utils.h"
|
||||
#include "../memory_manager.h"
|
||||
|
||||
void cli_cmd_meminfo(char *args) {
|
||||
(void)args;
|
||||
|
||||
// Print memory statistics
|
||||
memory_print_stats();
|
||||
}
|
||||
14
src/kernel/cli_apps/readtheman.c
Normal file
14
src/kernel/cli_apps/readtheman.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Forward declaration from cmd.c
|
||||
extern void cli_cmd_beep(char *args);
|
||||
|
||||
void cli_cmd_readtheman(char *args) {
|
||||
(void)args;
|
||||
cli_write("\nYou read the manual? NERD. you know what?\n");
|
||||
cli_write("Fuck you.\n");
|
||||
for(int i=0; i<3; i++) {
|
||||
cli_cmd_beep(NULL);
|
||||
cli_delay(1000000);
|
||||
}
|
||||
}
|
||||
11
src/kernel/cli_apps/reboot.c
Normal file
11
src/kernel/cli_apps/reboot.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "cli_utils.h"
|
||||
#include "io.h"
|
||||
|
||||
void cli_cmd_reboot(char *args) {
|
||||
(void)args;
|
||||
cli_write("Rebooting...\n");
|
||||
cli_delay(10000000);
|
||||
while ((inb(0x64) & 2) != 0) cli_delay(1000);
|
||||
outb(0x64, 0xFE);
|
||||
asm volatile ("int $0x3");
|
||||
}
|
||||
11
src/kernel/cli_apps/shutdown.c
Normal file
11
src/kernel/cli_apps/shutdown.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "cli_utils.h"
|
||||
#include "io.h"
|
||||
|
||||
void cli_cmd_shutdown(char *args) {
|
||||
(void)args;
|
||||
cli_write("Shutting down...\n");
|
||||
cli_delay(10000000);
|
||||
outb(0x64, 0xFE);
|
||||
outw(0x604, 0x2000);
|
||||
outw(0xB004, 0x2000);
|
||||
}
|
||||
61
src/kernel/cli_apps/txtedit.c
Normal file
61
src/kernel/cli_apps/txtedit.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include "cli_utils.h"
|
||||
#include "fat32.h"
|
||||
#include "wm.h"
|
||||
|
||||
// Forward declarations from editor.h and wm.c
|
||||
extern void editor_open_file(const char *filename);
|
||||
extern void editor_init(void);
|
||||
extern Window win_editor;
|
||||
extern Window win_explorer;
|
||||
extern Window win_cmd;
|
||||
extern Window win_notepad;
|
||||
extern Window win_calculator;
|
||||
|
||||
void cli_cmd_txtedit(char *args) {
|
||||
// Parse the file path argument
|
||||
char filepath[256];
|
||||
int i = 0;
|
||||
|
||||
// Skip leading whitespace
|
||||
while (args && args[i] && (args[i] == ' ' || args[i] == '\t')) {
|
||||
i++;
|
||||
}
|
||||
|
||||
// Extract filepath
|
||||
int j = 0;
|
||||
while (args && args[i] && args[i] != ' ' && args[i] != '\t' && j < 255) {
|
||||
filepath[j++] = args[i++];
|
||||
}
|
||||
filepath[j] = 0;
|
||||
|
||||
// If no filepath provided, create a new empty file
|
||||
if (j == 0) {
|
||||
cli_write("Usage: txtedit <filename>\n");
|
||||
cli_write("Example: txtedit myfile.txt\n");
|
||||
cli_write(" txtedit /document.txt\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalize the path (handles relative and absolute paths)
|
||||
char normalized_path[256];
|
||||
fat32_normalize_path(filepath, normalized_path);
|
||||
|
||||
// Open the file in the GUI editor
|
||||
editor_open_file(normalized_path);
|
||||
|
||||
// Make editor window visible and focused, bring to front
|
||||
win_editor.visible = true;
|
||||
win_editor.focused = true;
|
||||
|
||||
// Calculate max z_index to bring window to front
|
||||
int max_z = 0;
|
||||
if (win_explorer.z_index > max_z) max_z = win_explorer.z_index;
|
||||
if (win_cmd.z_index > max_z) max_z = win_cmd.z_index;
|
||||
if (win_notepad.z_index > max_z) max_z = win_notepad.z_index;
|
||||
if (win_calculator.z_index > max_z) max_z = win_calculator.z_index;
|
||||
win_editor.z_index = max_z + 1;
|
||||
|
||||
cli_write("Opening: ");
|
||||
cli_write(normalized_path);
|
||||
cli_write("\n");
|
||||
}
|
||||
26
src/kernel/cli_apps/uptime.c
Normal file
26
src/kernel/cli_apps/uptime.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "cli_utils.h"
|
||||
|
||||
// Forward declarations from cmd.c
|
||||
extern void rtc_get_datetime(int *y, int *m, int *d, int *h, int *min, int *s);
|
||||
extern int boot_time_init;
|
||||
extern int boot_year, boot_month, boot_day, boot_hour, boot_min, boot_sec;
|
||||
|
||||
void cli_cmd_uptime(char *args) {
|
||||
(void)args;
|
||||
int y, m, d, h, min, s;
|
||||
rtc_get_datetime(&y, &m, &d, &h, &min, &s);
|
||||
|
||||
int start_sec = boot_hour * 3600 + boot_min * 60 + boot_sec;
|
||||
int curr_sec = h * 3600 + min * 60 + s;
|
||||
if (curr_sec < start_sec) curr_sec += 24 * 3600;
|
||||
|
||||
int diff = curr_sec - start_sec;
|
||||
int up_h = diff / 3600;
|
||||
int up_m = (diff % 3600) / 60;
|
||||
int up_s = diff % 60;
|
||||
|
||||
cli_write("Uptime: ");
|
||||
cli_write_int(up_h); cli_write("h ");
|
||||
cli_write_int(up_m); cli_write("m ");
|
||||
cli_write_int(up_s); cli_write("s\n");
|
||||
}
|
||||
81
src/kernel/cli_apps_old/beep.h
Normal file
81
src/kernel/cli_apps_old/beep.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef BEEP_H
|
||||
#define BEEP_H
|
||||
|
||||
#include "../print.h"
|
||||
#include "../io.h"
|
||||
|
||||
// Forward declaration of brewing function from main.c
|
||||
void brewing(int iterations);
|
||||
|
||||
void beep_command() {
|
||||
brew_str("\n");
|
||||
brew_str("BEEP!");
|
||||
// Add a 500ms delay before the beep
|
||||
brewing(5000000);
|
||||
|
||||
// Set the PIT to the desired frequency (1000 Hz for high pitch)
|
||||
outb(0x43, 0xB6); // Command byte: channel 2, mode 3, binary
|
||||
int frequency = 1000;
|
||||
int divisor = 1193180 / frequency;
|
||||
outb(0x42, divisor & 0xFF);
|
||||
outb(0x42, (divisor >> 8) & 0xFF);
|
||||
|
||||
// Turn speaker on
|
||||
outb(0x61, inb(0x61) | 0x03);
|
||||
|
||||
// Keep the sound for 1 second
|
||||
brewing(10000000);
|
||||
|
||||
// Turn speaker off
|
||||
outb(0x61, inb(0x61) & 0xFC);
|
||||
|
||||
brewing(1000000);
|
||||
|
||||
outb(0x61, inb(0x61) | 0x03);
|
||||
|
||||
// Keep the sound for 1 second
|
||||
brewing(50000000);
|
||||
|
||||
// Turn speaker off
|
||||
outb(0x61, inb(0x61) & 0xFC);
|
||||
|
||||
// Turn speaker on
|
||||
outb(0x61, inb(0x61) | 0x03);
|
||||
|
||||
// Keep the sound for 1 second
|
||||
brewing(10000000);
|
||||
|
||||
// Turn speaker off
|
||||
outb(0x61, inb(0x61) & 0xFC);
|
||||
|
||||
brewing(1000000);
|
||||
|
||||
outb(0x61, inb(0x61) | 0x03);
|
||||
|
||||
// Keep the sound for 1 second
|
||||
brewing(50000000);
|
||||
|
||||
// Turn speaker off
|
||||
outb(0x61, inb(0x61) & 0xFC);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
33
src/kernel/cli_apps_old/blind.h
Normal file
33
src/kernel/cli_apps_old/blind.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_BLIND_H
|
||||
#define APPS_BLIND_H
|
||||
|
||||
#include "print.h"
|
||||
|
||||
static void blindme() {
|
||||
print_set_color(PRINT_INDEX_0, PRINT_INDEX_15);
|
||||
print_clear();
|
||||
brew_str("Woah.. is this heaven?\n");
|
||||
brew_str("no.\n");
|
||||
brew_str("This isn't TempleOS you fucking retard.\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // APPS_BLIND_H
|
||||
291
src/kernel/cli_apps_old/calc.h
Normal file
291
src/kernel/cli_apps_old/calc.h
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_CALC_H
|
||||
#define APPS_CALC_H
|
||||
|
||||
#include "print.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
extern int buffer_pos;
|
||||
|
||||
// Calculator state structure
|
||||
struct {
|
||||
char display[64]; // Display buffer for calculation
|
||||
int display_len;
|
||||
long current_val;
|
||||
long prev_val;
|
||||
char operation;
|
||||
int cursor_row; // 0-3 for numpad rows
|
||||
int cursor_col; // 0-3 for numpad cols
|
||||
int has_operation;
|
||||
} calc_state;
|
||||
|
||||
// Redraw the calculator UI
|
||||
static void calc_redraw_ui() {
|
||||
// Clear screen by printing newlines (but fewer to avoid deadspace)
|
||||
for (int i = 0; i < 24; i++) {
|
||||
brew_str("\n");
|
||||
}
|
||||
|
||||
// Display header
|
||||
brew_str("===== CALCULATOR =====\n");
|
||||
brew_str("Display: ");
|
||||
brew_str(calc_state.display);
|
||||
brew_str("\n\n");
|
||||
|
||||
// Draw numpad with cursor
|
||||
const char* buttons[4][4] = {
|
||||
{"7", "8", "9", "/"},
|
||||
{"4", "5", "6", "*"},
|
||||
{"1", "2", "3", "-"},
|
||||
{"0", ".", "=", "+"}
|
||||
};
|
||||
|
||||
for (int row = 0; row < 4; row++) {
|
||||
brew_str(" ");
|
||||
for (int col = 0; col < 4; col++) {
|
||||
if (row == calc_state.cursor_row && col == calc_state.cursor_col) {
|
||||
brew_str("[");
|
||||
brew_str(buttons[row][col]);
|
||||
brew_str("]");
|
||||
} else {
|
||||
brew_str(" ");
|
||||
brew_str(buttons[row][col]);
|
||||
brew_str(" ");
|
||||
}
|
||||
brew_str(" ");
|
||||
}
|
||||
brew_str("\n");
|
||||
}
|
||||
|
||||
brew_str("\nNavigate: Arrow Keys | Select: Enter | Clear: C | Quit: Q/ESC\n");
|
||||
}
|
||||
|
||||
// Get button at current cursor position
|
||||
static const char* calc_get_button() {
|
||||
const char* buttons[4][4] = {
|
||||
{"7", "8", "9", "/"},
|
||||
{"4", "5", "6", "*"},
|
||||
{"1", "2", "3", "-"},
|
||||
{"0", ".", "=", "+"}
|
||||
};
|
||||
return buttons[calc_state.cursor_row][calc_state.cursor_col];
|
||||
}
|
||||
|
||||
// Append character to display
|
||||
static void calc_append_to_display(const char* text) {
|
||||
int i = 0;
|
||||
while (text[i] && calc_state.display_len < 63) {
|
||||
calc_state.display[calc_state.display_len++] = text[i++];
|
||||
}
|
||||
calc_state.display[calc_state.display_len] = '\0';
|
||||
}
|
||||
|
||||
// Parse and calculate result
|
||||
static void calc_perform_calculation() {
|
||||
if (calc_state.display_len == 0) return;
|
||||
|
||||
// Parse the current display value
|
||||
long val = 0;
|
||||
int i = 0;
|
||||
int is_negative = 0;
|
||||
|
||||
if (calc_state.display[0] == '-') {
|
||||
is_negative = 1;
|
||||
i = 1;
|
||||
}
|
||||
|
||||
while (i < calc_state.display_len && calc_state.display[i] != '.') {
|
||||
if (calc_state.display[i] >= '0' && calc_state.display[i] <= '9') {
|
||||
val = val * 10 + (calc_state.display[i] - '0');
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (is_negative) val = -val;
|
||||
|
||||
long result = val;
|
||||
|
||||
if (calc_state.has_operation) {
|
||||
switch (calc_state.operation) {
|
||||
case '+': result = calc_state.prev_val + val; break;
|
||||
case '-': result = calc_state.prev_val - val; break;
|
||||
case '*': result = calc_state.prev_val * val; break;
|
||||
case '/':
|
||||
if (val != 0) result = calc_state.prev_val / val;
|
||||
else {
|
||||
calc_state.display_len = 0;
|
||||
calc_append_to_display("ERROR");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert result back to string
|
||||
calc_state.display_len = 0;
|
||||
if (result < 0) {
|
||||
calc_append_to_display("-");
|
||||
result = -result;
|
||||
}
|
||||
|
||||
if (result == 0) {
|
||||
calc_append_to_display("0");
|
||||
} else {
|
||||
char temp[32];
|
||||
int len = 0;
|
||||
long temp_val = result;
|
||||
while (temp_val > 0) {
|
||||
temp[len++] = '0' + (temp_val % 10);
|
||||
temp_val /= 10;
|
||||
}
|
||||
|
||||
// Reverse and append
|
||||
for (int j = len - 1; j >= 0; j--) {
|
||||
char c[2] = {temp[j], '\0'};
|
||||
calc_append_to_display(c);
|
||||
}
|
||||
}
|
||||
|
||||
calc_state.prev_val = result;
|
||||
}
|
||||
|
||||
// Main calculator command
|
||||
static void calc_cmd() {
|
||||
// Initialize calculator state
|
||||
calc_state.display[0] = '\0';
|
||||
calc_state.display_len = 0;
|
||||
calc_state.current_val = 0;
|
||||
calc_state.prev_val = 0;
|
||||
calc_state.operation = '\0';
|
||||
calc_state.cursor_row = 0;
|
||||
calc_state.cursor_col = 0;
|
||||
calc_state.has_operation = 0;
|
||||
|
||||
calc_redraw_ui();
|
||||
|
||||
buffer_pos = 0;
|
||||
|
||||
while (1) {
|
||||
if (check_keyboard()) {
|
||||
unsigned char scan_code = read_scan_code();
|
||||
|
||||
// Handle arrow keys for navigation
|
||||
if (scan_code == 0x48) { // UP arrow
|
||||
if (calc_state.cursor_row > 0) {
|
||||
calc_state.cursor_row--;
|
||||
calc_redraw_ui();
|
||||
}
|
||||
continue;
|
||||
} else if (scan_code == 0x50) { // DOWN arrow
|
||||
if (calc_state.cursor_row < 3) {
|
||||
calc_state.cursor_row++;
|
||||
calc_redraw_ui();
|
||||
}
|
||||
continue;
|
||||
} else if (scan_code == 0x4B) { // LEFT arrow
|
||||
if (calc_state.cursor_col > 0) {
|
||||
calc_state.cursor_col--;
|
||||
calc_redraw_ui();
|
||||
}
|
||||
continue;
|
||||
} else if (scan_code == 0x4D) { // RIGHT arrow
|
||||
if (calc_state.cursor_col < 3) {
|
||||
calc_state.cursor_col++;
|
||||
calc_redraw_ui();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
char ascii_char = scan_code_to_ascii(scan_code);
|
||||
|
||||
// Handle C key to clear
|
||||
if (ascii_char == 'c' || ascii_char == 'C') {
|
||||
calc_state.display[0] = '\0';
|
||||
calc_state.display_len = 0;
|
||||
calc_state.current_val = 0;
|
||||
calc_state.prev_val = 0;
|
||||
calc_state.operation = '\0';
|
||||
calc_state.has_operation = 0;
|
||||
calc_redraw_ui();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle Q key or ESC to quit
|
||||
if (ascii_char == 'q' || ascii_char == 'Q' || scan_code == 0x01) {
|
||||
brew_str("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle Enter to select button
|
||||
if (ascii_char == '\n' || scan_code == 0x1C) {
|
||||
const char* button = calc_get_button();
|
||||
|
||||
if (button[0] >= '0' && button[0] <= '9') {
|
||||
// Number button
|
||||
calc_append_to_display(button);
|
||||
calc_redraw_ui();
|
||||
} else if (button[0] == '.') {
|
||||
// Decimal point
|
||||
int has_dot = 0;
|
||||
for (int i = 0; i < calc_state.display_len; i++) {
|
||||
if (calc_state.display[i] == '.') {
|
||||
has_dot = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!has_dot && calc_state.display_len > 0) {
|
||||
calc_append_to_display(".");
|
||||
calc_redraw_ui();
|
||||
}
|
||||
} else if (button[0] == '=' || button[0] == '+' ||
|
||||
button[0] == '-' || button[0] == '*' || button[0] == '/') {
|
||||
|
||||
if (button[0] == '=') {
|
||||
if (calc_state.has_operation && calc_state.display_len > 0) {
|
||||
calc_perform_calculation();
|
||||
calc_state.operation = '\0';
|
||||
calc_state.has_operation = 0;
|
||||
calc_redraw_ui();
|
||||
}
|
||||
} else {
|
||||
// Operation button pressed
|
||||
if (calc_state.display_len > 0) {
|
||||
// If we already have an operation pending, calculate first
|
||||
if (calc_state.has_operation) {
|
||||
calc_perform_calculation();
|
||||
} else {
|
||||
// First operation: save display value to prev_val
|
||||
calc_perform_calculation();
|
||||
}
|
||||
// Set new operation
|
||||
calc_state.operation = button[0];
|
||||
calc_state.has_operation = 1;
|
||||
calc_state.display_len = 0;
|
||||
calc_state.display[0] = '\0';
|
||||
calc_redraw_ui();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // APPS_CALC_H
|
||||
109
src/kernel/cli_apps_old/cowsay.h
Normal file
109
src/kernel/cli_apps_old/cowsay.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Brew Kernel Cowsay Utility
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//
|
||||
// Implementation of cowsay from GNU/LINUX for Brew Kernel.
|
||||
// Props to Tony Monroe for the original concept.
|
||||
// One of these days we WONT port it to Windows. :3
|
||||
//
|
||||
#ifndef APPS_COWSAY_H
|
||||
#define APPS_COWSAY_H
|
||||
|
||||
#include "print.h"
|
||||
|
||||
// Function to calculate string length since we don't have string.h
|
||||
static int brew_strlen(const char* str) {
|
||||
int len = 0;
|
||||
while (str[len]) len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
// String comparison for parsing command
|
||||
static int strncmp_kernel(const char* s1, const char* s2, int n) {
|
||||
while (n-- > 0) {
|
||||
if (*s1 != *s2) {
|
||||
return (*s1 - *s2);
|
||||
}
|
||||
if (*s1 == '\0') {
|
||||
return 0;
|
||||
}
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Function to find where the command arguments start
|
||||
static const char* find_args(const char* cmd) {
|
||||
while (*cmd && *cmd != ' ') cmd++;
|
||||
while (*cmd == ' ') cmd++;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
// Function to draw the top border of the speech bubble
|
||||
static void draw_top_border(int width) {
|
||||
brew_str(" ");
|
||||
for (int i = 0; i < width + 2; i++) {
|
||||
brew_str("_");
|
||||
}
|
||||
brew_str("\n");
|
||||
}
|
||||
|
||||
// Function to draw the bottom border of the speech bubble
|
||||
static void draw_bottom_border(int width) {
|
||||
brew_str(" ");
|
||||
for (int i = 0; i < width + 2; i++) {
|
||||
brew_str("-");
|
||||
}
|
||||
brew_str("\n");
|
||||
}
|
||||
|
||||
// Main cowsay function
|
||||
static void cowsay(const char* message) {
|
||||
int len = brew_strlen(message);
|
||||
|
||||
// Draw speech bubble
|
||||
brew_str("\n"); // Start with a newline for better spacing
|
||||
draw_top_border(len);
|
||||
brew_str("< ");
|
||||
brew_str(message);
|
||||
brew_str(" >\n");
|
||||
draw_bottom_border(len);
|
||||
|
||||
// Draw the cow
|
||||
brew_str(" \\ ^__^\n");
|
||||
brew_str(" \\ (oo)\\_______\n");
|
||||
brew_str(" (__)\\ )\\/\\\n");
|
||||
brew_str(" ||----w |\n");
|
||||
brew_str(" || ||\n\n");
|
||||
}
|
||||
|
||||
// Entry point for the cowsay command
|
||||
static void display_cowsay(const char* command) {
|
||||
const char* message;
|
||||
if (!command || brew_strlen(command) == 0) {
|
||||
message = "Brew!";
|
||||
} else {
|
||||
message = find_args(command);
|
||||
if (brew_strlen(message) == 0) {
|
||||
message = "Brew!";
|
||||
}
|
||||
}
|
||||
cowsay(message);
|
||||
}
|
||||
#endif // APPS_COWSAY_H
|
||||
196
src/kernel/cli_apps_old/date.h
Normal file
196
src/kernel/cli_apps_old/date.h
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DATE_H
|
||||
#define DATE_H
|
||||
|
||||
#include "print.h"
|
||||
#include "keyboard.h"
|
||||
#include "rtc.h"
|
||||
#include "timezones.h"
|
||||
|
||||
// String comparison function for kernel
|
||||
static int strcmp_kernel_date(const char *s1, const char *s2) {
|
||||
while (*s1 && (*s1 == *s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
|
||||
}
|
||||
|
||||
// Simple delay function
|
||||
static inline void brewing_date(int iterations) {
|
||||
for (volatile int i = 0; i < iterations; i++) {
|
||||
__asm__ __volatile__("nop");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Timezone Selection ---
|
||||
static void select_timezone_for_continent_date(const char* continent, int* timezone_offset_h, int* timezone_offset_m) {
|
||||
int selected_timezone = 0;
|
||||
int needs_redraw = 1;
|
||||
|
||||
while (1) {
|
||||
if (needs_redraw) {
|
||||
print_clear();
|
||||
brew_str("Select a timezone:\n");
|
||||
int current_timezone = 0;
|
||||
for (int i = 0; i < num_timezones; i++) {
|
||||
if (strcmp_kernel_date(timezones[i].continent, continent) == 0) {
|
||||
if (current_timezone == selected_timezone) {
|
||||
print_set_color(PRINT_INDEX_0, PRINT_INDEX_7);
|
||||
}
|
||||
brew_str(timezones[i].name);
|
||||
brew_str("\n");
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
current_timezone++;
|
||||
}
|
||||
}
|
||||
needs_redraw = 0;
|
||||
}
|
||||
|
||||
while (!check_keyboard()) { /* Do nothing */ }
|
||||
|
||||
unsigned char sc = read_scan_code();
|
||||
if (sc == 0x48) { // Up Arrow
|
||||
if (selected_timezone > 0) {
|
||||
selected_timezone--;
|
||||
needs_redraw = 1;
|
||||
}
|
||||
} else if (sc == 0x50) { // Down Arrow
|
||||
int max_timezone = 0;
|
||||
for (int i = 0; i < num_timezones; i++) {
|
||||
if (strcmp_kernel_date(timezones[i].continent, continent) == 0) {
|
||||
max_timezone++;
|
||||
}
|
||||
}
|
||||
if (selected_timezone < max_timezone - 1) {
|
||||
selected_timezone++;
|
||||
needs_redraw = 1;
|
||||
}
|
||||
} else if (scan_code_to_ascii(sc) == '\n' || scan_code_to_ascii(sc) == '\r') {
|
||||
int current_timezone = 0;
|
||||
for (int i = 0; i < num_timezones; i++) {
|
||||
if (strcmp_kernel_date(timezones[i].continent, continent) == 0) {
|
||||
if (current_timezone == selected_timezone) {
|
||||
*timezone_offset_h = timezones[i].offset_h; // DST
|
||||
*timezone_offset_m = timezones[i].offset_m;
|
||||
return;
|
||||
}
|
||||
current_timezone++;
|
||||
}
|
||||
}
|
||||
}
|
||||
brewing_date(10000000);
|
||||
}
|
||||
}
|
||||
|
||||
static void select_continent_date(int* timezone_offset_h, int* timezone_offset_m) {
|
||||
const char* continents[] = {"North America", "South America", "Europe", "Asia", "Oceania", "Africa"};
|
||||
int num_continents = sizeof(continents) / sizeof(char*);
|
||||
int selected_continent = 0;
|
||||
int needs_redraw = 1;
|
||||
|
||||
while (1) {
|
||||
if (needs_redraw) {
|
||||
print_clear();
|
||||
brew_str("Select a continent:\n");
|
||||
for (int i = 0; i < num_continents; i++) {
|
||||
if (i == selected_continent) {
|
||||
print_set_color(PRINT_INDEX_0, PRINT_INDEX_7);
|
||||
}
|
||||
brew_str(continents[i]);
|
||||
brew_str("\n");
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
}
|
||||
needs_redraw = 0;
|
||||
}
|
||||
|
||||
while (!check_keyboard()) { /* Do nothing */ }
|
||||
|
||||
unsigned char sc = read_scan_code();
|
||||
if (sc == 0x48) { // Up Arrow
|
||||
if (selected_continent > 0) {
|
||||
selected_continent--;
|
||||
needs_redraw = 1;
|
||||
}
|
||||
} else if (sc == 0x50) { // Down Arrow
|
||||
if (selected_continent < num_continents - 1) {
|
||||
selected_continent++;
|
||||
needs_redraw = 1;
|
||||
}
|
||||
} else if (scan_code_to_ascii(sc) == '\n' || scan_code_to_ascii(sc) == '\r') {
|
||||
select_timezone_for_continent_date(continents[selected_continent], timezone_offset_h, timezone_offset_m);
|
||||
return;
|
||||
}
|
||||
brewing_date(10000000);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to print a zero-padded integer
|
||||
static void brew_int_padded_date(int n) {
|
||||
if (n >= 0 && n < 10) {
|
||||
print_char('0');
|
||||
}
|
||||
brew_int(n);
|
||||
}
|
||||
|
||||
static void date_command(int* timezone_offset_h, int* timezone_offset_m) {
|
||||
select_continent_date(timezone_offset_h, timezone_offset_m);
|
||||
int year, month, day, hour, minute, second;
|
||||
get_datetime(&year, &month, &day, &hour, &minute, &second);
|
||||
|
||||
// Apply timezone offset
|
||||
hour += *timezone_offset_h;
|
||||
minute += *timezone_offset_m;
|
||||
|
||||
// Handle minute overflow/underflow
|
||||
if (minute >= 60) {
|
||||
hour++;
|
||||
minute -= 60;
|
||||
} else if (minute < 0) {
|
||||
hour--;
|
||||
minute += 60;
|
||||
}
|
||||
|
||||
// Handle hour overflow/underflow
|
||||
if (hour >= 24) {
|
||||
day++;
|
||||
hour -= 24;
|
||||
} else if (hour < 0) {
|
||||
day--;
|
||||
hour += 24;
|
||||
}
|
||||
|
||||
// Note: This doesn't handle day/month/year wrapping correctly. It's a simplified implementation.
|
||||
|
||||
brew_str("\nCurrent Date and Time:\n");
|
||||
brew_int(year);
|
||||
brew_str("-");
|
||||
brew_int_padded_date(month);
|
||||
brew_str("-");
|
||||
brew_int_padded_date(day);
|
||||
brew_str(" ");
|
||||
brew_int_padded_date(hour);
|
||||
brew_str(":");
|
||||
brew_int_padded_date(minute);
|
||||
brew_str(":");
|
||||
brew_int_padded_date(second);
|
||||
brew_str("\n");
|
||||
}
|
||||
|
||||
#endif // DATE_H
|
||||
54
src/kernel/cli_apps_old/help.h
Normal file
54
src/kernel/cli_apps_old/help.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_HELP_H
|
||||
#define APPS_HELP_H
|
||||
|
||||
#include "../print.h"
|
||||
|
||||
static void display_help() {
|
||||
brew_str("\nAvailable commands:\n");
|
||||
brew_str(" HELP - Display this help message\n");
|
||||
brew_str(" DATE - Display the current date and time\n");
|
||||
brew_str(" EXIT - Exit CLI mode and return to regular typing\n");
|
||||
brew_str(" CLEAR - Clear the screen\n");
|
||||
brew_str(" ABOUT - Display system information\n");
|
||||
brew_str(" MATH - Perform basic arithmetic\n");
|
||||
brew_str(" MAN - Show the detailed user manual\n");
|
||||
brew_str(" LICENSE - Display the GNU GPLv3 license\n");
|
||||
brew_str(" UPTIME - Show how long the system has been running\n");
|
||||
brew_str(" MEMORY - Display memory usage statistics\n");
|
||||
brew_str(" BEEP - Makes a beep sound using the PC speaker\n");
|
||||
brew_str(" TXTEDIT - Open the text editor\n");
|
||||
brew_str(" COWSAY. - MOO!\n");
|
||||
brew_str(" LS - List files in current directory\n");
|
||||
brew_str(" CD - Change current directory\n");
|
||||
brew_str(" PWD - Print working directory\n");
|
||||
brew_str(" MKDIR - Create one or more directories\n");
|
||||
brew_str(" RM - Remove a file or empty directory\n");
|
||||
brew_str(" CAT - Display file contents\n");
|
||||
brew_str(" TOUCH - Create an empty file\n");
|
||||
brew_str(" ECHO - Print text (can redirect to file with >)\n");
|
||||
brew_str(" NETINIT - Initialize network card\n");
|
||||
brew_str(" NETINFO - Show network status (MAC, IP)\n");
|
||||
brew_str(" UDPTEST - Start UDP echo server on port 12345 (broken)\n");
|
||||
brew_str(" UDPSEND - Send UDP packet (UDPSEND <ip> <port> <msg>)\n");
|
||||
brew_str("\nPipe support:\n");
|
||||
brew_str(" CAT <file> | UDPSEND <ip> <port> - Send file contents via UDP\n");
|
||||
}
|
||||
|
||||
#endif // APPS_HELP_H
|
||||
738
src/kernel/cli_apps_old/license.h
Normal file
738
src/kernel/cli_apps_old/license.h
Normal file
|
|
@ -0,0 +1,738 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_LICENSE_H
|
||||
#define APPS_LICENSE_H
|
||||
|
||||
#include "print.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
const char* license_pages[] = {
|
||||
" GNU GENERAL PUBLIC LICENSE",
|
||||
" Version 3, 29 June 2007",
|
||||
" Copyright (C) 2024-2026 boreddevnl",
|
||||
"",
|
||||
" ",
|
||||
" Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>",
|
||||
" Everyone is permitted to copy and distribute verbatim copies",
|
||||
" of this license document, but changing it is not allowed.",
|
||||
"",
|
||||
" Preamble",
|
||||
"",
|
||||
" The GNU General Public License is a free, copyleft license for",
|
||||
"software and other kinds of works.",
|
||||
"",
|
||||
" The licenses for most software and other practical works are designed",
|
||||
"to take away your freedom to share and change the works. By contrast,",
|
||||
"the GNU General Public License is intended to guarantee your freedom to",
|
||||
"share and change all versions of a program--to make sure it remains free",
|
||||
"software for all its users. We, the Free Software Foundation, use the",
|
||||
"GNU General Public License for most of our software; it applies also to",
|
||||
"any other work released this way by its authors. You can apply it to",
|
||||
"your programs, too.",
|
||||
"",
|
||||
" When we speak of free software, we are referring to freedom, not",
|
||||
"price. Our General Public Licenses are designed to make sure that you",
|
||||
"have the freedom to distribute copies of free software (and charge for",
|
||||
"them if you wish), that you receive source code or can get it if you",
|
||||
"want it, that you can change the software or use pieces of it in new",
|
||||
"free programs, and that you know you can do these things.",
|
||||
"",
|
||||
" To protect your rights, we need to prevent others from denying you",
|
||||
"these rights or asking you to surrender the rights. Therefore, you have",
|
||||
"certain responsibilities if you distribute copies of the software, or if",
|
||||
"you modify it: responsibilities to respect the freedom of others.",
|
||||
"",
|
||||
" For example, if you distribute copies of such a program, whether",
|
||||
"gratis or for a fee, you must pass on to the recipients the same",
|
||||
"freedoms that you received. You must make sure that they, too, receive",
|
||||
"or can get the source code. And you must show them these terms so they",
|
||||
"know their rights.",
|
||||
"",
|
||||
" Developers that use the GNU GPL protect your rights with two steps:",
|
||||
"(1) assert copyright on the software, and (2) offer you this License",
|
||||
"giving you legal permission to copy, distribute and/or modify it.",
|
||||
"",
|
||||
" For the developers' and authors' protection, the GPL clearly explains",
|
||||
"that there is no warranty for this free software. For both users' and",
|
||||
"authors' sake, the GPL requires that modified versions be marked as",
|
||||
"changed, so that their problems will not be attributed erroneously to",
|
||||
"authors of previous versions.",
|
||||
"",
|
||||
" Some devices are designed to deny users access to install or run",
|
||||
"modified versions of the software inside them, although the manufacturer",
|
||||
"can do so. This is fundamentally incompatible with the aim of",
|
||||
"protecting users' freedom to change the software. The systematic",
|
||||
"pattern of such abuse occurs in the area of products for individuals to",
|
||||
"use, which is precisely where it is most unacceptable. Therefore, we",
|
||||
"have designed this version of the GPL to prohibit the practice for those",
|
||||
"products. If such problems arise substantially in other domains, we",
|
||||
"stand ready to extend this provision to those domains in future versions",
|
||||
"of the GPL, as needed to protect the freedom of users.",
|
||||
"",
|
||||
" Finally, every program is threatened constantly by software patents.",
|
||||
"States should not allow patents to restrict development and use of",
|
||||
"software on general-purpose computers, but in those that do, we wish to",
|
||||
"avoid the special danger that patents applied to a free program could",
|
||||
"make it effectively proprietary. To prevent this, the GPL assures that",
|
||||
"patents cannot be used to render the program non-free.",
|
||||
"",
|
||||
" The precise terms and conditions for copying, distribution and",
|
||||
"modification follow.",
|
||||
"",
|
||||
" TERMS AND CONDITIONS",
|
||||
"",
|
||||
" 0. Definitions.",
|
||||
"",
|
||||
" 'This License' refers to version 3 of the GNU General Public License.",
|
||||
"",
|
||||
" 'Copyright' also means copyright-like laws that apply to other kinds of",
|
||||
"works, such as semiconductor masks.",
|
||||
"",
|
||||
" 'The Program' refers to any copyrightable work licensed under this",
|
||||
"License. Each licensee is addressed as 'you'. 'Licensees' and",
|
||||
"'recipients' may be individuals or organizations.",
|
||||
"",
|
||||
" To 'modify' a work means to copy from or adapt all or part of the work",
|
||||
"in a fashion requiring copyright permission, other than the making of an",
|
||||
"exact copy. The resulting work is called a 'modified version' of the",
|
||||
"earlier work or a work 'based on' the earlier work.",
|
||||
"",
|
||||
" A 'covered work' means either the unmodified Program or a work based",
|
||||
"on the Program.",
|
||||
"",
|
||||
" To 'propagate' a work means to do anything with it that, without",
|
||||
"permission, would make you directly or secondarily liable for",
|
||||
"infringement under applicable copyright law, except executing it on a",
|
||||
"computer or modifying a private copy. Propagation includes copying,",
|
||||
"distribution (with or without modification), making available to the",
|
||||
"public, and in some countries other activities as well.",
|
||||
"",
|
||||
" To 'convey' a work means any kind of propagation that enables other",
|
||||
"parties to make or receive copies. Mere interaction with a user through",
|
||||
"a computer network, with no transfer of a copy, is not conveying.",
|
||||
"",
|
||||
" An interactive user interface displays 'Appropriate Legal Notices'",
|
||||
"to the extent that it includes a convenient and prominently visible",
|
||||
"feature that (1) displays an appropriate copyright notice, and (2)",
|
||||
"tells the user that there is no warranty for the work (except to the",
|
||||
"extent that warranties are provided), that licensees may convey the",
|
||||
"work under this License, and how to view a copy of this License. If",
|
||||
"the interface presents a list of user commands or options, such as a",
|
||||
"menu, a prominent item in the list meets this criterion.",
|
||||
"",
|
||||
" 1. Source Code.",
|
||||
"",
|
||||
" The 'source code' for a work means the preferred form of the work",
|
||||
"for making modifications to it. 'Object code' means any non-source",
|
||||
"form of a work.",
|
||||
"",
|
||||
" A 'Standard Interface' means an interface that either is an official",
|
||||
"standard defined by a recognized standards body, or, in the case of",
|
||||
"interfaces specified for a particular programming language, one that",
|
||||
"is widely used among developers working in that language.",
|
||||
"",
|
||||
" The 'System Libraries' of an executable work include anything, other",
|
||||
"than the work as a whole, that (a) is included in the normal form of",
|
||||
"packaging a Major Component, but which is not part of that Major",
|
||||
"Component, and (b) serves only to enable use of the work with that",
|
||||
"Major Component, or to implement a Standard Interface for which an",
|
||||
"implementation is available to the public in source code form. A",
|
||||
"'Major Component', in this context, means a major essential component",
|
||||
"(kernel, window system, and so on) of the specific operating system",
|
||||
"(if any) on which the executable work runs, or a compiler used to",
|
||||
"produce the work, or an object code interpreter used to run it.",
|
||||
"",
|
||||
" The 'Corresponding Source' for a work in object code form means all",
|
||||
"the source code needed to generate, install, and (for an executable",
|
||||
"work) run the object code and to modify the work, including scripts to",
|
||||
"control those activities. However, it does not include the work's",
|
||||
"System Libraries, or general-purpose tools or generally available free",
|
||||
"programs which are used unmodified in performing those activities but",
|
||||
"which are not part of the work. For example, Corresponding Source",
|
||||
"includes interface definition files associated with source files for",
|
||||
"the work, and the source code for shared libraries and dynamically",
|
||||
"linked subprograms that the work is specifically designed to require,",
|
||||
"such as by intimate data communication or control flow between those",
|
||||
"subprograms and other parts of the work.",
|
||||
"",
|
||||
" The Corresponding Source need not include anything that users",
|
||||
"can regenerate automatically from other parts of the Corresponding",
|
||||
"Source.",
|
||||
"",
|
||||
" The Corresponding Source for a work in source code form is that",
|
||||
"same work.",
|
||||
"",
|
||||
" 2. Basic Permissions.",
|
||||
"",
|
||||
" All rights granted under this License are granted for the term of",
|
||||
"copyright on the Program, and are irrevocable provided the stated",
|
||||
"conditions are met. This License explicitly affirms your unlimited",
|
||||
"permission to run the unmodified Program. The output from running a",
|
||||
"covered work is covered by this License only if the output, given its",
|
||||
"content, constitutes a covered work. This License acknowledges your",
|
||||
"rights of fair use or other equivalent, as provided by copyright law.",
|
||||
"",
|
||||
" You may make, run and propagate covered works that you do not",
|
||||
"convey, without conditions so long as your license otherwise remains",
|
||||
"in force. You may convey covered works to others for the sole purpose",
|
||||
"of having them make modifications exclusively for you, or provide you",
|
||||
"with facilities for running those works, provided that you comply with",
|
||||
"the terms of this License in conveying all material for which you do",
|
||||
"not control copyright. Those thus making or running the covered works",
|
||||
"for you must do so exclusively on your behalf, under your direction",
|
||||
"and control, on terms that prohibit them from making any copies of",
|
||||
"your copyrighted material outside their relationship with you.",
|
||||
"",
|
||||
" Conveying under any other circumstances is permitted solely under",
|
||||
"the conditions stated below. Sublicensing is not allowed; section 10",
|
||||
"makes it unnecessary.",
|
||||
"",
|
||||
" 3. Protecting Users' Legal Rights From Anti-Circumvention Law.",
|
||||
"",
|
||||
" No covered work shall be deemed part of an effective technological",
|
||||
"measure under any applicable law fulfilling obligations under article",
|
||||
"11 of the WIPO copyright treaty adopted on 20 December 1996, or",
|
||||
"similar laws prohibiting or restricting circumvention of such",
|
||||
"measures.",
|
||||
"",
|
||||
" When you convey a covered work, you waive any legal power to forbid",
|
||||
"circumvention of technological measures to the extent such circumvention",
|
||||
"is effected by exercising rights under this License with respect to",
|
||||
"the covered work, and you disclaim any intention to limit operation or",
|
||||
"modification of the work as a means of enforcing, against the work's",
|
||||
"users, your or third parties' legal rights to forbid circumvention of",
|
||||
"technological measures.",
|
||||
"",
|
||||
" 4. Conveying Verbatim Copies.",
|
||||
"",
|
||||
" You may convey verbatim copies of the Program's source code as you",
|
||||
"receive it, in any medium, provided that you conspicuously and",
|
||||
"appropriately publish on each copy an appropriate copyright notice;",
|
||||
"keep intact all notices stating that this License and any",
|
||||
"non-permissive terms added in accord with section 7 apply to the code;",
|
||||
"keep intact all notices of the absence of any warranty; and give all",
|
||||
"recipients a copy of this License along with the Program.",
|
||||
"",
|
||||
" You may charge any price or no price for each copy that you convey,",
|
||||
"and you may offer support or warranty protection for a fee.",
|
||||
"",
|
||||
" 5. Conveying Modified Source Versions.",
|
||||
"",
|
||||
" You may convey a work based on the Program, or the modifications to",
|
||||
"produce it from the Program, in the form of source code under the",
|
||||
"terms of section 4, provided that you also meet all of these conditions:",
|
||||
"",
|
||||
" a) The work must carry prominent notices stating that you modified",
|
||||
" it, and giving a relevant date.",
|
||||
"",
|
||||
" b) The work must carry prominent notices stating that it is",
|
||||
" released under this License and any conditions added under section",
|
||||
" 7. This requirement modifies the requirement in section 4 to",
|
||||
" 'keep intact all notices'.",
|
||||
"",
|
||||
" c) You must license the entire work, as a whole, under this",
|
||||
" License to anyone who comes into possession of a copy. This",
|
||||
" License will therefore apply, along with any applicable section 7",
|
||||
" additional terms, to the whole of the work, and all its parts,",
|
||||
" regardless of how they are packaged. This License gives no",
|
||||
" permission to license the work in any other way, but it does not",
|
||||
" invalidate such permission if you have separately received it.",
|
||||
"",
|
||||
" d) If the work has interactive user interfaces, each must display",
|
||||
" Appropriate Legal Notices; however, if the Program has interactive",
|
||||
" interfaces that do not display Appropriate Legal Notices, your",
|
||||
" work need not make them do so.",
|
||||
"",
|
||||
" A compilation of a covered work with other separate and independent",
|
||||
"works, which are not by their nature extensions of the covered work,",
|
||||
"and which are not combined with it such as to form a larger program,",
|
||||
"in or on a volume of a storage or distribution medium, is called an",
|
||||
"'aggregate' if the compilation and its resulting copyright are not",
|
||||
"used to limit the access or legal rights of the compilation's users",
|
||||
"beyond what the individual works permit. Inclusion of a covered work",
|
||||
"in an aggregate does not cause this License to apply to the other",
|
||||
"parts of the aggregate.",
|
||||
"",
|
||||
" 6. Conveying Non-Source Forms.",
|
||||
"",
|
||||
" You may convey a covered work in object code form under the terms",
|
||||
"of sections 4 and 5, provided that you also convey the",
|
||||
"machine-readable Corresponding Source under the terms of this License,",
|
||||
"in one of these ways:",
|
||||
"",
|
||||
" a) Convey the object code in, or embodied in, a physical product",
|
||||
" (including a physical distribution medium), accompanied by the",
|
||||
" Corresponding Source fixed on a durable physical medium",
|
||||
" customarily used for software interchange.",
|
||||
"",
|
||||
" b) Convey the object code in, or embodied in, a physical product",
|
||||
" (including a physical distribution medium), accompanied by a",
|
||||
" written offer, valid for at least three years and valid for as",
|
||||
" long as you offer spare parts or customer support for that product",
|
||||
" model, to give anyone who possesses the object code either (1) a",
|
||||
" copy of the Corresponding Source for all the software in the",
|
||||
" product that is covered by this License, on a durable physical",
|
||||
" medium customarily used for software interchange, for a price no",
|
||||
" more than your reasonable cost of physically performing this",
|
||||
" conveying of source, or (2) access to copy the",
|
||||
" Corresponding Source from a network server at no charge.",
|
||||
"",
|
||||
" c) Convey individual copies of the object code with a copy of the",
|
||||
" written offer to provide the Corresponding Source. This",
|
||||
" alternative is allowed only occasionally and noncommercially, and",
|
||||
" only if you received the object code with such an offer, in accord",
|
||||
" with subsection 6b.",
|
||||
"",
|
||||
" d) Convey the object code by offering access from a designated",
|
||||
" place (gratis or for a charge), and offer equivalent access to the",
|
||||
" Corresponding Source in the same way through the same place at no",
|
||||
" further charge. You need not require recipients to copy the",
|
||||
" Corresponding Source along with the object code. If the place to",
|
||||
" copy the object code is a network server, the Corresponding Source",
|
||||
" may be on a different server (operated by you or a third party)",
|
||||
" that supports equivalent copying facilities, provided you maintain",
|
||||
" clear directions next to the object code saying where to find the",
|
||||
" Corresponding Source. Regardless of what server hosts the",
|
||||
" Corresponding Source, you remain obligated to ensure that it is",
|
||||
" available for as long as needed to satisfy these requirements.",
|
||||
"",
|
||||
" e) Convey the object code using peer-to-peer transmission, provided",
|
||||
" you inform other peers where the object code and Corresponding",
|
||||
" Source of the work are being offered to the general public at no",
|
||||
" charge under subsection 6d.",
|
||||
"",
|
||||
" A separable portion of the object code, whose source code is excluded",
|
||||
"from the Corresponding Source as a System Library, need not be",
|
||||
"included in conveying the object code work.",
|
||||
"",
|
||||
" A 'User Product' is either (1) a 'consumer product', which means any",
|
||||
"tangible personal property which is normally used for personal, family,",
|
||||
"or household purposes, or (2) anything designed or sold for incorporation",
|
||||
"into a dwelling. In determining whether a product is a consumer product,",
|
||||
"doubtful cases shall be resolved in favor of coverage. For a particular",
|
||||
"product received by a particular user, 'normally used' refers to a",
|
||||
"typical or common use of that class of product, regardless of the status",
|
||||
"of the particular user or of the way in which the particular user",
|
||||
"actually uses, or expects or is expected to use, the product. A product",
|
||||
"is a consumer product regardless of whether the product has substantial",
|
||||
"commercial, industrial or non-consumer uses, unless such uses represent",
|
||||
"the only significant mode of use of the product.",
|
||||
"",
|
||||
" 'Installation Information' for a User Product means any methods,",
|
||||
"procedures, authorization keys, or other information required to install",
|
||||
"and execute modified versions of a covered work in that User Product from",
|
||||
"a modified version of its Corresponding Source. The information must",
|
||||
"suffice to ensure that the continued functioning of the modified object",
|
||||
"code is in no case prevented or interfered with solely because",
|
||||
"modification has been made.",
|
||||
"",
|
||||
" If you convey an object code work under this section in, or with, or",
|
||||
"specifically for use in, a User Product, and the conveying occurs as",
|
||||
"part of a transaction in which the right of possession and use of the",
|
||||
"User Product is transferred to the recipient in perpetuity or for a",
|
||||
"fixed term (regardless of how the transaction is characterized), the",
|
||||
"Corresponding Source conveyed under this section must be accompanied",
|
||||
"by the Installation Information. But this requirement does not apply",
|
||||
"if neither you nor any third party retains the ability to install",
|
||||
"modified object code on the User Product (for example, the work has",
|
||||
"been installed in ROM).",
|
||||
"",
|
||||
" The requirement to provide Installation Information does not include a",
|
||||
"requirement to continue to provide support service, warranty, or updates",
|
||||
"for a work that has been modified or installed by the recipient, or for",
|
||||
"the User Product in which it has been modified or installed. Access to a",
|
||||
"network may be denied when the modification itself materially and",
|
||||
"adversely affects the operation of the network or violates the rules and",
|
||||
"protocols for communication across the network.",
|
||||
"",
|
||||
" Corresponding Source conveyed, and Installation Information provided,",
|
||||
"in accord with this section must be in a format that is publicly",
|
||||
"documented (and with an implementation available to the public in",
|
||||
"source code form), and must require no special password or key for",
|
||||
"unpacking, reading or copying.",
|
||||
"",
|
||||
" 7. Additional Terms.",
|
||||
"",
|
||||
" 'Additional permissions' are terms that supplement the terms of this",
|
||||
"License by making exceptions from one or more of its conditions.",
|
||||
"Additional permissions that are applicable to the entire Program shall",
|
||||
"be treated as though they were included in this License, to the extent",
|
||||
"that they are valid under applicable law. If additional permissions",
|
||||
"apply only to part of the Program, that part may be used separately",
|
||||
"under those permissions, but the entire Program remains governed by",
|
||||
"this License without regard to the additional permissions.",
|
||||
"",
|
||||
" When you convey a copy of a covered work, you may at your option",
|
||||
"remove any additional permissions from that copy, or from any part of",
|
||||
"it. (Additional permissions may be written to require their own",
|
||||
"removal in certain cases when you modify the work.) You may place",
|
||||
"additional permissions on material, added by you to a covered work,",
|
||||
"for which you have or can give appropriate copyright permission.",
|
||||
"",
|
||||
" Notwithstanding any other provision of this License, for material you",
|
||||
"add to a covered work, you may (if authorized by the copyright holders of",
|
||||
"that material) supplement the terms of this License with terms:",
|
||||
"",
|
||||
" a) Disclaiming warranty or limiting liability differently from the",
|
||||
" terms of sections 15 and 16 of this License; or",
|
||||
"",
|
||||
" b) Requiring preservation of specified reasonable legal notices or",
|
||||
" author attributions in that material or in the Appropriate Legal",
|
||||
" Notices displayed by works containing it; or",
|
||||
"",
|
||||
" c) Prohibiting misrepresentation of the origin of that material, or",
|
||||
" requiring that modified versions of such material be marked in",
|
||||
" reasonable ways as different from the original version; or",
|
||||
"",
|
||||
" d) Limiting the use for publicity purposes of names of licensors or",
|
||||
" authors of the material; or",
|
||||
"",
|
||||
" e) Declining to grant rights under trademark law for use of some",
|
||||
" trade names, trademarks, or service marks; or",
|
||||
"",
|
||||
" f) Requiring indemnification of licensors and authors of that",
|
||||
" material by anyone who conveys the material (or modified versions of",
|
||||
" it) with contractual assumptions of liability to the recipient, for",
|
||||
" any liability that these contractual assumptions directly impose on",
|
||||
" those licensors and authors.",
|
||||
"",
|
||||
" All other non-permissive additional terms are considered 'further",
|
||||
"restrictions' within the meaning of section 10. If the Program as you",
|
||||
"received it, or any part of it, contains a notice stating that it is",
|
||||
"governed by this License along with a term that is a further",
|
||||
"restriction, you may remove that term. If a license document contains",
|
||||
"a further restriction but permits relicensing or conveying under this",
|
||||
"License, you may add to a covered work material governed by the terms",
|
||||
"of that license document, provided that the further restriction does",
|
||||
"not survive such relicensing or conveying.",
|
||||
"",
|
||||
" If you add terms to a covered work in accord with this section, you",
|
||||
"must place, in the relevant source files, a statement of the",
|
||||
"additional terms that apply to those files, or a notice indicating",
|
||||
"where to find the applicable terms.",
|
||||
"",
|
||||
" Additional terms, permissive or non-permissive, may be stated in the",
|
||||
"form of a separately written license, or stated as exceptions;",
|
||||
"the above requirements apply either way.",
|
||||
"",
|
||||
" 8. Termination.",
|
||||
"",
|
||||
" You may not propagate or modify a covered work except as expressly",
|
||||
"provided under this License. Any attempt otherwise to propagate or",
|
||||
"modify it is void, and will automatically terminate your rights under",
|
||||
"this License (including any patent licenses granted under the third",
|
||||
"paragraph of section 11).",
|
||||
"",
|
||||
" However, if you cease all violation of this License, then your",
|
||||
"license from a particular copyright holder is reinstated (a)",
|
||||
"provisionally, unless and until the copyright holder explicitly and",
|
||||
"finally terminates your license, and (b) permanently, if the copyright",
|
||||
"holder fails to notify you of the violation by some reasonable means",
|
||||
"prior to 60 days after the cessation.",
|
||||
"",
|
||||
" Moreover, your license from a particular copyright holder is",
|
||||
"reinstated permanently if the copyright holder notifies you of the",
|
||||
"violation by some reasonable means, this is the first time you have",
|
||||
"received notice of violation of this License (for any work) from that",
|
||||
"copyright holder, and you cure the violation prior to 30 days after",
|
||||
"your receipt of the notice.",
|
||||
"",
|
||||
" Termination of your rights under this section does not terminate the",
|
||||
"licenses of parties who have received copies or rights from you under",
|
||||
"this License. If your rights have been terminated and not permanently",
|
||||
"reinstated, you do not qualify to receive new licenses for the same",
|
||||
"material under section 10.",
|
||||
"",
|
||||
" 9. Acceptance Not Required for Having Copies.",
|
||||
"",
|
||||
" You are not required to accept this License in order to receive or",
|
||||
"run a copy of the Program. Ancillary propagation of a covered work",
|
||||
"occurring solely as a consequence of using peer-to-peer transmission",
|
||||
"to receive a copy likewise does not require acceptance. However,",
|
||||
"nothing other than this License grants you permission to propagate or",
|
||||
"modify any covered work. These actions infringe copyright if you do",
|
||||
"not accept this License. Therefore, by modifying or propagating a",
|
||||
"covered work, you indicate your acceptance of this License to do so.",
|
||||
"",
|
||||
" 10. Automatic Licensing of Downstream Recipients.",
|
||||
"",
|
||||
" Each time you convey a covered work, the recipient automatically",
|
||||
"receives a license from the original licensors, to run, modify and",
|
||||
"propagate that work, subject to this License. You are not responsible",
|
||||
"for enforcing compliance by third parties with this License.",
|
||||
"",
|
||||
" An 'entity transaction' is a transaction transferring control of an",
|
||||
"organization, or substantially all assets of one, or subdividing an",
|
||||
"organization, or merging organizations. If propagation of a covered",
|
||||
"work results from an entity transaction, each party to that",
|
||||
"transaction who receives a copy of the work also receives whatever",
|
||||
"licenses to the work the party's predecessor in interest had or could",
|
||||
"give under the previous paragraph, plus a right to possession of the",
|
||||
"Corresponding Source of the work from the predecessor in interest, if",
|
||||
"the predecessor has it or can get it with reasonable efforts.",
|
||||
"",
|
||||
" You may not impose any further restrictions on the exercise of the",
|
||||
"rights granted or affirmed under this License. For example, you may",
|
||||
"not impose a license fee, royalty, or other charge for exercise of",
|
||||
"rights granted under this License, and you may not initiate litigation",
|
||||
"(including a cross-claim or counterclaim in a lawsuit) alleging that",
|
||||
"any patent claim is infringed by making, using, selling, offering for",
|
||||
"sale, or importing the Program or any portion of it.",
|
||||
"",
|
||||
" 11. Patents.",
|
||||
"",
|
||||
" A 'contributor' is a copyright holder who authorizes use under this",
|
||||
"License of the Program or a work on which the Program is based. The",
|
||||
"work thus licensed is called the contributor's 'contributor version'.",
|
||||
"",
|
||||
" A contributor's 'essential patent claims' are all patent claims",
|
||||
"owned or controlled by the contributor, whether already acquired or",
|
||||
"hereafter acquired, that would be infringed by some manner, permitted",
|
||||
"by this License, of making, using, or selling its contributor version,",
|
||||
"but do not include claims that would be infringed only as a",
|
||||
"consequence of further modification of the contributor version. For",
|
||||
"purposes of this definition, 'control' includes the right to grant",
|
||||
"patent sublicenses in a manner consistent with the requirements of",
|
||||
"this License.",
|
||||
"",
|
||||
" Each contributor grants you a non-exclusive, worldwide, royalty-free",
|
||||
"patent license under the contributor's essential patent claims, to",
|
||||
"make, use, sell, offer for sale, import and otherwise run, modify and",
|
||||
"propagate the contents of its contributor version.",
|
||||
"",
|
||||
" In the following three paragraphs, a 'patent license' is any express",
|
||||
"agreement or commitment, however denominated, not to enforce a patent",
|
||||
"(such as an express permission to practice a patent or covenant not to",
|
||||
"sue for patent infringement). To 'grant' such a patent license to a",
|
||||
"party means to make such an agreement or commitment not to enforce a",
|
||||
"patent against the party.",
|
||||
"",
|
||||
" If you convey a covered work, knowingly relying on a patent license,",
|
||||
"and the Corresponding Source of the work is not available for anyone",
|
||||
"to copy, free of charge and under the terms of this License, through a",
|
||||
"publicly available network server or other readily accessible means,",
|
||||
"then you must either (1) cause the Corresponding Source to be so",
|
||||
"available, or (2) arrange to deprive yourself of the benefit of the",
|
||||
"patent license for this particular work, or (3) arrange, in a manner",
|
||||
"consistent with the requirements of this License, to extend the patent",
|
||||
"license to downstream recipients. 'Knowingly relying' means you have",
|
||||
"actual knowledge that, but for the patent license, your conveying the",
|
||||
"covered work in a country, or your recipient's use of the covered work",
|
||||
"in a country, would infringe one or more identifiable patents in that",
|
||||
"country that you have reason to believe are valid.",
|
||||
"",
|
||||
" If, pursuant to or in connection with a single transaction or",
|
||||
"arrangement, you convey, or propagate by procuring conveyance of, a",
|
||||
"covered work, and grant a patent license to some of the parties",
|
||||
"receiving the covered work authorizing them to use, propagate, modify",
|
||||
"or convey a specific copy of the covered work, then the patent license",
|
||||
"you grant is automatically extended to all recipients of the covered",
|
||||
"work and works based on it.",
|
||||
"",
|
||||
" A patent license is 'discriminatory' if it does not include within",
|
||||
"the scope of its coverage, prohibits the exercise of, or is",
|
||||
"conditioned on the non-exercise of one or more of the rights that are",
|
||||
"specifically granted under this License. You may not convey a covered",
|
||||
"work if you are a party to an arrangement with a third party that is",
|
||||
"in the business of distributing software, under which you make payment",
|
||||
"to the third party based on the extent of your activity of conveying",
|
||||
"the work, and under which the third party grants, to any of the",
|
||||
"parties who would receive the covered work from you, a discriminatory",
|
||||
"patent license (a) in connection with copies of the covered work",
|
||||
"conveyed by you (or copies made from those copies), or (b) primarily",
|
||||
"for and in connection with specific products or compilations that",
|
||||
"contain the covered work, unless you entered into that arrangement,",
|
||||
"or that patent license was granted, prior to 28 March 2007.",
|
||||
"",
|
||||
" Nothing in this License shall be construed as excluding or limiting",
|
||||
"any implied license or other defenses to infringement that may",
|
||||
"otherwise be available to you under applicable patent law.",
|
||||
"",
|
||||
" 12. No Surrender of Others' Freedom.",
|
||||
"",
|
||||
" If conditions are imposed on you (whether by court order, agreement or",
|
||||
"otherwise) that contradict the conditions of this License, they do not",
|
||||
"excuse you from the conditions of this License. If you cannot convey a",
|
||||
"covered work so as to satisfy simultaneously your obligations under this",
|
||||
"License and any other pertinent obligations, then as a consequence you may",
|
||||
"not convey it at all. For example, if you agree to terms that obligate you",
|
||||
"to collect a royalty for further conveying from those to whom you convey",
|
||||
"the Program, the only way you could satisfy both those terms and this",
|
||||
"License would be to refrain entirely from conveying the Program.",
|
||||
"",
|
||||
" 13. Use with the GNU Affero General Public License.",
|
||||
"",
|
||||
" Notwithstanding any other provision of this License, you have",
|
||||
"permission to link or combine any covered work with a work licensed",
|
||||
"under version 3 of the GNU Affero General Public License into a single",
|
||||
"combined work, and to convey the resulting work. The terms of this",
|
||||
"License will continue to apply to the part which is the covered work,",
|
||||
"but the special requirements of the GNU Affero General Public License,",
|
||||
"section 13, concerning interaction through a network will apply to the",
|
||||
"combination as such.",
|
||||
"",
|
||||
" 14. Revised Versions of this License.",
|
||||
"",
|
||||
" The Free Software Foundation may publish revised and/or new versions of",
|
||||
"the GNU General Public License from time to time. Such new versions will",
|
||||
"be similar in spirit to the present version, but may differ in detail to",
|
||||
"address new problems or concerns.",
|
||||
"",
|
||||
" Each version is given a distinguishing version number. If the",
|
||||
"Program specifies that a certain numbered version of the GNU General",
|
||||
"Public License 'or any later version' applies to it, you have the",
|
||||
"option of following the terms and conditions either of that numbered",
|
||||
"version or of any later version published by the Free Software",
|
||||
"Foundation. If the Program does not specify a version number of the",
|
||||
"GNU General Public License, you may choose any version ever published",
|
||||
"by the Free Software Foundation.",
|
||||
"",
|
||||
" If the Program specifies that a proxy can decide which future",
|
||||
"versions of the GNU General Public License can be used, that proxy's",
|
||||
"public statement of acceptance of a version permanently authorizes you",
|
||||
"to choose that version for the Program.",
|
||||
"",
|
||||
" Later license versions may give you additional or different",
|
||||
"permissions. However, no additional obligations are imposed on any",
|
||||
"author or copyright holder as a result of your choosing to follow a",
|
||||
"later version.",
|
||||
"",
|
||||
" 15. Disclaimer of Warranty.",
|
||||
"",
|
||||
" THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY",
|
||||
"APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT",
|
||||
"HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM 'AS IS' WITHOUT WARRANTY",
|
||||
"OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,",
|
||||
"THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR",
|
||||
"PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM",
|
||||
"IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF",
|
||||
"ALL NECESSARY SERVICING, REPAIR OR CORRECTION.",
|
||||
"",
|
||||
" 16. Limitation of Liability.",
|
||||
"",
|
||||
" IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING",
|
||||
"WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS",
|
||||
"THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY",
|
||||
"GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE",
|
||||
"USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF",
|
||||
"DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD",
|
||||
"PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),",
|
||||
"EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF",
|
||||
"SUCH DAMAGES.",
|
||||
"",
|
||||
" 17. Interpretation of Sections 15 and 16.",
|
||||
"",
|
||||
" If the disclaimer of warranty and limitation of liability provided",
|
||||
"above cannot be given local legal effect according to their terms,",
|
||||
"reviewing courts shall apply local law that most closely approximates",
|
||||
"an absolute waiver of all civil liability in connection with the",
|
||||
"Program, unless a warranty or assumption of liability accompanies a",
|
||||
"copy of the Program in return for a fee.",
|
||||
"",
|
||||
" END OF TERMS AND CONDITIONS",
|
||||
"",
|
||||
" How to Apply These Terms to Your New Programs",
|
||||
"",
|
||||
" If you develop a new program, and you want it to be of the greatest",
|
||||
"possible use to the public, the best way to achieve this is to make it",
|
||||
"free software which everyone can redistribute and change under these terms.",
|
||||
"",
|
||||
" To do so, attach the following notices to the program. It is safest",
|
||||
"to attach them to the start of each source file to most effectively",
|
||||
"state the exclusion of warranty; and each file should have at least",
|
||||
"the 'copyright' line and a pointer to where the full notice is found.",
|
||||
"",
|
||||
" <one line to give the program's name and a brief idea of what it does.>",
|
||||
" Copyright (C) <year> <name of author>",
|
||||
"",
|
||||
" This program is free software: you can redistribute it and/or modify",
|
||||
" it under the terms of the GNU General Public License as published by",
|
||||
" the Free Software Foundation, either version 3 of the License, or",
|
||||
" (at your option) any later version.",
|
||||
"",
|
||||
" This program is distributed in the hope that it will be useful,",
|
||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of",
|
||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
|
||||
" GNU General Public License for more details.",
|
||||
"",
|
||||
" You should have received a copy of the GNU General Public License",
|
||||
" along with this program. If not, see <https://www.gnu.org/licenses/>.",
|
||||
"",
|
||||
"Also add information on how to contact you by electronic and paper mail.",
|
||||
"",
|
||||
" If the program does terminal interaction, make it output a short",
|
||||
"notice like this when it starts in an interactive mode:",
|
||||
"",
|
||||
" <program> Copyright (C) <year> <name of author>",
|
||||
" This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.",
|
||||
" This is free software, and you are welcome to redistribute it",
|
||||
" under certain conditions; type `show c' for details.",
|
||||
"",
|
||||
"The hypothetical commands `show w' and `show c' should show the appropriate",
|
||||
"parts of the General Public License. Of course, your program's commands",
|
||||
"might be different; for a GUI interface, you would use an 'about box'.",
|
||||
"",
|
||||
" You should also get your employer (if you work as a programmer) or school,",
|
||||
"if any, to sign a 'copyright disclaimer' for the program, if necessary.",
|
||||
"For more information on this, and how to apply and follow the GNU GPL, see",
|
||||
"<https://www.gnu.org/licenses/>.",
|
||||
"",
|
||||
" The GNU General Public License does not permit incorporating your program",
|
||||
"into proprietary programs. If your program is a subroutine library, you",
|
||||
"may consider it more useful to permit linking proprietary applications with",
|
||||
"the library. If this is what you want to do, use the GNU Lesser General",
|
||||
"Public License instead of this License. But first, please read",
|
||||
"<https://www.gnu.org/licenses/why-not-lgpl.html>.",
|
||||
"--- End of License ---"
|
||||
};
|
||||
const int license_num_lines = sizeof(license_pages) / sizeof(char*);
|
||||
|
||||
static void show_license() {
|
||||
int top_line = 0;
|
||||
int needs_redraw = 1;
|
||||
|
||||
while (1) {
|
||||
if (needs_redraw) {
|
||||
print_clear();
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
for (int i = 0; i < 24 && (top_line + i) < license_num_lines; i++) {
|
||||
brew_str(license_pages[top_line + i]);
|
||||
brew_str("\n");
|
||||
}
|
||||
print_set_color(PRINT_INDEX_15, PRINT_INDEX_9);
|
||||
brew_str("-- (Up/Down to scroll, 'q' to quit) --");
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
needs_redraw = 0;
|
||||
}
|
||||
|
||||
// Wait for a key press before doing anything
|
||||
while (!check_keyboard()) { /* Do nothing */ }
|
||||
|
||||
unsigned char sc = read_scan_code(); // Now read the key
|
||||
if (sc == 0x48 && top_line > 0) { top_line--; needs_redraw = 1; } // Up Arrow
|
||||
else if (sc == 0x50 && (top_line + 24) < license_num_lines) { top_line++; needs_redraw = 1; } // Down Arrow
|
||||
else if (scan_code_to_ascii(sc) == 'q') {
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
break;
|
||||
}
|
||||
brewing(10000000); // Delay to handle keyboard typematic rate (key-repeat)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // APPS_MAN_H
|
||||
156
src/kernel/cli_apps_old/man.h
Normal file
156
src/kernel/cli_apps_old/man.h
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_MAN_H
|
||||
#define APPS_MAN_H
|
||||
|
||||
#include "print.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
const char* manual_pages[] = {
|
||||
"BrewKernel User Manual",
|
||||
"----------------------",
|
||||
"",
|
||||
"Welcome to the BrewKernel, a simple hobby operating system kernel designed",
|
||||
"for x86_64 architecture. This manual provides an overview of the system,",
|
||||
"its features, and available commands.",
|
||||
"",
|
||||
"== System Overview ==",
|
||||
"BrewKernel boots into a VGA text mode display (80x25 characters). It",
|
||||
"initializes a custom color palette and provides basic keyboard input",
|
||||
"handling. The primary user interface is a simple command-line",
|
||||
"interface (CLI).",
|
||||
"",
|
||||
"== Features ==",
|
||||
"* Ramdisk-based Filesystem: A simple in-memory filesystem supporting",
|
||||
" files and directories.",
|
||||
"* VGA Text Mode Driver: Full control over text and background colors.",
|
||||
"* PS/2 Keyboard Driver: Handles key presses, including modifier keys",
|
||||
" like Shift.",
|
||||
"* Simple CLI: A basic shell to interact with the kernel.",
|
||||
"* Command History (sort of): The last entered command remains in the",
|
||||
" buffer but is not yet a full history feature.",
|
||||
"",
|
||||
"== How to Use the CLI ==",
|
||||
"Upon boot, you can type 'CLI' and press Enter to start the command-line",
|
||||
"interface. Once in the CLI, you can type commands followed by Enter.",
|
||||
"Commands are case-insensitive.",
|
||||
"",
|
||||
"== Special Keys ==",
|
||||
"* Up/down arrow keys, scrolls through command history. (CLI mode only)",
|
||||
"",
|
||||
"== File System ==",
|
||||
"The BrewKernel includes a simple ramdisk-based filesystem. You can create,",
|
||||
"read, write, and list files and directories using the following commands:",
|
||||
"This filesystem will NOT save to disk and only saves to RAM.",
|
||||
"This filesystem is UNIX like, using '/' as the directory separator.",
|
||||
"Commands like ls, cd, mkdir work with absolute and relative paths.",
|
||||
"",
|
||||
"== Brew Language==",
|
||||
"== This version of brewkernel contains a simple interpreter for the",
|
||||
"== brew programming language. Currently the only implemented function is",
|
||||
"== brew_str, which prints a string to the screen. More features will be",
|
||||
"== added in future versions. Brew files have the extension .brew",
|
||||
"== you can run a brew file using the command: brewer >filename.brew<",
|
||||
"== Available Commands ==",
|
||||
"HELP: Displays a short list of available commands.",
|
||||
"LS [path]: Lists files in the specified directory or current directory if",
|
||||
" no path is given.",
|
||||
"",
|
||||
"CD [path]: Changes the current directory to 'path'.",
|
||||
"",
|
||||
"PWD: Prints the current working directory path.",
|
||||
"",
|
||||
"MKDIR [path]: Creates a new directory at the specified path.",
|
||||
"",
|
||||
"MAN: Shows this detailed user manual. Use UP/DOWN arrow keys to",
|
||||
" scroll and 'q' to quit the manual viewer.",
|
||||
"",
|
||||
"ABOUT: Displays information about the kernel, including version, build",
|
||||
" date, architecture, and compiler.",
|
||||
"",
|
||||
"MATH:",
|
||||
"A simple calculator for basic arithmetic operations",
|
||||
"(add, subtract, multiply, divide) on integers.",
|
||||
|
||||
"",
|
||||
"DATE: Displays the current date and time, with an option to select your",
|
||||
" timezone.",
|
||||
"",
|
||||
"TXTEDIT: A simple text editor. Features:",
|
||||
" - Create and edit multiple text files",
|
||||
" - Files are preserved between editor sessions (until reboot)",
|
||||
" - Navigate with arrow keys",
|
||||
" - Save/load files with custom names",
|
||||
" - ESC to exit (with save prompt)",
|
||||
"USAGE: txtedit >filename< or:",
|
||||
"txtedit and choose name on save",
|
||||
"",
|
||||
"IREADTHEMANUAL: Wow. You actually read the manual. Run this command",
|
||||
" for a special surprise!",
|
||||
"",
|
||||
"CLEAR: Clears the entire screen and moves the cursor to the top-left.",
|
||||
"",
|
||||
"EXIT: Exits the CLI mode and returns to the initial kernel screen.",
|
||||
"",
|
||||
"LICENSE: Displays the full GNU General Public License v3, under which",
|
||||
" BrewKernel is distributed. Use UP/DOWN to scroll, 'q' to quit.",
|
||||
"",
|
||||
"COWSAY: Moo! Displays a cow saying a message. Usage: COWSAY [message]",
|
||||
" Inspired by GNU/LINUX",
|
||||
"",
|
||||
"UPTIME: Shows how long the system has been running since boot.",
|
||||
"BEEP: Makes a beep sound using the PC speaker.",
|
||||
"--- End of Manual ---"
|
||||
};
|
||||
const int manual_num_lines = sizeof(manual_pages) / sizeof(char*);
|
||||
|
||||
static void show_manual() {
|
||||
int top_line = 0;
|
||||
int needs_redraw = 1;
|
||||
|
||||
while (1) {
|
||||
if (needs_redraw) {
|
||||
print_clear();
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
for (int i = 0; i < 24 && (top_line + i) < manual_num_lines; i++) {
|
||||
brew_str(manual_pages[top_line + i]);
|
||||
brew_str("\n");
|
||||
}
|
||||
print_set_color(PRINT_INDEX_15, PRINT_INDEX_9);
|
||||
brew_str("-- (Up/Down to scroll, 'q' to quit) --");
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
needs_redraw = 0;
|
||||
}
|
||||
|
||||
// Wait for a key press before doing anything
|
||||
while (!check_keyboard()) { /* Do nothing */ }
|
||||
|
||||
unsigned char sc = read_scan_code(); // Now read the key
|
||||
if (sc == 0x48 && top_line > 0) { top_line--; needs_redraw = 1; } // Up Arrow
|
||||
else if (sc == 0x50 && (top_line + 24) < manual_num_lines) { top_line++; needs_redraw = 1; } // Down Arrow
|
||||
else if (scan_code_to_ascii(sc) == 'q') {
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0);
|
||||
break;
|
||||
}
|
||||
|
||||
brewing(10000000); // Delay to handle keyboard typematic rate (key-repeat)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // APPS_MAN_H
|
||||
131
src/kernel/cli_apps_old/math.h
Normal file
131
src/kernel/cli_apps_old/math.h
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_MATH_H
|
||||
#define APPS_MATH_H
|
||||
|
||||
#include "print.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
extern int buffer_pos;
|
||||
|
||||
static void math_cmd() {
|
||||
brew_str("\nMath Calculator\n");
|
||||
brew_str("Choose operation:\n");
|
||||
brew_str("1. Addition (+)\n");
|
||||
brew_str("2. Subtraction (-)\n");
|
||||
brew_str("3. Multiplication (*)\n");
|
||||
brew_str("4. Division (/)\n");
|
||||
brew_str("\nEnter operation number: ");
|
||||
|
||||
// Clear buffer for new input
|
||||
buffer_pos = 0;
|
||||
|
||||
// Wait for operation choice
|
||||
while (1) {
|
||||
if (check_keyboard()) {
|
||||
unsigned char scan_code = read_scan_code();
|
||||
char ascii_char = scan_code_to_ascii(scan_code);
|
||||
|
||||
if (ascii_char >= '1' && ascii_char <= '4') {
|
||||
print_char(ascii_char);
|
||||
char operation = ascii_char;
|
||||
brew_str("\nEnter first number: ");
|
||||
|
||||
// Get first number
|
||||
buffer_pos = 0;
|
||||
int first_num = 0;
|
||||
while (1) {
|
||||
if (check_keyboard()) {
|
||||
scan_code = read_scan_code();
|
||||
ascii_char = scan_code_to_ascii(scan_code);
|
||||
|
||||
if (ascii_char >= '0' && ascii_char <= '9') {
|
||||
print_char(ascii_char);
|
||||
first_num = first_num * 10 + (ascii_char - '0');
|
||||
} else if (ascii_char == '\n' || ascii_char == '\r') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
brew_str("\nEnter second number: ");
|
||||
|
||||
// Get second number
|
||||
buffer_pos = 0;
|
||||
int second_num = 0;
|
||||
while (1) {
|
||||
if (check_keyboard()) {
|
||||
scan_code = read_scan_code();
|
||||
ascii_char = scan_code_to_ascii(scan_code);
|
||||
|
||||
if (ascii_char >= '0' && ascii_char <= '9') {
|
||||
print_char(ascii_char);
|
||||
second_num = second_num * 10 + (ascii_char - '0');
|
||||
} else if (ascii_char == '\n' || ascii_char == '\r') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
brew_str("\nResult: ");
|
||||
switch (operation) {
|
||||
case '1':
|
||||
brew_str("\n");
|
||||
brew_int(first_num);
|
||||
brew_str(" + ");
|
||||
brew_int(second_num);
|
||||
brew_str(" = ");
|
||||
brew_int(first_num + second_num);
|
||||
break;
|
||||
case '2':
|
||||
brew_str("\n");
|
||||
brew_int(first_num);
|
||||
brew_str(" - ");
|
||||
brew_int(second_num);
|
||||
brew_str(" = ");
|
||||
brew_int(first_num - second_num);
|
||||
break;
|
||||
case '3':
|
||||
brew_str("\n");
|
||||
brew_int(first_num);
|
||||
brew_str(" * ");
|
||||
brew_int(second_num);
|
||||
brew_str(" = ");
|
||||
brew_int(first_num * second_num);
|
||||
break;
|
||||
case '4':
|
||||
if (second_num == 0) {
|
||||
brew_str("Error: Division by zero!\n");
|
||||
} else {
|
||||
brew_str("\n");
|
||||
brew_int(first_num);
|
||||
brew_str(" / ");
|
||||
brew_int(second_num);
|
||||
brew_str(" = ");
|
||||
brew_int(first_num / second_num);
|
||||
}
|
||||
break;
|
||||
}
|
||||
brew_str("\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // APPS_MATH_H
|
||||
52
src/kernel/cli_apps_old/readtheman.h
Normal file
52
src/kernel/cli_apps_old/readtheman.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef APPS_NERD_H
|
||||
#define APPS_NERD_H
|
||||
|
||||
#include "../io.h"
|
||||
#include "../print.h"
|
||||
|
||||
static void nerd() {
|
||||
brew_str("\n");
|
||||
brew_str("You read the manual? NERD. you know what?\n");
|
||||
brew_str("Fuck you.\n");
|
||||
brewing(5000000000);
|
||||
|
||||
|
||||
// Set the PIT to the desired frequency (1000 Hz for high pitch)
|
||||
outb(0x43, 0xB6); // Command byte: channel 2, mode 3, binary
|
||||
int frequency = 1000;
|
||||
int divisor = 1193180 / frequency;
|
||||
outb(0x42, divisor & 0xFF);
|
||||
outb(0x42, (divisor >> 8) & 0xFF);
|
||||
|
||||
outb(0x61, inb(0x61) | 0x03);
|
||||
|
||||
for(int i = 0; i < 1000000000000000000; i++) {
|
||||
print_set_color(PRINT_INDEX_0, PRINT_INDEX_15); // black on white
|
||||
print_clear();
|
||||
brewing(500000);
|
||||
|
||||
print_set_color(PRINT_INDEX_15, PRINT_INDEX_0); // white on black
|
||||
print_clear();
|
||||
brewing(500000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // APPS_NERD_H
|
||||
40
src/kernel/cli_apps_old/reboot.h
Normal file
40
src/kernel/cli_apps_old/reboot.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef REBOOT_H
|
||||
#define REBOOT_H
|
||||
|
||||
#include "../print.h"
|
||||
#include "../io.h"
|
||||
|
||||
void brewing(int iterations);
|
||||
|
||||
void reboot_command() {
|
||||
brew_str("\nInitiating system reboot...\n");
|
||||
brewing(10000000);
|
||||
while ((inb(0x64) & 2) != 0) {
|
||||
brewing(1000);
|
||||
}
|
||||
outb(0x64, 0xFE);
|
||||
brewing(50000000);
|
||||
asm volatile ("lidt %0" : : "m"(*(char*)0));
|
||||
asm volatile ("int $0x3");
|
||||
brew_str("WARNING: System reboot failed.\n");
|
||||
brew_str("Please reset your computer manually.\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
35
src/kernel/cli_apps_old/shutdown.h
Normal file
35
src/kernel/cli_apps_old/shutdown.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef SHUTDOWN_H
|
||||
#define SHUTDOWN_H
|
||||
|
||||
#include "../print.h"
|
||||
#include "../io.h"
|
||||
|
||||
void brewing(int iterations);
|
||||
|
||||
void shutdown_command() {
|
||||
brew_str("\nInitiating system shutdown...\n");
|
||||
brewing(10000000);
|
||||
outw(0xB004, 0x2000);
|
||||
outb(0x64, 0xFE);
|
||||
brew_str("WARNING: System shutdown failed.\n");
|
||||
brew_str("It is now safe to turn off your computer.\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
420
src/kernel/cli_apps_old/txtedit.h
Normal file
420
src/kernel/cli_apps_old/txtedit.h
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TXTEDIT_H
|
||||
#define TXTEDIT_H
|
||||
|
||||
#include "../print.h"
|
||||
#include "../keyboard.h"
|
||||
#include "../filesys.h"
|
||||
#include "../file.h"
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
#define MAX_LINES 25
|
||||
#define MAX_LINE_LENGTH 80
|
||||
|
||||
// Helper string functions for txtedit
|
||||
static int strcmp_txtedit(const char *s1, const char *s2) {
|
||||
while (*s1 && (*s1 == *s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
|
||||
}
|
||||
|
||||
static size_t strlen_txtedit(const char* str) {
|
||||
size_t len = 0;
|
||||
while (str[len]) len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
// Buffer for the current file being edited
|
||||
static char text_buffer[BUFFER_SIZE];
|
||||
static int buffer_size = 0;
|
||||
static int cursor_pos = 0;
|
||||
static int cursor_row = 0;
|
||||
static int cursor_col = 0;
|
||||
static int scroll_offset = 0; // Line number at top of visible area
|
||||
static int has_unsaved_changes = 0; // Flag to track if file has been modified
|
||||
#define ESC_KEY 0x01
|
||||
#define ENTER_KEY 0x1C
|
||||
#define BACKSPACE_KEY 0x0E
|
||||
#define SCAN_CODE_LEFT_ARROW 0x4B
|
||||
#define SCAN_CODE_RIGHT_ARROW 0x4D
|
||||
#define VISIBLE_LINES 23 // Lines 0-22 visible (line 23 is status)
|
||||
|
||||
// Status messages
|
||||
static const char* MSG_SAVED = "Text saved to RAM buffer";
|
||||
static const char* MSG_LOADED = "Text loaded from RAM buffer";
|
||||
static const char* MSG_HELP = "ESC:Exit ENTER:NewLine Arrows:Navigate";
|
||||
|
||||
static void draw_status_line(const char* msg) {
|
||||
size_t row, col;
|
||||
print_get_cursor_pos(&row, &col);
|
||||
print_set_cursor_pos(24, 0); // Bottom line
|
||||
print_set_color(PRINT_INDEX_0, PRINT_INDEX_7); // Black on light grey
|
||||
for(int i = 0; i < 80; i++) print_char(' '); // Clear line
|
||||
print_set_cursor_pos(24, 0);
|
||||
brew_str(msg);
|
||||
print_set_cursor_pos(row, col);
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0); // Reset colors to latte
|
||||
}
|
||||
|
||||
static void get_filename(char* filename) {
|
||||
int pos = 0;
|
||||
print_clear();
|
||||
brew_str("Enter filename (e.g., file.txt): ");
|
||||
|
||||
while(1) {
|
||||
if(check_keyboard()) {
|
||||
unsigned char scan_code = read_scan_code();
|
||||
|
||||
if(scan_code == 0x1C) { // Enter
|
||||
filename[pos] = '\0';
|
||||
break;
|
||||
}
|
||||
else if(scan_code == 0x0E) { // Backspace
|
||||
if(pos > 0) {
|
||||
pos--;
|
||||
print_backspace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
char c = scan_code_to_ascii(scan_code);
|
||||
if(c && pos < FS_MAX_FILENAME - 1) {
|
||||
filename[pos++] = c;
|
||||
print_char(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char current_filename[FS_MAX_FILENAME];
|
||||
|
||||
static void save_current_buffer(const char* text_buffer, int buffer_size, bool prompt_for_filename) {
|
||||
// If we don't have a current filename and need to prompt, ask for one
|
||||
if (current_filename[0] == '\0' && prompt_for_filename) {
|
||||
get_filename(current_filename);
|
||||
} else if (current_filename[0] == '\0') {
|
||||
draw_status_line("Error: No filename specified");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new file in the current directory
|
||||
File* file = fs_find_file(current_filename);
|
||||
if (!file) {
|
||||
file = fs_create_file(current_filename);
|
||||
}
|
||||
|
||||
if (file && file_write_content(file, text_buffer, buffer_size)) {
|
||||
draw_status_line("File saved successfully");
|
||||
} else {
|
||||
draw_status_line("Error: Could not save file");
|
||||
}
|
||||
}
|
||||
|
||||
static void calculate_cursor_position() {
|
||||
// Calculate cursor position based on buffer position
|
||||
cursor_row = 0;
|
||||
cursor_col = 0;
|
||||
int current_line = 0;
|
||||
|
||||
for(int i = 0; i < cursor_pos && i < buffer_size; i++) {
|
||||
if(text_buffer[i] == '\n') {
|
||||
current_line++;
|
||||
cursor_col = 0;
|
||||
} else {
|
||||
cursor_col++;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust display row based on scroll offset
|
||||
cursor_row = current_line - scroll_offset;
|
||||
|
||||
// Auto-scroll up if cursor goes above visible area
|
||||
if(cursor_row < 0) {
|
||||
scroll_offset += cursor_row;
|
||||
cursor_row = 0;
|
||||
}
|
||||
|
||||
// Auto-scroll down if cursor goes below visible area
|
||||
if(cursor_row >= VISIBLE_LINES) {
|
||||
scroll_offset += (cursor_row - VISIBLE_LINES + 1);
|
||||
cursor_row = VISIBLE_LINES - 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void redraw_screen() {
|
||||
print_disable_cursor();
|
||||
|
||||
print_clear();
|
||||
print_set_cursor_pos(0, 0);
|
||||
|
||||
// Draw the text buffer, starting from scroll_offset
|
||||
int current_line = 0;
|
||||
int display_line = 0;
|
||||
|
||||
for(int i = 0; i < buffer_size && display_line < VISIBLE_LINES; i++) {
|
||||
// Skip lines until we reach scroll_offset
|
||||
if(current_line < scroll_offset) {
|
||||
if(text_buffer[i] == '\n') {
|
||||
current_line++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// We're now in the visible area
|
||||
if(text_buffer[i] == '\n') {
|
||||
print_char('\n');
|
||||
current_line++;
|
||||
display_line++;
|
||||
if(display_line >= VISIBLE_LINES) break;
|
||||
} else {
|
||||
print_char(text_buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate cursor position based on cursor_pos in buffer
|
||||
calculate_cursor_position();
|
||||
|
||||
draw_status_line(MSG_HELP);
|
||||
// Position cursor correctly and re-enable it
|
||||
print_set_cursor_pos(cursor_row, cursor_col);
|
||||
print_enable_cursor();
|
||||
}
|
||||
|
||||
static void insert_char(char c) {
|
||||
if(buffer_size >= BUFFER_SIZE - 1) return;
|
||||
|
||||
// Move following text forward
|
||||
for(int i = buffer_size; i > cursor_pos; i--) {
|
||||
text_buffer[i] = text_buffer[i-1];
|
||||
}
|
||||
|
||||
text_buffer[cursor_pos] = c;
|
||||
cursor_pos++;
|
||||
buffer_size++;
|
||||
has_unsaved_changes = 1; // Mark file as modified
|
||||
|
||||
// Redraw the screen to properly display the inserted character
|
||||
redraw_screen();
|
||||
}
|
||||
|
||||
static void delete_char() {
|
||||
if(cursor_pos <= 0) return;
|
||||
|
||||
cursor_pos--;
|
||||
// Move following text backward
|
||||
for(int i = cursor_pos; i < buffer_size - 1; i++) {
|
||||
text_buffer[i] = text_buffer[i+1];
|
||||
}
|
||||
buffer_size--;
|
||||
has_unsaved_changes = 1; // Mark file as modified
|
||||
|
||||
// Redraw the screen to properly display after deletion
|
||||
redraw_screen();
|
||||
}
|
||||
|
||||
static void handle_special_key(unsigned char scan_code) {
|
||||
switch(scan_code) {
|
||||
case SCAN_CODE_UP_ARROW: {
|
||||
// Find the start of the current line
|
||||
int line_start = cursor_pos;
|
||||
while(line_start > 0 && text_buffer[line_start - 1] != '\n') {
|
||||
line_start--;
|
||||
}
|
||||
|
||||
// If we're on the first line, can't go up
|
||||
if(line_start == 0) break;
|
||||
|
||||
// Find the start of the previous line
|
||||
int prev_line_start = line_start - 1;
|
||||
while(prev_line_start > 0 && text_buffer[prev_line_start - 1] != '\n') {
|
||||
prev_line_start--;
|
||||
}
|
||||
|
||||
// Calculate target column position
|
||||
int target_col = cursor_pos - line_start;
|
||||
|
||||
// Find the end of the previous line
|
||||
int prev_line_end = prev_line_start;
|
||||
while(prev_line_end < line_start - 1 && text_buffer[prev_line_end] != '\n') {
|
||||
prev_line_end++;
|
||||
}
|
||||
|
||||
// Move cursor to same column in previous line (or end of line if shorter)
|
||||
int prev_line_length = prev_line_end - prev_line_start;
|
||||
cursor_pos = prev_line_start + (target_col < prev_line_length ? target_col : prev_line_length);
|
||||
calculate_cursor_position();
|
||||
redraw_screen();
|
||||
break;
|
||||
}
|
||||
|
||||
case SCAN_CODE_DOWN_ARROW: {
|
||||
// Find the start of the current line
|
||||
int line_start = cursor_pos;
|
||||
while(line_start > 0 && text_buffer[line_start - 1] != '\n') {
|
||||
line_start--;
|
||||
}
|
||||
|
||||
// Find the end of the current line
|
||||
int line_end = cursor_pos;
|
||||
while(line_end < buffer_size && text_buffer[line_end] != '\n') {
|
||||
line_end++;
|
||||
}
|
||||
|
||||
// If we're on the last line, can't go down
|
||||
if(line_end >= buffer_size) break;
|
||||
|
||||
// Move to start of next line
|
||||
int next_line_start = line_end + 1;
|
||||
if(next_line_start >= buffer_size) break;
|
||||
|
||||
// Find the end of the next line
|
||||
int next_line_end = next_line_start;
|
||||
while(next_line_end < buffer_size && text_buffer[next_line_end] != '\n') {
|
||||
next_line_end++;
|
||||
}
|
||||
|
||||
// Calculate target column position
|
||||
int target_col = cursor_pos - line_start;
|
||||
|
||||
// Move cursor to same column in next line (or end of line if shorter)
|
||||
int next_line_length = next_line_end - next_line_start;
|
||||
cursor_pos = next_line_start + (target_col < next_line_length ? target_col : next_line_length);
|
||||
calculate_cursor_position();
|
||||
redraw_screen();
|
||||
break;
|
||||
}
|
||||
|
||||
case SCAN_CODE_LEFT_ARROW:
|
||||
if(cursor_pos > 0) {
|
||||
cursor_pos--;
|
||||
calculate_cursor_position();
|
||||
redraw_screen();
|
||||
}
|
||||
break;
|
||||
|
||||
case SCAN_CODE_RIGHT_ARROW:
|
||||
if(cursor_pos < buffer_size) {
|
||||
cursor_pos++;
|
||||
calculate_cursor_position();
|
||||
redraw_screen();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void load_file(const char* filename) {
|
||||
File* file = fs_find_file(filename);
|
||||
if (!file) {
|
||||
draw_status_line("Creating new file");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t size;
|
||||
const char* content = file_get_content(file, &size);
|
||||
if (!content || size > BUFFER_SIZE) {
|
||||
draw_status_line("Error: Could not load file or file too large");
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy content to buffer
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
text_buffer[i] = content[i];
|
||||
}
|
||||
buffer_size = size;
|
||||
cursor_pos = 0; // Start at beginning of file
|
||||
has_unsaved_changes = 0; // File is not modified after loading
|
||||
draw_status_line("File loaded successfully");
|
||||
}
|
||||
|
||||
void txtedit_run(const char* filename) {
|
||||
print_set_color(PRINT_INDEX_7, PRINT_INDEX_0); // Set initial color to latte
|
||||
|
||||
// Clear the buffers and filename
|
||||
for(int i = 0; i < BUFFER_SIZE; i++) {
|
||||
text_buffer[i] = 0;
|
||||
}
|
||||
buffer_size = 0;
|
||||
cursor_pos = 0;
|
||||
scroll_offset = 0;
|
||||
has_unsaved_changes = 0;
|
||||
current_filename[0] = '\0';
|
||||
|
||||
// If filename is provided, store it
|
||||
if (filename) {
|
||||
int i;
|
||||
for (i = 0; filename[i] && i < FS_MAX_FILENAME - 1; i++) {
|
||||
current_filename[i] = filename[i];
|
||||
}
|
||||
current_filename[i] = '\0';
|
||||
load_file(filename);
|
||||
}
|
||||
|
||||
print_clear();
|
||||
redraw_screen();
|
||||
print_enable_cursor();
|
||||
|
||||
while(1) {
|
||||
if(check_keyboard()) {
|
||||
unsigned char scan_code = read_scan_code();
|
||||
|
||||
if(scan_code == ESC_KEY) {
|
||||
// Only ask to save if there are unsaved changes
|
||||
if(has_unsaved_changes) {
|
||||
draw_status_line("Save before exit? (Y/N)");
|
||||
while(1) {
|
||||
if(check_keyboard()) {
|
||||
unsigned char save_scan = read_scan_code();
|
||||
char save_char = scan_code_to_ascii(save_scan);
|
||||
if(save_char == 'Y' || save_char == 'y') {
|
||||
// Only prompt for filename if we don't have one (started with txtedit with no args)
|
||||
save_current_buffer(text_buffer, buffer_size, current_filename[0] == '\0');
|
||||
break;
|
||||
}
|
||||
else if(save_char == 'N' || save_char == 'n') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(scan_code == ENTER_KEY) {
|
||||
insert_char('\n');
|
||||
}
|
||||
else if(scan_code == BACKSPACE_KEY) {
|
||||
delete_char();
|
||||
}
|
||||
else if(scan_code == SCAN_CODE_UP_ARROW || scan_code == SCAN_CODE_DOWN_ARROW ||
|
||||
scan_code == SCAN_CODE_LEFT_ARROW || scan_code == SCAN_CODE_RIGHT_ARROW) {
|
||||
handle_special_key(scan_code);
|
||||
}
|
||||
else {
|
||||
char c = scan_code_to_ascii(scan_code);
|
||||
if(c) insert_char(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // TXTEDIT_H
|
||||
97
src/kernel/cli_apps_old/uptime.h
Normal file
97
src/kernel/cli_apps_old/uptime.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Brew Kernel
|
||||
* Copyright (C) 2024-2026 boreddevnl
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef UPTIME_H
|
||||
#define UPTIME_H
|
||||
|
||||
#include "print.h"
|
||||
#include "rtc.h"
|
||||
|
||||
// Global variable to store boot time
|
||||
static int boot_time_hour = -1;
|
||||
static int boot_time_min = -1;
|
||||
static int boot_time_sec = -1;
|
||||
|
||||
// Initialize boot time
|
||||
void init_uptime(void) {
|
||||
if (boot_time_hour == -1) {
|
||||
int year, month, day;
|
||||
get_datetime(&year, &month, &day, &boot_time_hour, &boot_time_min, &boot_time_sec);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to print a zero-padded integer
|
||||
static void brew_int_padded_uptime(int n) {
|
||||
if (n >= 0 && n < 10) {
|
||||
print_char('0');
|
||||
}
|
||||
brew_int(n);
|
||||
}
|
||||
|
||||
// Calculate time difference considering wraparound
|
||||
static void calc_time_diff(int start_h, int start_m, int start_s,
|
||||
int curr_h, int curr_m, int curr_s,
|
||||
int *diff_h, int *diff_m, int *diff_s) {
|
||||
int total_start_secs = start_h * 3600 + start_m * 60 + start_s;
|
||||
int total_curr_secs = curr_h * 3600 + curr_m * 60 + curr_s;
|
||||
|
||||
// Handle day wraparound
|
||||
if (total_curr_secs < total_start_secs) {
|
||||
total_curr_secs += 24 * 3600; // Add a full day of seconds
|
||||
}
|
||||
|
||||
int diff_secs = total_curr_secs - total_start_secs;
|
||||
|
||||
*diff_h = diff_secs / 3600;
|
||||
diff_secs %= 3600;
|
||||
*diff_m = diff_secs / 60;
|
||||
*diff_s = diff_secs % 60;
|
||||
}
|
||||
|
||||
// Display uptime command
|
||||
static void display_uptime(void) {
|
||||
init_uptime(); // Ensure boot time is initialized
|
||||
|
||||
int curr_hour, curr_min, curr_sec;
|
||||
int year, month, day;
|
||||
get_datetime(&year, &month, &day, &curr_hour, &curr_min, &curr_sec);
|
||||
|
||||
int up_hours, up_minutes, up_seconds;
|
||||
calc_time_diff(boot_time_hour, boot_time_min, boot_time_sec,
|
||||
curr_hour, curr_min, curr_sec,
|
||||
&up_hours, &up_minutes, &up_seconds);
|
||||
|
||||
brew_str("\nSystem uptime: ");
|
||||
if (up_hours > 0) {
|
||||
brew_int(up_hours);
|
||||
brew_str(" hour");
|
||||
if (up_hours != 1) brew_str("s");
|
||||
brew_str(" ");
|
||||
}
|
||||
if (up_minutes > 0 || up_hours > 0) {
|
||||
brew_int(up_minutes);
|
||||
brew_str(" minute");
|
||||
if (up_minutes != 1) brew_str("s");
|
||||
brew_str(" ");
|
||||
}
|
||||
brew_int(up_seconds);
|
||||
brew_str(" second");
|
||||
if (up_seconds != 1) brew_str("s");
|
||||
brew_str("\n");
|
||||
}
|
||||
|
||||
#endif // UPTIME_H
|
||||
711
src/kernel/cmd.c
Normal file
711
src/kernel/cmd.c
Normal file
|
|
@ -0,0 +1,711 @@
|
|||
#include "cmd.h"
|
||||
#include "graphics.h"
|
||||
#include "wm.h"
|
||||
#include "io.h"
|
||||
#include "rtc.h"
|
||||
#include "notepad.h"
|
||||
#include "calculator.h"
|
||||
#include "fat32.h"
|
||||
#include "cli_apps/cli_apps.h"
|
||||
#include "licensewr.h"
|
||||
#include <stddef.h>
|
||||
#include "memory_manager.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define CMD_COLS 70
|
||||
#define CMD_ROWS 25
|
||||
#define LINE_HEIGHT 10
|
||||
#define CHAR_WIDTH 8
|
||||
#define PROMPT "> "
|
||||
|
||||
#define COLOR_RED 0xFFFF0000
|
||||
|
||||
#define TXT_BUFFER_SIZE 4096
|
||||
#define TXT_VISIBLE_LINES (CMD_ROWS - 2)
|
||||
|
||||
#define FS_MAX_FILES 16
|
||||
#define FS_MAX_FILENAME 64
|
||||
#define FS_MAX_SIZE 4096
|
||||
|
||||
typedef struct {
|
||||
char name[FS_MAX_FILENAME];
|
||||
char content[FS_MAX_SIZE];
|
||||
int size;
|
||||
bool used;
|
||||
} RamFile;
|
||||
|
||||
static RamFile ram_fs[FS_MAX_FILES];
|
||||
|
||||
static void fs_init() {
|
||||
for (int i = 0; i < FS_MAX_FILES; i++) {
|
||||
ram_fs[i].used = false;
|
||||
ram_fs[i].size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RamFile* fs_find(const char *name) {
|
||||
for (int i = 0; i < FS_MAX_FILES; i++) {
|
||||
if (ram_fs[i].used) {
|
||||
// Simple strcmp
|
||||
const char *a = ram_fs[i].name;
|
||||
const char *b = name;
|
||||
bool match = true;
|
||||
while (*a && *b) {
|
||||
if (*a != *b) { match = false; break; }
|
||||
a++; b++;
|
||||
}
|
||||
if (match && *a == *b) return &ram_fs[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static RamFile* fs_create(const char *name) {
|
||||
if (fs_find(name)) return fs_find(name);
|
||||
for (int i = 0; i < FS_MAX_FILES; i++) {
|
||||
if (!ram_fs[i].used) {
|
||||
ram_fs[i].used = true;
|
||||
int j = 0;
|
||||
while (name[j] && j < FS_MAX_FILENAME - 1) {
|
||||
ram_fs[i].name[j] = name[j];
|
||||
j++;
|
||||
}
|
||||
ram_fs[i].name[j] = 0;
|
||||
ram_fs[i].size = 0;
|
||||
return &ram_fs[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// --- Structs ---
|
||||
typedef struct {
|
||||
char c;
|
||||
uint32_t color;
|
||||
} CharCell;
|
||||
|
||||
typedef enum {
|
||||
MODE_SHELL,
|
||||
MODE_PAGER
|
||||
} CmdMode;
|
||||
|
||||
// --- State ---
|
||||
Window win_cmd;
|
||||
|
||||
// Shell State
|
||||
static CharCell screen_buffer[CMD_ROWS][CMD_COLS];
|
||||
static int cursor_row = 0;
|
||||
static int cursor_col = 0;
|
||||
static uint32_t current_color = COLOR_LTGRAY;
|
||||
|
||||
// Pager State
|
||||
static CmdMode current_mode = MODE_SHELL;
|
||||
static char pager_wrapped_lines[2000][CMD_COLS + 1];
|
||||
static int pager_total_lines = 0;
|
||||
static int pager_top_line = 0;
|
||||
|
||||
// Boot time for uptime
|
||||
int boot_time_init = 0;
|
||||
int boot_year, boot_month, boot_day, boot_hour, boot_min, boot_sec;
|
||||
|
||||
// --- Helpers ---
|
||||
static void cmd_memset(void *dest, int val, size_t len) {
|
||||
unsigned char *ptr = dest;
|
||||
while (len-- > 0) *ptr++ = val;
|
||||
}
|
||||
|
||||
static size_t cmd_strlen(const char *str) {
|
||||
size_t len = 0;
|
||||
while (str[len]) len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int cmd_strcmp(const char *s1, const char *s2) {
|
||||
while (*s1 && (*s1 == *s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
|
||||
}
|
||||
|
||||
static void cmd_strcpy(char *dest, const char *src) {
|
||||
while (*src) *dest++ = *src++;
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
static int cmd_atoi(const char *str) {
|
||||
int res = 0;
|
||||
int sign = 1;
|
||||
if (*str == '-') { sign = -1; str++; }
|
||||
while (*str >= '0' && *str <= '9') {
|
||||
res = res * 10 + (*str - '0');
|
||||
str++;
|
||||
}
|
||||
return res * sign;
|
||||
}
|
||||
|
||||
static void brewing(int iterations) {
|
||||
for (volatile int i = 0; i < iterations; i++) {
|
||||
__asm__ __volatile__("nop");
|
||||
}
|
||||
}
|
||||
|
||||
static void itoa(int n, char *buf) {
|
||||
if (n == 0) {
|
||||
buf[0] = '0'; buf[1] = 0; return;
|
||||
}
|
||||
int i = 0;
|
||||
int sign = n < 0;
|
||||
if (sign) n = -n;
|
||||
while (n > 0) {
|
||||
buf[i++] = (n % 10) + '0';
|
||||
n /= 10;
|
||||
}
|
||||
if (sign) buf[i++] = '-';
|
||||
buf[i] = 0;
|
||||
// Reverse
|
||||
for (int j = 0; j < i / 2; j++) {
|
||||
char t = buf[j];
|
||||
buf[j] = buf[i - 1 - j];
|
||||
buf[i - 1 - j] = t;
|
||||
}
|
||||
}
|
||||
|
||||
// Manual and license pages are now in the individual command files
|
||||
|
||||
// --- Terminal Emulation ---
|
||||
|
||||
static void cmd_scroll_up() {
|
||||
for (int r = 1; r < CMD_ROWS; r++) {
|
||||
for (int c = 0; c < CMD_COLS; c++) {
|
||||
screen_buffer[r - 1][c] = screen_buffer[r][c];
|
||||
}
|
||||
}
|
||||
// Clear bottom row
|
||||
for (int c = 0; c < CMD_COLS; c++) {
|
||||
screen_buffer[CMD_ROWS - 1][c].c = ' ';
|
||||
screen_buffer[CMD_ROWS - 1][c].color = current_color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Public for CLI apps to use
|
||||
void cmd_putchar(char c) {
|
||||
if (c == '\n') {
|
||||
cursor_col = 0;
|
||||
cursor_row++;
|
||||
} else if (c == '\b') {
|
||||
if (cursor_col > 0) {
|
||||
cursor_col--;
|
||||
screen_buffer[cursor_row][cursor_col].c = ' ';
|
||||
}
|
||||
} else {
|
||||
if (cursor_col >= CMD_COLS) {
|
||||
cursor_col = 0;
|
||||
cursor_row++;
|
||||
}
|
||||
|
||||
if (cursor_row >= CMD_ROWS) {
|
||||
cmd_scroll_up();
|
||||
cursor_row = CMD_ROWS - 1;
|
||||
}
|
||||
|
||||
screen_buffer[cursor_row][cursor_col].c = c;
|
||||
screen_buffer[cursor_row][cursor_col].color = current_color;
|
||||
cursor_col++;
|
||||
}
|
||||
|
||||
if (cursor_row >= CMD_ROWS) {
|
||||
cmd_scroll_up();
|
||||
cursor_row = CMD_ROWS - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Public for CLI apps to use
|
||||
void cmd_write(const char *str) {
|
||||
while (*str) {
|
||||
cmd_putchar(*str++);
|
||||
}
|
||||
}
|
||||
|
||||
// Public for CLI apps to use
|
||||
void cmd_write_int(int n) {
|
||||
char buf[32];
|
||||
itoa(n, buf);
|
||||
cmd_write(buf);
|
||||
}
|
||||
|
||||
// --- Pager Logic ---
|
||||
|
||||
// Public for CLI apps to use - clear the terminal screen
|
||||
void cmd_screen_clear() {
|
||||
for(int r=0; r<CMD_ROWS; r++) {
|
||||
for(int c=0; c<CMD_COLS; c++) {
|
||||
screen_buffer[r][c].c = ' ';
|
||||
screen_buffer[r][c].color = COLOR_LTGRAY;
|
||||
}
|
||||
}
|
||||
cursor_row = 0;
|
||||
cursor_col = 0;
|
||||
}
|
||||
|
||||
// Public for CLI apps to use - exit/close the terminal window
|
||||
void cmd_window_exit() {
|
||||
win_cmd.visible = false;
|
||||
}
|
||||
|
||||
// Public for CLI apps to use
|
||||
void pager_wrap_content(const char **lines, int count) {
|
||||
pager_total_lines = 0;
|
||||
pager_top_line = 0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
const char *line = lines[i];
|
||||
int len = cmd_strlen(line);
|
||||
|
||||
if (len == 0) {
|
||||
pager_wrapped_lines[pager_total_lines][0] = 0;
|
||||
pager_total_lines++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Intelligent Word Wrap
|
||||
int processed = 0;
|
||||
while (processed < len) {
|
||||
if (pager_total_lines >= 2000) break;
|
||||
|
||||
int remaining = len - processed;
|
||||
int chunk_len = remaining;
|
||||
if (chunk_len > CMD_COLS) chunk_len = CMD_COLS;
|
||||
|
||||
// If we are cutting a word, backtrack to last space
|
||||
if (chunk_len < remaining) { // Only check if we are actually wrapping
|
||||
int split_point = chunk_len;
|
||||
while (split_point > 0 && line[processed + split_point] != ' ') {
|
||||
split_point--;
|
||||
}
|
||||
|
||||
if (split_point > 0) {
|
||||
chunk_len = split_point; // Cut at space
|
||||
}
|
||||
// If split_point == 0, the word is longer than the line, so forced split is okay.
|
||||
}
|
||||
|
||||
// Copy chunk
|
||||
for (int k = 0; k < chunk_len; k++) {
|
||||
pager_wrapped_lines[pager_total_lines][k] = line[processed + k];
|
||||
}
|
||||
pager_wrapped_lines[pager_total_lines][chunk_len] = 0;
|
||||
|
||||
pager_total_lines++;
|
||||
processed += chunk_len;
|
||||
|
||||
// Skip the space we just split on
|
||||
if (processed < len && line[processed] == ' ') {
|
||||
processed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Public for CLI apps to use
|
||||
void pager_set_mode(void) {
|
||||
current_mode = MODE_PAGER;
|
||||
}
|
||||
|
||||
// --- Commands (now delegated to cli_apps/) ---
|
||||
|
||||
// Command dispatch table
|
||||
typedef struct {
|
||||
const char *name;
|
||||
void (*func)(char *args);
|
||||
} CommandEntry;
|
||||
|
||||
static const CommandEntry commands[] = {
|
||||
{"HELP", cli_cmd_help},
|
||||
{"help", cli_cmd_help},
|
||||
{"DATE", cli_cmd_date},
|
||||
{"date", cli_cmd_date},
|
||||
{"CLEAR", cli_cmd_clear},
|
||||
{"clear", cli_cmd_clear},
|
||||
{"ABOUT", cli_cmd_about},
|
||||
{"about", cli_cmd_about},
|
||||
{"MATH", cli_cmd_math},
|
||||
{"math", cli_cmd_math},
|
||||
{"MAN", cli_cmd_man},
|
||||
{"man", cli_cmd_man},
|
||||
{"LICENSE", cli_cmd_license},
|
||||
{"license", cli_cmd_license},
|
||||
{"TXTEDIT", cli_cmd_txtedit},
|
||||
{"txtedit", cli_cmd_txtedit},
|
||||
{"UPTIME", cli_cmd_uptime},
|
||||
{"uptime", cli_cmd_uptime},
|
||||
{"BEEP", cli_cmd_beep},
|
||||
{"beep", cli_cmd_beep},
|
||||
{"COWSAY", cli_cmd_cowsay},
|
||||
{"cowsay", cli_cmd_cowsay},
|
||||
{"REBOOT", cli_cmd_reboot},
|
||||
{"reboot", cli_cmd_reboot},
|
||||
{"SHUTDOWN", cli_cmd_shutdown},
|
||||
{"shutdown", cli_cmd_shutdown},
|
||||
{"IREADTHEMANUAL", cli_cmd_readtheman},
|
||||
{"ireadthemanual", cli_cmd_readtheman},
|
||||
{"BLIND", cli_cmd_blind},
|
||||
{"blind", cli_cmd_blind},
|
||||
{"EXIT", cli_cmd_exit},
|
||||
{"exit", cli_cmd_exit},
|
||||
// Filesystem Commands
|
||||
{"CD", cli_cmd_cd},
|
||||
{"cd", cli_cmd_cd},
|
||||
{"PWD", cli_cmd_pwd},
|
||||
{"pwd", cli_cmd_pwd},
|
||||
{"LS", cli_cmd_ls},
|
||||
{"ls", cli_cmd_ls},
|
||||
{"MKDIR", cli_cmd_mkdir},
|
||||
{"mkdir", cli_cmd_mkdir},
|
||||
{"RM", cli_cmd_rm},
|
||||
{"rm", cli_cmd_rm},
|
||||
{"ECHO", cli_cmd_echo},
|
||||
{"echo", cli_cmd_echo},
|
||||
{"CAT", cli_cmd_cat},
|
||||
{"cat", cli_cmd_cat},
|
||||
// Memory Management Commands
|
||||
{"MEMINFO", cli_cmd_meminfo},
|
||||
{"meminfo", cli_cmd_meminfo},
|
||||
{"MALLOC", cli_cmd_malloc},
|
||||
{"malloc", cli_cmd_malloc},
|
||||
{"FREEMEM", cli_cmd_free_mem},
|
||||
{"freemem", cli_cmd_free_mem},
|
||||
{"MEMBLOCK", cli_cmd_memblock},
|
||||
{"memblock", cli_cmd_memblock},
|
||||
{"MEMVALID", cli_cmd_memvalid},
|
||||
{"memvalid", cli_cmd_memvalid},
|
||||
{"MEMTEST", cli_cmd_memtest},
|
||||
{"memtest", cli_cmd_memtest},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
// --- Dispatcher ---
|
||||
|
||||
// Buffer for capturing command output
|
||||
static char pipe_buffer[4096];
|
||||
static int pipe_buffer_pos = 0;
|
||||
|
||||
static void pipe_capture_write(const char *str) {
|
||||
while (*str && pipe_buffer_pos < (int)sizeof(pipe_buffer) - 1) {
|
||||
pipe_buffer[pipe_buffer_pos++] = *str++;
|
||||
}
|
||||
}
|
||||
|
||||
// Execute a single command
|
||||
static void cmd_exec_single(char *cmd) {
|
||||
while (*cmd == ' ') cmd++;
|
||||
if (!*cmd) return;
|
||||
|
||||
// Split cmd and args
|
||||
char *args = cmd;
|
||||
while (*args && *args != ' ') args++;
|
||||
if (*args) {
|
||||
*args = 0; // Null terminate cmd
|
||||
args++; // Point to start of args
|
||||
}
|
||||
|
||||
// Use command dispatch table
|
||||
for (int i = 0; commands[i].name != NULL; i++) {
|
||||
if (cmd_strcmp(cmd, commands[i].name) == 0) {
|
||||
commands[i].func(args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cmd_write("Unknown command: ");
|
||||
cmd_write(cmd);
|
||||
cmd_write("\n");
|
||||
}
|
||||
|
||||
// Execute command with pipe support
|
||||
static void cmd_exec(char *cmd) {
|
||||
// Check for pipe operator
|
||||
char *pipe_ptr = NULL;
|
||||
for (int i = 0; cmd[i]; i++) {
|
||||
if (cmd[i] == '|' && (i == 0 || cmd[i-1] != '>' && cmd[i+1] != '>' )) {
|
||||
pipe_ptr = &cmd[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pipe_ptr) {
|
||||
// No pipe - execute normally
|
||||
cmd_exec_single(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
// Split into two commands
|
||||
*pipe_ptr = 0;
|
||||
char *second_cmd = pipe_ptr + 1;
|
||||
|
||||
// Execute first command with output captured
|
||||
pipe_buffer_pos = 0;
|
||||
cmd_memset(pipe_buffer, 0, sizeof(pipe_buffer));
|
||||
|
||||
FAT32_FileHandle *pipe_file = fat32_open("_pipe_temp.tmp", "w");
|
||||
if (!pipe_file) {
|
||||
cmd_write("Error: Cannot create pipe\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cmd_exec_single(cmd);
|
||||
|
||||
fat32_close(pipe_file);
|
||||
|
||||
cmd_exec_single(second_cmd);
|
||||
}
|
||||
|
||||
|
||||
// --- Window Functions ---
|
||||
|
||||
static void cmd_paint(Window *win) {
|
||||
// Draw Window Content Background
|
||||
int offset_x = win->x + 4;
|
||||
int offset_y = win->y + 24;
|
||||
|
||||
// Fill background
|
||||
draw_rect(offset_x, offset_y, win->w - 8, win->h - 28, COLOR_BLACK);
|
||||
|
||||
int start_y = offset_y + 4;
|
||||
int start_x = offset_x + 4;
|
||||
|
||||
if (current_mode == MODE_PAGER) {
|
||||
// Draw Pager Content (Wrapped)
|
||||
for (int i = 0; i < CMD_ROWS && (pager_top_line + i) < pager_total_lines; i++) {
|
||||
draw_string(start_x, start_y + (i * LINE_HEIGHT), pager_wrapped_lines[pager_top_line + i], COLOR_LTGRAY);
|
||||
}
|
||||
|
||||
// Status Bar
|
||||
draw_string(start_x, start_y + (CMD_ROWS * LINE_HEIGHT), "-- Press Q to quit --", COLOR_WHITE);
|
||||
|
||||
} else {
|
||||
// Draw Shell Buffer
|
||||
for (int r = 0; r < CMD_ROWS; r++) {
|
||||
for (int c = 0; c < CMD_COLS; c++) {
|
||||
char ch = screen_buffer[r][c].c;
|
||||
if (ch != 0 && ch != ' ') {
|
||||
draw_char(start_x + (c * CHAR_WIDTH), start_y + (r * LINE_HEIGHT), ch, screen_buffer[r][c].color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Cursor
|
||||
if (win->focused) {
|
||||
draw_rect(start_x + (cursor_col * CHAR_WIDTH), start_y + (cursor_row * LINE_HEIGHT) + 8, CHAR_WIDTH, 2, COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_key(Window *target, char c) {
|
||||
(void)target;
|
||||
if (current_mode == MODE_PAGER) {
|
||||
if (c == 'q' || c == 'Q') {
|
||||
current_mode = MODE_SHELL;
|
||||
} else if (c == 17) { // UP
|
||||
if (pager_top_line > 0) pager_top_line--;
|
||||
} else if (c == 18) { // DOWN
|
||||
if (pager_top_line < pager_total_lines - CMD_ROWS) pager_top_line++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Shell Mode
|
||||
if (c == '\n') { // Enter
|
||||
char cmd_buf[CMD_COLS + 1];
|
||||
int len = 0;
|
||||
int prompt_len = cmd_strlen(PROMPT);
|
||||
|
||||
for (int i = prompt_len; i < CMD_COLS; i++) {
|
||||
char ch = screen_buffer[cursor_row][i].c;
|
||||
if (ch == 0) break;
|
||||
cmd_buf[len++] = ch;
|
||||
}
|
||||
while (len > 0 && cmd_buf[len-1] == ' ') len--;
|
||||
cmd_buf[len] = 0;
|
||||
|
||||
cmd_putchar('\n');
|
||||
|
||||
cmd_exec(cmd_buf);
|
||||
|
||||
cmd_write(PROMPT);
|
||||
} else if (c == 17) { // UP
|
||||
// History not implemented
|
||||
} else if (c == 18) { // DOWN
|
||||
|
||||
} else if (c == 19) { // LEFT
|
||||
if (cursor_col > (int)cmd_strlen(PROMPT)) {
|
||||
cursor_col--;
|
||||
}
|
||||
} else if (c == 20) { // RIGHT
|
||||
if (cursor_col < CMD_COLS - 1) {
|
||||
cursor_col++;
|
||||
}
|
||||
} else if (c == '\b') { // Backspace
|
||||
if (cursor_col > (int)cmd_strlen(PROMPT)) {
|
||||
cursor_col--;
|
||||
screen_buffer[cursor_row][cursor_col].c = ' ';
|
||||
}
|
||||
} else {
|
||||
if (c >= 32 && c <= 126) {
|
||||
cmd_putchar(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_reset(void) {
|
||||
// Reset terminal to fresh state
|
||||
cmd_screen_clear();
|
||||
cmd_write("BrewOS Command Prompt\n");
|
||||
cmd_write(PROMPT);
|
||||
}
|
||||
|
||||
static void create_test_files(void) {
|
||||
fat32_mkdir("Documents");
|
||||
fat32_mkdir("Projects");
|
||||
fat32_mkdir("Documents/Important");
|
||||
|
||||
FAT32_FileHandle *fh = fat32_open("README.md", "w");
|
||||
if (fh) {
|
||||
const char *content =
|
||||
"BREW OS 1.01 ALPHA\n"
|
||||
"==================\n\n"
|
||||
"BREWKERNEL IS NOW BREWOS!\n\n"
|
||||
"Brewkernel will from now on be deprecated as its core became too messy.\n"
|
||||
"I have built a less bloated kernel and wrote a DE above it, which is why\n"
|
||||
"it is now an OS instead of a kernel.\n\n"
|
||||
"Brew Kernel is a simple x86_64 hobbyist operating system.\n"
|
||||
"It features a DE (and WM), a FAT32 filesystem, customizable UI and much much more!\n"
|
||||
"ramdisk-like filesystem.\n\n"
|
||||
"FEATURES\n"
|
||||
"--------\n"
|
||||
"* Brew WM (Window Manager)\n"
|
||||
"* FAT32 Filesystem\n"
|
||||
"* 64-bit long mode support\n"
|
||||
"* Multiboot2 compliant\n"
|
||||
"* Text editor and file explorer\n"
|
||||
"* IDT (Interrupt Descriptor Table)\n"
|
||||
"* Ability to run on actual x86_64 hardware\n"
|
||||
"* Command-line interface (CLI)\n\n"
|
||||
"PREREQUISITES\n"
|
||||
"-------------\n"
|
||||
"To build BrewOS, you'll need the following tools installed:\n\n"
|
||||
"* x86_64 ELF Toolchain (x86_64-elf-gcc, x86_64-elf-ld)\n"
|
||||
"* NASM (Netwide Assembler)\n"
|
||||
"* xorriso (for creating bootable ISO images)\n"
|
||||
"* QEMU (optional, for testing in emulator)\n\n"
|
||||
"On macOS, install via Homebrew:\n"
|
||||
" brew install x86_64-elf-binutils x86_64-elf-gcc nasm xorriso qemu\n\n"
|
||||
"BUILDING\n"
|
||||
"--------\n"
|
||||
"Simply run 'make' from the project root:\n\n"
|
||||
" make\n\n"
|
||||
"This will:\n"
|
||||
"1. Download Limine v7.0.0 bootloader files (if not present)\n"
|
||||
"2. Compile all kernel C sources and assembly files\n"
|
||||
"3. Link the kernel ELF binary\n"
|
||||
"4. Generate a bootable ISO image (brewos.iso)\n\n"
|
||||
"Build output:\n"
|
||||
"* Compiled object files: build/\n"
|
||||
"* ISO root filesystem: iso_root/\n"
|
||||
"* Final ISO image: brewos.iso\n\n"
|
||||
"RUNNING\n"
|
||||
"-------\n"
|
||||
"QEMU EMULATION:\n"
|
||||
"Run in QEMU with:\n"
|
||||
" make run\n\n"
|
||||
"Or manually:\n"
|
||||
" qemu-system-x86_64 -m 2G -serial stdio -cdrom brewos.iso -boot d\n\n"
|
||||
"RUNNING ON REAL HARDWARE:\n"
|
||||
"WARNING: This is at YOUR OWN RISK. This software comes with ZERO warranty\n"
|
||||
"and may break your system.\n\n"
|
||||
"1. Create bootable USB using Balena Etcher to flash brewos.iso\n"
|
||||
"2. Enable legacy (BIOS) boot in your system BIOS/UEFI settings\n"
|
||||
"3. Disable Secure Boot if needed\n"
|
||||
"4. Insert USB drive and select it in boot menu during startup\n\n"
|
||||
"Tested Hardware:\n"
|
||||
"* HP EliteDesk 705 G4 DM (AMD Ryzen 5 PRO 2400G, Radeon Vega)\n"
|
||||
"* Lenovo ThinkPad A475 20KL002VMH (AMD Pro A12-8830B, Radeon R7)\n\n"
|
||||
"PROJECT STRUCTURE\n"
|
||||
"-----------------\n"
|
||||
"* src/kernel/ - Main kernel implementation\n"
|
||||
" - boot.asm - Boot assembly code\n"
|
||||
" - main.c - Kernel entry point\n"
|
||||
" - *.c / *.h - Core kernel modules\n"
|
||||
" - cli_apps/ - Command-line applications\n"
|
||||
" - wallpaper.ppm - Default desktop wallpaper\n"
|
||||
"* build/ - Compiled object files (generated during build)\n"
|
||||
"* iso_root/ - ISO filesystem layout (generated during build)\n"
|
||||
"* limine/ - Limine bootloader files (downloaded automatically)\n"
|
||||
"* linker.ld - Linker script for x86_64 ELF\n"
|
||||
"* limine.cfg - Limine bootloader configuration\n"
|
||||
"* Makefile - Build configuration and targets\n\n"
|
||||
"LICENSE\n"
|
||||
"-------\n"
|
||||
"Copyright (C) 2024-2026 boreddevnl\n\n"
|
||||
"This program is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n\n"
|
||||
"For full license details, see the LICENSE file in the repository.\n";
|
||||
fat32_write(fh, (void *)content, cmd_strlen(content));
|
||||
fat32_close(fh);
|
||||
}
|
||||
|
||||
write_license_file();
|
||||
|
||||
fh = fat32_open("Documents/notes.txt", "w");
|
||||
if (fh) {
|
||||
const char *content = "My Notes\n\n- First note\n- Second note\n";
|
||||
fat32_write(fh, (void *)content, 39);
|
||||
fat32_close(fh);
|
||||
}
|
||||
|
||||
fh = fat32_open("Documents/notes.txt", "w");
|
||||
if (fh) {
|
||||
const char *content = "My Notes\n\n- First note\n- Second note\n";
|
||||
fat32_write(fh, (void *)content, 39);
|
||||
fat32_close(fh);
|
||||
}
|
||||
|
||||
fh = fat32_open("Projects/project1.txt", "w");
|
||||
if (fh) {
|
||||
const char *content = "Project 1\n\nStatus: In Progress\n";
|
||||
fat32_write(fh, (void *)content, 32);
|
||||
fat32_close(fh);
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_init(void) {
|
||||
fs_init(); // Init RAMFS
|
||||
fat32_init(); // Init FAT32 filesystem
|
||||
create_test_files();
|
||||
|
||||
win_cmd.title = "Command Prompt";
|
||||
win_cmd.x = 50;
|
||||
win_cmd.y = 50;
|
||||
win_cmd.w = (CMD_COLS * CHAR_WIDTH) + 20;
|
||||
win_cmd.h = (CMD_ROWS * LINE_HEIGHT) + 40;
|
||||
|
||||
win_cmd.visible = false;
|
||||
win_cmd.focused = false;
|
||||
win_cmd.z_index = 0;
|
||||
win_cmd.paint = cmd_paint;
|
||||
win_cmd.handle_key = cmd_key;
|
||||
win_cmd.handle_click = NULL;
|
||||
win_cmd.handle_right_click = NULL;
|
||||
|
||||
cmd_reset();
|
||||
|
||||
if (!boot_time_init) {
|
||||
rtc_get_datetime(&boot_year, &boot_month, &boot_day, &boot_hour, &boot_min, &boot_sec);
|
||||
boot_time_init = 1;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue