Skip to content

Commit

Permalink
Merge pull request #2 from cortex-debug/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
thegecko authored Jan 30, 2023
2 parents 3598993 + c0707fd commit 9ed48c7
Show file tree
Hide file tree
Showing 29 changed files with 1,808 additions and 1,068 deletions.
56 changes: 38 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"serve": "serve --cors -p 9000"
},
"dependencies": {
"jszip": "^3.10.1",
"node-fetch": "^2.6.7",
"xml2js": "^0.4.23"
},
Expand All @@ -41,6 +42,7 @@
"@vscode/test-web": "^0.0.24",
"buffer": "^6.0.3",
"eslint": "^7.29.0",
"path-browserify": "1.0.1",
"serve": "^14.0.1",
"stream-browserify": "^3.0.0",
"timers-browserify": "^2.0.12",
Expand All @@ -63,7 +65,7 @@
},
"commands": [
{
"command": "svd-viewer.svd.setValue",
"command": "svd-viewer.svd.updateNode",
"title": "Update Value",
"icon": "$(edit)"
},
Expand All @@ -73,7 +75,7 @@
"icon": "$(files)"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"title": "Refresh",
"icon": "$(refresh)"
},
Expand All @@ -96,15 +98,15 @@
"menus": {
"commandPalette": [
{
"command": "svd-viewer.svd.setValue",
"command": "svd-viewer.svd.updateNode",
"when": "false"
},
{
"command": "svd-viewer.svd.copyValue",
"when": "false"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "false"
},
{
Expand All @@ -122,19 +124,19 @@
],
"touchBar": [
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem == registerRW"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem == register"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem == registerRO"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem =~ /peripheral.*/"
},
{
Expand All @@ -148,22 +150,22 @@
],
"view/item/context": [
{
"command": "svd-viewer.svd.setValue",
"command": "svd-viewer.svd.updateNode",
"when": "view == svd-viewer.svd && viewItem == field",
"group": "inline"
},
{
"command": "svd-viewer.svd.setValue",
"command": "svd-viewer.svd.updateNode",
"when": "view == svd-viewer.svd && viewItem == fieldWO",
"group": "inline"
},
{
"command": "svd-viewer.svd.setValue",
"command": "svd-viewer.svd.updateNode",
"when": "view == svd-viewer.svd && viewItem == registerRW",
"group": "inline"
},
{
"command": "svd-viewer.svd.setValue",
"command": "svd-viewer.svd.updateNode",
"when": "view == svd-viewer.svd && viewItem == registerWO",
"group": "inline"
},
Expand All @@ -183,22 +185,22 @@
"group": "inline"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem == registerRW",
"group": "inline"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem == register",
"group": "inline"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem == registerRO",
"group": "inline"
},
{
"command": "svd-viewer.svd.refreshValue",
"command": "svd-viewer.svd.forceRefresh",
"when": "view == svd-viewer.svd && viewItem =~ /peripheral.*/",
"group": "inline"
},
Expand Down Expand Up @@ -229,8 +231,26 @@
},
"svd-viewer.deviceConfig": {
"type": "string",
"default": "device",
"description": "Debug configuration key to use to get the device"
"default": "deviceName",
"description": "Debug configuration key to use to get the device name"
},
"svd-viewer.processorConfig": {
"type": "string",
"default": "processorName",
"description": "Debug configuration key to use to get the procerssor name"
},
"svd-viewer.svdAddrGapThreshold": {
"type": "number",
"default": 16,
"multipleOf": 1,
"minimum": -1,
"maximum": 32,
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device. -1 means never combine registers and is very slow"
},
"svd-viewer.packAssetUrl": {
"type": "string",
"default": "https://pack-asset-service.keil.arm.com",
"description": "Base URL for CMSIS pack assets"
}
}
}
Expand Down
57 changes: 57 additions & 0 deletions src/addrranges.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2017-2019 Marcel Ball
* https://github.com/Marus/cortex-debug
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

export class AddrRange {
constructor(public base: number, public length: number) {
}

/** return next address after this addr. range */
public nxtAddr(): number {
return this.base + this.length;
}

/** return last address in this range */
public endAddr(): number {
return this.nxtAddr() - 1;
}
}

export class AddressRangesUtils {
/**
* Returns a set of address ranges that have 0 < length <= maxBytes
*
* @param ranges array of ranges to check an split
* @param maxBytes limit of each range
* @param dbgMsg To output debug messages -- name of address space
* @param dbgLen To output debug messages -- total length of addr space
*/
public static splitIntoChunks(ranges: AddrRange[], maxBytes: number, _dbgMsg = '', _dbgLen = 0): AddrRange[] {
const newRanges = new Array<AddrRange>();
for (const r of ranges) {
while (r.length > maxBytes) {
newRanges.push(new AddrRange(r.base, maxBytes));
r.base += maxBytes;
r.length -= maxBytes;
}
if (r.length > 0) { // Watch out, can be negative
newRanges.push(r);
}
}
return newRanges;
}
}
24 changes: 17 additions & 7 deletions src/browser/extension.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
/**
* Copyright (C) 2023 Arm Limited
*/

import * as vscode from 'vscode';
import { PeripheralTree } from '../peripheral-tree';
import { SvdCommands } from '../svd-commands';
import { PeripheralTreeProvider } from '../views/peripheral';
import { Commands } from '../commands';
import { DebugTracker } from '../debug-tracker';
import { SvdRegistry } from '../svd-registry';
import { SvdResolver } from '../svd-resolver';

export const activate = async (context: vscode.ExtensionContext): Promise<void> => {
const peripheralTree = new PeripheralTree();
const commands = new SvdCommands(peripheralTree);
const tracker = new DebugTracker(peripheralTree);
export const activate = async (context: vscode.ExtensionContext): Promise<SvdRegistry> => {
const tracker = new DebugTracker();
const registry = new SvdRegistry();
const resolver = new SvdResolver(registry);
const peripheralTree = new PeripheralTreeProvider(tracker, resolver);
const commands = new Commands(peripheralTree);

await tracker.activate(context);
await peripheralTree.activate(context);
await commands.activate(context);
await tracker.activate(context);

return registry;
};

export const deactivate = async (): Promise<void> => {
Expand Down
53 changes: 53 additions & 0 deletions src/cmsis-pack/pack-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (C) 2023 Arm Limited
*/

import * as vscode from 'vscode';

const MAIN_DELIMITER = '::';
const VERSION_DELIMITER = '@';

export interface Pack {
vendor: string;
pack: string;
version?: string;
}

export const parsePackString = (packString: string): Pack | undefined => {
let parts = packString.split(MAIN_DELIMITER);

if (parts.length < 2) {
return undefined;
}

const vendor = parts[0];
let pack = parts[1];

parts = pack.split(VERSION_DELIMITER);
let version: string | undefined;

if (parts.length > 1) {
pack = parts[0];
version = parts[1];
}

return {
vendor,
pack,
version
};
};

export const pdscFromPack = (basePath: string, pack: Pack): vscode.Uri => {
const pdscFile = `${pack.vendor}.${pack.pack}.pdsc`;
return fileFromPack(basePath, pack, pdscFile);
};

export const fileFromPack = (basePath: string, pack: Pack, file: string): vscode.Uri => {
if (!pack.version) {
throw new Error('CMSIS pack version is required');
}

const baseUri = vscode.Uri.parse(basePath);
return vscode.Uri.joinPath(baseUri, pack.vendor, pack.pack, pack.version, file);
};
Loading

0 comments on commit 9ed48c7

Please sign in to comment.