mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[Review] Class to namespace
This commit is contained in:
@@ -26,8 +26,8 @@ void Boot::bootSlot(Bootloader::Slot s) {
|
||||
// We are trying to boot epsilon, so we check the version and show an advertisement if needed
|
||||
const char * version = s.userlandHeader()->version();
|
||||
const char * min = "18.2.4";
|
||||
int vsum = Bootloader::Utility::versionSum(version, strlen(version));
|
||||
int minsum = Bootloader::Utility::versionSum(min, strlen(min));
|
||||
int vsum = Utility::versionSum(version, strlen(version));
|
||||
int minsum = Utility::versionSum(min, strlen(min));
|
||||
if (vsum >= minsum) {
|
||||
Interface::drawEpsilonAdvertisement();
|
||||
uint64_t scan = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ char* reverse(char *buffer, int i, int j) {
|
||||
}
|
||||
|
||||
// Iterative function to implement `itoa()` function in C
|
||||
char* Bootloader::Utility::itoa(int value, char* buffer, int base) {
|
||||
char* Utility::itoa(int value, char* buffer, int base) {
|
||||
// invalid input
|
||||
if (base < 2 || base > 32) {
|
||||
return buffer;
|
||||
|
||||
@@ -24,9 +24,9 @@ const void(*KernelHeader::startPointer() const)() {
|
||||
}
|
||||
|
||||
const bool KernelHeader::isAboveVersion16 () const {
|
||||
int sum = Bootloader::Utility::versionSum(m_version, 2);
|
||||
int sum = Utility::versionSum(m_version, 2);
|
||||
char newVersion[] = "16";
|
||||
int min = Bootloader::Utility::versionSum(newVersion, 2);
|
||||
int min = Utility::versionSum(newVersion, 2);
|
||||
return sum >= min;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ static char data[255];
|
||||
|
||||
const char * Bootloader::USBData::buildStringDescriptor(StringHeader header, uint32_t startAddress, uint32_t size) {
|
||||
strlcpy(data, header.getString(), sizeof(data));
|
||||
Bootloader::Utility::itoa((int32_t)startAddress, &data[strlen(header.getString())], 16);
|
||||
Utility::itoa((int32_t)startAddress, &data[strlen(header.getString())], 16);
|
||||
data[strlen(header.getString()) + 8] = '/';
|
||||
data[strlen(header.getString()) + 8 + 1] = '0';
|
||||
data[strlen(header.getString()) + 8 + 2] = '1';
|
||||
data[strlen(header.getString()) + 8 + 3] = '*';
|
||||
data[strlen(header.getString()) + 8 + 4] = '0';
|
||||
Bootloader::Utility::itoa((int32_t)size/1024, &data[strlen(header.getString()) + 8 + 5], 10);
|
||||
Utility::itoa((int32_t)size/1024, &data[strlen(header.getString()) + 8 + 5], 10);
|
||||
data[strlen(header.getString()) + 8 + 5 + 2] = 'K';
|
||||
data[strlen(header.getString()) + 8 + 5 + 2 + 1] = 'g';
|
||||
data[strlen(header.getString()) + 8 + 5 + 2 + 2] = '\0';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <bootloader/utility.h>
|
||||
#include <string.h>
|
||||
|
||||
int Bootloader::Utility::versionSum(const char * version, int length) {
|
||||
int Utility::versionSum(const char * version, int length) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
sum += version[i] * (strlen(version) * 100 - i * 10);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#ifndef _BOOTLOADER_ITOA_H_
|
||||
#define _BOOTLOADER_ITOA_H_
|
||||
|
||||
namespace Bootloader {
|
||||
class Utility {
|
||||
public:
|
||||
static char * itoa(int value, char * result, int base);
|
||||
static int versionSum(const char * version, int length);
|
||||
};
|
||||
namespace Utility {
|
||||
|
||||
static char * itoa(int value, char * result, int base);
|
||||
static int versionSum(const char * version, int length);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user